Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
foxni
V2EX  ›  Linux

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

  •  
  •   foxni ·
    foxni · Mar 9, 2017 · 4124 views
    This topic created in 3352 days ago, the information mentioned may be changed or developed.

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

    2 replies    2017-03-15 00:11:42 +08:00
    knightdf
        1
    knightdf  
       Mar 9, 2017   ❤️ 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
       Mar 15, 2017 via iPhone
    @knightdf 明天试试,这两天忙别的都差点忘了这事了,谢谢哈
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   945 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 21:12 · PVG 05:12 · LAX 14:12 · JFK 17:12
    ♥ Do have faith in what you're doing.