Centos7 firewall的基本配置命令
Centos7 firewall的基本配置命令
Centos7以上版本默认防火墙为firewall,记录一下学习的firewall的基本配置。
查看防火墙运行状态
firewall-cmd –state
查看配置结果
firewall-cmd --list-all
查看所有规则
firewall-cmd --direct --get-all-rules
查看所有开放端口
firewall-cmd --zone=public --list-ports
查看ip限制
firewall-cmd --zone=public --list-rich-rules
开启端口
firewall-cmd --zone=public --add-port=22/tcp --permanent
关闭端口
firewall-cmd --zone=public --remove-port=22/tcp --permanent
重新载入防火墙
firewall-cmd --reload
下面两个是在配置过程中发现的两个漏洞,网上找到了解释及解决办法,实测可行。
ICMP timestamp请求响应漏洞:
远程主机会回复ICMP_TIMESTAMP查询并返回它们系统的当前时间。 这可能允许者一些基于时间认证的协议
修复:
firewall-cmd --permanent --direct --add-rule ipv4 filter INPUT 0 -p ICMP --icmp-type timestamp-request -m comment --comment "deny ICMP timestamp" -j DROP
firewall-cmd --permanent --direct --add-rule ipv4 filter INPUT 0 -p ICMP --icmp-type timestamp-reply -m comment --comment "deny ICMP timestamp" -j DROP
允许Traceroute探测漏洞:
本插件使用Traceroute探测来获取扫描器与远程主机之间的路由信息。或者也可以利用这些信息来了解目标网络的网络拓扑
修复:
firewall-cmd --permanent --direct --add-rule ipv4 filter INPUT 0 -p ICMP --icmp-type 11 -m comment --comment "deny traceroute" -j DROP
firewall-cmd --permanent --direct --add-rule ipv4 filter OUTPUT 0 -p ICMP --icmp-type 11 -m comment --comment "deny traceroute" -j DROP