CentOS 7防火墙详细配置
1、查看防火墙状态
systemctl status firewalld
2、开启防火墙
systemctl start firewalld
3、关闭防火墙
systemctl stop firewalld
4、设置开机启动
systemctl enable firewalld
5、禁止开机启动
systemctl disable firewalld
6、查看防火墙配置
firewall-cmd --state firewall-cmd --list-all
7、查询端口是否开放
firewall-cmd --query-port=8080/tcp
8、允许80端口访问
firewall-cmd --permanent --add-port=80/tcp firewall-cmd --reload #重新加载防火墙配置才会起作用
9、移除80端口
firewall-cmd --permanent --remove-port=80/tcp firewall-cmd --reload
10、允许某个端口段
firewall-cmd --permanent --zone=public --add-port=1000-2000/tcp firewall-cmd --reload
11、允许某个IP访问,默认允许
firewall-cmd --permanent --add-rich-rule='rule family=ipv4 source address=192.168.1.169 accept' firewall-cmd --reload
12、禁止某个IP访问
firewall-cmd --permanent --add-rich-rule='rule family=ipv4 source address=10.0.0.42 drop' firewall-cmd --reload
13、允许某个IP访问某个端口
firewall-cmd --permanent --add-rich-rule='rule family=ipv4 source address=192.168.1.169 port protocol=tcp port=6379 accept' firewall-cmd --reload
14、移除以上规则
firewall-cmd --permanent --remove-rich-rule='rule family="ipv4" source address="192.168.1.169" port port="6379" protocol="tcp" accept' firewall-cmd --reload
15、允许某个IP段访问
firewall-cmd --permanent --add-rich-rule='rule family=ipv4 source address=10.0.0.0/24 accept'
16、重启防火墙
firewall-cmd --reload
本文出处:HiFeng'Blog
本文链接:https://hicairo.com/post/21.html
版权声明:本博客所有文章除特别声明外,均采用CC BY-NC-SA许可协议。转载请注明出处!
<< 上一篇
下一篇 >>