V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
2ME
V2EX  ›  NGINX

NGINX UDP 透明代理问题

  •  
  •   2ME · Jul 2, 2021 · 4054 views
    This topic created in 1763 days ago, the information mentioned may be changed or developed.

    gateway 172.0.0.1 NGINX(Kong) UDP 监听 53 端口
    udp-server 172.0.0.2 监听 30053 端口
    nginx 配置了透明代理proxy_bind $remote_addr transparent;
    配置后 udp-server 可以正常获取到客户端 ip 但是无法返回结果给客户端
    想问一下 iptable 怎么配置才能正常返回 网关和服务都是跑在 docker 里的
    这篇博客的 tc 命令返回值都是 Illegal "match"
    相关问题 https://forum.nginx.org/read.php?11,268467

    9 replies    2021-07-15 15:11:32 +08:00
    2ME
        1
    2ME  
    OP
       Jul 2, 2021
    在 output 链配置了 DNAT 不生效 Reply from unexpected source: gateway#53, expected udp-server#300553
    2ME
        2
    2ME  
    OP
       Jul 2, 2021
    #1 Reply from unexpected source: udp-server#30053, expected gateway#53
    guo4224
        3
    guo4224  
       Jul 6, 2021
    策略路由,或者直接把默认路由设置成你的 nginx 机器。其他的 haproxy 也是一样
    2ME
        4
    2ME  
    OP
       Jul 6, 2021 via iPhone
    @guo4224 这个好像不解决端口不匹配的问题
    learningman
        5
    learningman  
       Jul 6, 2021
    iptables MASQUERADE
    2ME
        6
    2ME  
    OP
       Jul 6, 2021
    @learningman MASQUERADE 只是 ip 伪装 不解决 port 不一致的问题
    guo4224
        7
    guo4224  
       Jul 9, 2021
    @2ME 端口不匹配是什么鬼?
    2ME
        8
    2ME  
    OP
       Jul 9, 2021
    @guo4224 入口是 nginx 监听的 53 端口 server 发起回复是 30053 端口 客户端发现回复的端口和发起请求的端口不一致会拒绝的 参考 2 楼的报错信息
    2ME
        9
    2ME  
    OP
       Jul 15, 2021
    http://disq.us/p/292lyfk 不知道 tc pedit 能不能解决这个问题
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2756 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 68ms · UTC 13:34 · PVG 21:34 · LAX 06:34 · JFK 09:34
    ♥ Do have faith in what you're doing.