Я пытаюсь перенаправить входящий трафик 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