1、进入目录:[[email protected] ~]# cd /etc/sysconfig

2、修改文件:[[email protected] sysconfig]# vi iptables
2.1打开文件后是这样
2.2按键盘的a键变成编辑状态
2.3在文件添加一句:-I INPUT -p tcp --dport 3306 -j ACCEPT
其中3306是端口号。如果添加80就写80
2.4按Esc键
2.5按Shift+:
2.6输入wq保存退出
3、重启防火墙
[[email protected] sysconfig]# service iptables restart
4、查看端口
[[email protected] sysconfig]# /etc/init.d/iptables status
表格:filter
Chain INPUT (policy ACCEPT)
num target prot opt source destination
1 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:3306
Chain FORWARD (policy ACCEPT)
num target prot opt source destination
Chain OUTPUT (policy ACCEPT)
num target prot opt source destination
转载于:https://www.cnblogs.com/Coling/articles/3521993.html