2010-11-29 5 views
15

Как перенаправить один порт на другой локальный порт с помощью ip6tables? , например. что-то вроде этого: ip6tables -t физ -A PREROUTING -j REDIRECT -p TCP --dport 443 --to-порты 8443REDIRECT порт в ip6tables

ответ

4

ip6tables не поддерживает REDIRECT. (Обычно люди используют это в среде NAT, а NAT, как правило, не поддерживается с помощью IPv6.)

Если все, что вам нужно сделать, это привязать к нижнему порту как к обычным пользователям, почему бы не попробовать обходное решение, описанное в this answer? Конечно, в случае с Tomcat это звучит так, что это означает, что любой Java-процесс может работать.

+7

Видимо, `ip6tables` v1.4.18 и ядро ​​Linux v3.8 поддерживают` REDIRECT`: https://sector7g.be/posts/ipv6-nat-pre-routing-with-iptables – 2014-03-10 10:48:12

5

Ну это старый вопрос, но так как мне нужно сделать то же самое ... Вот что я нашел:

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.) 

Это справедливо для ip6tables только, конечно. Поэтому я предполагаю, что это действительно:

ip6tables -t mangle -A PREROUTING -p tcp --dport 443 -j TPROXY --on-port 8443 

Однако, я еще не пробовал.

+0

Вам будет труднее чем REDIRECT в IPv4 ... TPROXY имеет особое поведение в таблице mangle, поэтому вам нужно использовать метки на нем и расширенную маршрутизацию. – 2012-06-19 08:58:32