iptables—icmp请求与响应规则

2015-10-29 04:30:51
标签:icmp iptables

icmp:0 8

0:响应请求

8:回答请求

 

本主机ping请求应答:

# 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上没有请求应答,需添加上:

# iptables -A INPUT -d 192.168.1.128 -p icmp --icmp-type 8 -j ACCEPT

再加上出向的响应:

# iptables -A OUTPUT -s 192.168.1.128 -p icmp --icmp-type 0 -j ACCEPT

 

本文出自 “我的学习博客” 博客,请务必保留此出处http://houzhimeng.blog.51cto.com/3938990/1707531

posted @ 2017-04-18 17:32  TDXR  阅读(105)  评论(0)    收藏  举报