CentOS7 默认使用firewalld,我用不习惯,这里要先安装iptables:
1、先关闭并禁用firewalld
systemctl stop firewalld
systemctl disable firewalld
2、安装iptables
yum -y install iptables
比如这里要打开80和9000端口,9000端口只对ip为192.168.1.200开放
1、 vi /etc/sysconfig/iptables
2、 在配置22端口的那一行下面添加
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-I INPUT -p tcp --dport 9000 -j DROP
-I INPUT -s 192.168.1.200 -p tcp --dport 9000 -j ACCEPT
3、重启防火墙
systemctl restart iptables
本文介绍如何在CentOS7中停用firewalld并安装使用iptables,包括配置80和9000端口的方法,其中9000端口仅对特定IP开放。
774

被折叠的 条评论
为什么被折叠?



