linux centos开启80、22、3306端口方案
1、设定
[root@localhost ~]# /sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
[root@localhost ~]# /sbin/iptables -I INPUT -p tcp --dport 22 -j ACCEPT
[root@localhost ~]# /sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
2、保存
[root@localhost ~]# /etc/rc.d/init.d/iptables save
3、重启防火墙
[root@localhost ~]# service iptables restart
4、查看
[root@localhost ~]# /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
2 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:22
3 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:80
Chain FORWARD (policy ACCEPT)
num target prot opt source destination
Chain OUTPUT (policy ACCEPT)
num target prot opt source destination