码迷,mamicode.com
首页 > 其他好文 > 详细

iptables—icmp请求与响应规则:

时间:2015-10-29 07:22:24      阅读:341      评论:0      收藏:0      [点我收藏+]

标签:icmp   iptables   

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

iptables—icmp请求与响应规则:

标签:icmp   iptables   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!