iptables—icmp请求与响应规则:

时间:2015-10-29 07:21:23   收藏:0   阅读:414

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


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

原文:http://houzhimeng.blog.51cto.com/3938990/1707531

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!