kslr
V2EX  ›  问与答

Iptables 设置针对某个 IP 不进行端口转发?

  •  
  •   kslr · Mar 1, 2015 · 2300 views
    This topic created in 4185 days ago, the information mentioned may be changed or developed.

    我在Iptables上设置了53端口转发到1053端口,但是针对某几个IP希望仍然使用53端口,请问这该如何实现?

    3 replies    2015-03-01 23:10:24 +08:00
    icloudnet
        1
    icloudnet  
       Mar 1, 2015
    iptables -A INPUT -p tcp -s 你的IP --dport 53 -m state --state NEW,ESTABLISHED -j ACCEPT
    iptables -A OUTPUT -p tcp --sport 3306 -m state --state ESTABLISHED -j ACCEPT
    icloudnet
        2
    icloudnet  
       Mar 1, 2015
    上面第二行的3306改成53 (ps:发出去就没法改,:):(:)
    extreme
        3
    extreme  
       Mar 1, 2015
    是不是NAT表?
    如果是,就用RETURN。
    iptables -t nat -I PREROUTING -s 来源
    IP -p 协议 --dport 53 -j RETURN
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2655 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 05:15 · PVG 13:15 · LAX 22:15 · JFK 01:15
    ♥ Do have faith in what you're doing.