Linux防火墙

启动防火墙

systemctl start firewalld

查看防火墙状态

systemctl status firewalld 或者 firewall-cmd –state

端口操作

开启端口
firewall-cmd –zone=public –add-port=80/tcp –permanent
命令含义:
–zone #作用域
–add-port=80/tcp #添加端口,格式为:端口/通讯协议
–permanent #永久生效,没有此参数重启后失效

关闭一个端口:
firewall-cmd –permanent –remove-port=8080/tcp
打开某项服务:
firewall-cmd –permanent –add-service=http
关闭某项服务:
firewall-cmd –permanent –remove-service=http
进行端口转发:
firewall-cmd –permanent –add-forward-port=port=80:proto=tcp:toport=8080:toaddr=192.0.2.55
允许转发到其他地址:
firewall-cmd –permanent –add-masquerade
重新加载防火墙:
firewall-cmd –reload
三、配置firewall
查看版本:
firewall-cmd –version
查看帮助:
firewall-cmd –help
查看设置:
显示状态: firewallcmdstate: f i r e w a l l − c m d – s t a t e 查 看 区 域 信 息 : firewall-cmd –get-active-zones
查看指定接口所属区域:$ firewall-cmd –get-zone-of-interface=eth0
拒绝所有包:
firewall-cmd –panic-on
取消拒绝状态:
firewall-cmd –panic-off
查看是否拒绝:
firewall-cmd –query-panic

你可能感兴趣的:(Linux)