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

iptables 的 snat 写了--dport 就匹配不到呢

  •  
  •   d0m2o08 · Oct 25, 2021 · 2453 views
    This topic created in 1686 days ago, the information mentioned may be changed or developed.

    访问 2022 的数据包,修改目标地址

    iptables -t nat -I PREROUTING -p tcp --dport 2022 -j DNAT --to 10.133.64.84:22
    

    用这个匹配目的地是 64.84 目标端口 2022 的数据包 匹配不到

    iptables -t nat -I POSTROUTING -p tcp -d 10.133.64.84 --dport 2022 -j MASQUERADE
    

    如果写成这样就可以

    iptables -t nat -I POSTROUTING -p tcp -d 10.133.64.84  -j MASQUERADE
    

    各位大屌,为啥加了--dport 就不行了呢

    d0m2o08
        1
    d0m2o08  
    OP
       Oct 25, 2021
    搞懂了,dnat 的时候已经把目标端口改成 22 了 下面的--dport 要指定为 22😂
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2677 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 10:29 · PVG 18:29 · LAX 03:29 · JFK 06:29
    ♥ Do have faith in what you're doing.