iptables—icmp请求与响应规则:

icmp:0 8

0:响应请求

8:回答请求


本主机ping请求应答:

[root@localhost ~]# iptables -A OUTPUT -s 192.168.1.128 -p icmp --icmp-type 8 -j ACCEPT

但是本机没有响应规则,所以ping不给回显。


此时需要加上本机回显规则:

[root@localhost ~]# iptables -A INPUT -d 192.168.1.128 -p icmp --icmp-type 0 -j ACCEPT
[root@localhost ~]# ping 192.168.1.129
PING 192.168.1.129 (192.168.1.129) 56(84) bytes of data.
64 bytes from 192.168.1.129: icmp_seq=1 ttl=64 time=0.319 ms
64 bytes from 192.168.1.129: icmp_seq=2 ttl=64 time=0.256 ms


此时外部ping本主机是ping不通内部的,因为input上没有请求应答,需添加上:

[root@localhost ~]# iptables -A INPUT -d 192.168.1.128 -p icmp --icmp-type 8 -j ACCEPT


再加上出向的响应:

[root@localhost ~]# iptables -A OUTPUT -s 192.168.1.128 -p icmp --icmp-type 0 -j ACCEPT


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章