兩種常用開啓、關閉和重啓iptables操作:
[root@sky9896 ~]# service iptables start #開啓防火牆
[root@sky9896 ~]# /etc/init.d/iptables start #開啓防火牆
[root@sky9896 ~]# /etc/init.d/iptables stop #關閉防火牆
[root@sky9896 ~]# service iptables stop #關閉防火牆
[root@sky9896 ~]# service iptables restart #重啓防火牆
[root@sky9896 ~]# /etc/init.d/iptables restart #重啓防火牆
iptables:應用防火牆規則:[確定]
[root@sky9896 ~]# vi /etc/sysconfig/iptables #編輯防火牆配置文件
[root@sky9896 sky]# cat /etc/sysconfig/iptables
# Generated by iptables-save v1.4.7 on Tue Jan 27 20:36:02 2015
*filter
:INPUT ACCEPT [51:5520]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [38:3576]
-A INPUT -p tcp -m state --state NEW -m tcp --dport 9899 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A INPUT -p udp -m state --state NEW -m udp --dport 161 -j ACCEPT
-A INPUT -p udp -m state --state NEW -m udp --dport 3306 -j ACCEPT
-A INPUT -p udp -m state --state NEW -m udp --dport 514 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 10000 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 3000 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT
以上是生產服務器開啓tcp和udp的相關端口號。