centos iptables关于ping
配置iptables策略后,一般来说INPUT都是DROP然后配置需要通过的
当执行:
iptables -P INPUT DROP
后,机器就不能被ping通了!
因为icmp没有添加到规则中!
于是我执行如下代码:
iptables -A INPUT -p icmp -j ACCEPT
还是不能ping通!!
网上搜索后 使用如下代码:
iptables -A INPUT -p icmp --icmp-type 3 -j ACCEPT
iptables -A INPUT -p icmp --icmp-type 8 -j ACCEPT
iptables -A INPUT -p icmp --icmp-type 11 -j ACCEPT
可是,还是不能ping通!
最后网上搜索了下icmp-type,发现了下面这张表格:
| TYPE | CODE | Description | Query | Error |
|---|---|---|---|---|
| 0 | 0 | Echo Reply——回显应答(Ping应答) | x | |
| 3 | 0 | Network Unreachable——网络不可达 | x | |
| 3 | 1 | Host Unreachable——主机不可达 | x | |
| 3 | 2 | Protocol Unreachable——协议不可达 | x | |
| 3 | 3 | Port Unreachable——端口不可达 | x | |
| 3 | 4 | Fragmentation needed but no frag. bit set——需要进行分片但设置不分片比特 | x | |
| 3 | 5 | Source routing failed——源站选路失败 | x | |
| 3 | 6 | Destination network unknown——目的网络未知 | x | |
| 3 | 7 | Destination host unknown——目的主机未知 | x | |
| 3 | 8 | Source host isolated (obsolete)——源主机被隔离(作废不用) | x | |
| 3 | 9 | Destination network administratively prohibited——目的网络被强制禁止 | x | |
| 3 | 10 | Destination host administratively prohibited——目的主机被强制禁止 | x | |
| 3 | 11 | Network unreachable for TOS——由于服务类型TOS,网络不可达 | x | |
| 3 | 12 | Host unreachable for TOS——由于服务类型TOS,主机不可达 | x | |
| 3 | 13 | Communication administratively prohibited by filtering——由于过滤,通信被强制禁止 | x | |
| 3 | 14 | Host precedence violation——主机越权 | x | |
| 3 | 15 | Precedence cutoff in effect——优先中止生效 | x | |
| 4 | 0 | Source quench——源端被关闭(基本流控制) | ||
| 5 | 0 | Redirect for network——对网络重定向 | ||
| 5 | 1 | Redirect for host——对主机重定向 | ||
| 5 | 2 | Redirect for TOS and network——对服务类型和网络重定向 | ||
| 5 | 3 | Redirect for TOS and host——对服务类型和主机重定向 | ||
| 8 | 0 | Echo request——回显请求(Ping请求) | x | |
| 9 | 0 | Router advertisement——路由器通告 | ||
| 10 | 0 | Route solicitation——路由器请求 | ||
| 11 | 0 | TTL equals 0 during transit——传输期间生存时间为0 | x | |
| 11 | 1 | TTL equals 0 during reassembly——在数据报组装期间生存时间为0 | x | |
| 12 | 0 | IP header bad (catchall error)——坏的IP首部(包括各种差错) | x | |
| 12 | 1 | Required options missing——缺少必需的选项 | x | |
| 13 | 0 | Timestamp request (obsolete)——时间戳请求(作废不用) | x | |
| 14 | Timestamp reply (obsolete)——时间戳应答(作废不用) | x | ||
| 15 | 0 | Information request (obsolete)——信息请求(作废不用) | x | |
| 16 | 0 | Information reply (obsolete)——信息应答(作废不用) | x | |
| 17 | 0 | Address mask request——地址掩码请求 | x | |
| 18 | 0 | Address mask reply——地址掩码应答 |
从表中我们不难发现 ping请求是 type 8 而ping应答是type 0
于是更改iptables 为:
iptables -A INPUT -p icmp --icmp-type 0 -j ACCEPT
iptables -A INPUT -p icmp --icmp-type 8 -j ACCEPT
然后就发现能够ping通了!
然后保存防火墙规则,重启防火墙:
service iptables save
service iptables restart
centos iptables关于ping的更多相关文章
- centOS IP能ping通但是域名ping不通
centOS IP能ping通但是域名ping不通, 导致了yum update 无更新. 百度了很久,最后有个方法试过解决了: iptables -X iptables -F 然后重新 yum up ...
- iptables禁止ping入
iptables禁止ping入 以下设置将允许自己往外ping 不允许别人ping自己 vi /etc/sysconfig/iptables 加入如下2条规则 -A INPUT -p icmp --i ...
- Centos防火墙禁止ping和开启ping
1.允许PING设置 iptables -A INPUT -p icmp --icmp-type echo-request -j ACCEPT iptables -A OUTPUT -p icmp - ...
- mac pfctl / centos iptables 使用
mac使用pfctl 为了测试zk client的重连功能,需要模拟zk client与zk server网络连接出现问题的情况,经过查询资料发现可以使用防火墙阻止zk server启动端口上的流量实 ...
- Centos iptables防火墙关闭启动详解
CentOS .0默认使用的是firewall作为防火墙,使用iptables必须重新设置一下 .直接关闭防火墙 systemctl stop firewalld.service #停止firewal ...
- linux 中 iptables关于ping的问题
允许其他机器ping通防火墙 iptables -A INPUT -p icmp --icmp-type echo-request -j ACCEPT iptables -A OUTPUT -p ic ...
- CentOS iptables防火墙的基本应用讲解
iptables是Linux下不错的防火墙软件,本文主要给大家介绍下iptables的安装.规则增加和清除.开放指定端口.屏蔽指定ip和ip段等CentOS下iptables的基本应用. 一.ipta ...
- Centos iptables防火墙设置
iptables的基本语法格式 iptables [-t 表名] 命令选项 [链名] [条件匹配] [-j 目标动作或跳转]说明:表名.链名用于指定iptables命令所操作的表和链,命令选项用于指定 ...
- centos iptables
1.查看本机关于IPTABLES的设置情况iptables -L -niptables --listmore /etc/sysconfig/iptablesservice iptables statu ...
随机推荐
- HDU 1709 母函数天平问题 可出现减法的情况 The Balance
The Balance Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- golang effective 翻译
参考 Effective Go 官方文档 其他参考译文 https://studygolang.com/articles/3228 http://docscn.studygolang.com/doc/ ...
- Tomcat学习笔记(六)
Tomcat日志 网上找到一篇分析不错的博文 http://peiquan.blog.51cto.com/7518552/1580189/
- inux下设置mysql数据库字符集utf8
mysql中文乱码解决方法:将mysql数据库编码统一utf8 查看数据库编码: ? 1 <span style="font-size: 16px;"><stro ...
- 行为型设计模式之命令模式(Command)
结构 意图 将一个请求封装为一个对象,从而使你可用不同的请求对客户进行参数化:对请求排队或记录请求日志,以及支持可撤消的操作. 适用性 抽象出待执行的动作以参数化某对象,你可用过程语言中的回调(c a ...
- matlab7 + sqlitejdbc-v056.jar出现错误
conn=database('data.db','','','org.sqlite.JDBC','jdbc:sqlite:C:/MATLAB7/work/del_man_voice_from_wave ...
- protobuf 中的嵌套消息的使用 主要对set_allocated_和mutable_的使用
protobuf的简单的使用,不过还留下了一个问题,那就是之前主要介绍的都是对简单数据的赋值,简单数据直接采用set_xx()即可,但是如果不是简单变量而是自定义的复合类型变量,就没有简单的set函数 ...
- 给Input type='date'赋值
(如有错敬请指点,以下是我工作中遇到并且解决的问题) 需要使用AngularJS动态给<input type="date" />赋值. 我使用的是ng-bind=&qu ...
- dnspod 批量添加记录
#!/usr/bin/python #-*- coding: utf-8 -*- import os,requests,json import re,xlsxwriter,time import xl ...
- spark streaming 异常No output streams registered, so nothing to execute
实现spark streaming demo时,代码: public static void main (String[] args) { SparkConf conf = new SparkConf ...