重定位ip6tables中的端口

Cha*_*Sun 16 iptables ipv6

如何使用ip6tables将一个端口重定向到另一个本地端口?例如:ip6tables -t nat -A PREROUTING -j REDIRECT -p tcp --dport 443 --to-ports 8443

mpo*_*llo 6

ip6tables不支持REDIRECT。(通常人们在 NAT 环境中使用它,而 IPv6 通常不支持 NAT。)

如果您需要做的只是作为普通用户绑定到低端口,为什么不尝试此答案中描述的解决方法?当然,就 Tomcat 而言,听起来这意味着为任何 Java 进程提供该功能。

  • 显然 `ip6tables` v1.4.18 和 Linux kernel v3.8 支持 `REDIRECT`:https://sector7g.be/posts/ipv6-nat-pre-routing-with-iptables (11认同)

Adr*_*erc 6

这是一个古老的问题,但是因为我需要做同样的事情......这就是我发现的:

TPROXY

This target is only valid in the mangle table, in the PREROUTING chain and user-defined chains which are only called from this chain. It redirects the packet to a local socket without changing the packet header in any way. It can also change the mark value which can then be used in advanced routing rules. It takes three options:
--on-port port
    This specifies a destination port to use. It is a required option, 0 means the new destination port is the same as the original. This is only valid if the rule also specifies -p tcp or -p udp. 
--on-ip address
    This specifies a destination address to use. By default the address is the IP address of the incoming interface. This is only valid if the rule also specifies -p tcp or -p udp. 
--tproxy-mark value[/mask]
    Marks packets with the given value/mask. The fwmark value set here can be used by advanced routing. (Required for transparent proxying to work: otherwise these packets will get forwarded, which is probably not what you want.)
Run Code Online (Sandbox Code Playgroud)

当然,这仅适用于ip6tables.所以我想这是有效的:

ip6tables -t mangle -A PREROUTING -p tcp --dport 443 -j TPROXY --on-port 8443
Run Code Online (Sandbox Code Playgroud)

但是,我还没试过.

  • 在我的测试框中的/usr/share/doc/iptables/changelog.Debian.gz中进行了一次简短的搜索之后,它似乎已被包含在1.4.11.1-1中,如http://bugs.debian.org所述. /cgi-bin/bugreport.cgi?bug=529954 (2认同)