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 ...
随机推荐
- [ecmagent][redis学习][1初识redis] python操作redis
#1 连接redis # 连接redis -- import redis -- 使用端口连接redis conn = redis.Redis(host=) -- 使用套接字连接 r = redis.R ...
- 【bzoj2396】神奇的矩阵 随机化
题目描述 给出三个行数和列数均为N的矩阵A.B.C,判断A*B=C是否成立. 输入 题目可能包含若干组数据.对于每组数据,第一行一个数N,接下来给出三个N*N的矩阵,依次为A.B.C三个矩阵. 输出 ...
- P2625 豪华游轮 (背包$dp$,数学)
题目链接 Solution 贼有意思的一个题目. 可以发现阻止我们走的更远的就是那些需要反向走的路程. 然后发现当角度越接近 \(180^\circ\) ,对我们最终的答案则更优. 所以先是一个背包把 ...
- code forces Codeforces Round #487 (Div. 2) C
C. A Mist of Florescence time limit per test 1 second memory limit per test 256 megabytes input stan ...
- Spring----01. 入门知识,IoC/DI
1.spring两个最基本概念:依赖注入DI.面向切面AOP 2.spring通过上下文Application Context装配bean,实现方式的区别是如何加载它们的配置信息, ClassPath ...
- Binary Indexted Tree 树状数组入门
感谢http://www.cnblogs.com/xudong-bupt/p/3484080.html 树状数组(BIT)是能够完成下述操作的数据结构: 给定一初始值全为零的数列a1,a2a,a3.. ...
- 【转】beyond compare 启动提示“应用程序发生错误”
[转]beyond compare 启动提示“应用程序发生错误” 今天到公司BCompare不能打开,重新安装也不能打开.最后处理下,就解决了.方法是把C:\Documents and Setti ...
- SecureCRT指南
本文主要介绍SecureCRT的使用方法和技巧. [概念解释]什么是SSH? SSH的英文全称是Secure Shell 传统的网络服务程序,如:FTP和telnet在本质上都是不安全的, 因为它们在 ...
- jQuery操作下拉列表以及单选多选框
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- 【原创】Linux环境下的图形系统和AMD R600显卡编程(6)——AMD显卡GPU命令格式
前面一篇blog里面描述了命令环缓冲区机制,在命令环机制下,驱动写入PM4(不知道为何会取这样一个名字)包格式的命令对显卡进行配置.这一篇blog将详细介绍命令包的格式. 当前定义了4中命令包,分别是 ...