V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
foxni
V2EX  ›  Linux

iptables 只允许某个 ip 的 ping 的规则

  •  
  •   foxni ·
    foxni · 2017-03-09 15:40:04 +08:00 · 3458 次点击
    这是一个创建于 2576 天前的主题,其中的信息可能已经有所发展或是发生改变。

    如题,这样的规则怎么写,目前我是所有都禁 ping 的,有些时候还是需要 ping 或者 mtr 来检查主机网络状况的,所以想放开某个 ip 。。。

    2 条回复    2017-03-15 00:11:42 +08:00
    knightdf
        1
    knightdf  
       2017-03-09 16:00:44 +08:00   ❤️ 1
    关键字: iptables icmp

    SERVER_IP="202.54.10.20"
    iptables -A INPUT -p icmp --icmp-type 8 -s 0/0 -d $SERVER_IP -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
    iptables -A OUTPUT -p icmp --icmp-type 0 -s $SERVER_IP -d 0/0 -m state --state ESTABLISHED,RELATED -j ACCEPT

    自己试试啊,我没实验
    foxni
        2
    foxni  
    OP
       2017-03-15 00:11:42 +08:00 via iPhone
    @knightdf 明天试试,这两天忙别的都差点忘了这事了,谢谢哈
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   994 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 20:07 · PVG 04:07 · LAX 13:07 · JFK 16:07
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.