Назад | Перейти на главную страницу

Параметр Iptables --to-ports с целью REDIRECT (ошибка?)

Я пытаюсь перенаправить входящий трафик UDP (514) на два порта (10514 и 10515) с помощью iptables. На странице руководства iptables-extensions для целевого REDIRECT используется синтаксис "--to-ports порт [-port]".

Упоминается, что вы можете указать как один порт, так и диапазон, но мне не удается заставить его работать в диапазоне. Вроде взять только первый порт диапазона.

Программное обеспечение прослушивает два порта

Вот правила, которые я использую, и iptables -nvL:

iptables -A INPUT -p udp --dport 10514 -s 10.0.0.0/8 -j ACCEPT
iptables -A INPUT -p udp --dport 10515 -s 10.0.0.0/8 -j ACCEPT
iptables -A PREROUTING -t nat -i eth0 -p udp --dport 514 -j REDIRECT --to-ports 10514-10515

Chain PREROUTING (policy ACCEPT 1550 packets, 93888 bytes)
 pkts bytes target     prot opt in     out     source               destination         
  424 72586 REDIRECT   udp  --  eth0   *       0.0.0.0/0            0.0.0.0/0            udp dpt:514 redir ports 10514-10515


Chain INPUT (policy DROP 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         

68854   14M ACCEPT     udp  --  *      *       10.0.0.0/8           0.0.0.0/0            udp dpt:10514
    0     0 ACCEPT     udp  --  *      *       10.0.0.0/8           0.0.0.0/0            udp dpt:10515 

Так что теперь я могу ответить на свой вопрос!

https://serverfault.com/a/741108/538674

Эта цель может быть решением проблемы без отключения отслеживания соединения но ему нужно последнее ядро

TEE The TEE target will clone a packet and redirect this clone to another machine on the local network segment. In other words, the nexthop must be the target, or you will have to configure the nexthop to forward it further if so desired.

--gateway ipaddr
    Send the cloned packet to the host reachable at the given IP address. Use of 0.0.0.0 (for IPv4 packets) or :: (IPv6) is invalid. 

To forward all incoming traffic on eth0 to an Network Layer logging box:

-t mangle -A PREROUTING -i eth0 -j TEE --gateway 2001:db8::1