Linuxにiptbablesの設定内容を確認、削除、保存する方法
1.firewallルールの確認
操作コマンド
[root@tp ~]# iptables -L -n
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain RH-Firewall-1-INPUT (0 references)
target prot opt source destination
ACCEPT all – 0.0.0.0/0 0.0.0.0/0
ACCEPT icmp – 0.0.0.0/0 0.0.0.0/0 icmp type 255
ACCEPT esp – 0.0.0.0/0 0.0.0.0/0
ACCEPT ah – 0.0.0.0/0 0.0.0.0/0
ACCEPT udp – 0.0.0.0/0 224.0.0.251 udp dpt:5353
ACCEPT udp – 0.0.0.0/0 0.0.0.0/0 udp dpt:631
ACCEPT all – 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
ACCEPT tcp – 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22
ACCEPT tcp – 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:80
ACCEPT tcp – 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:8080
ACCEPT tcp – 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:25
REJECT all – 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
2.firewallが起動しない場合
[root@tp ~]# iptables -L -n
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
3.既存firewallのルールをクリア
[root@tp ~]# iptables -F
[root@tp ~]# iptables -X
4.firewallのルール保存、再起動
[root@tp ~]# /etc/rc.d/init.d/iptables save
iptablesの再起動
[root@tp ~]# service iptables restart