I am looking for a solution where TCP packets need to be forwarded or broadcasted to multiple destinations. Using nftables, I managed to forward packets to another machine with the following rule:
nft -- add chain ip nat prerouting { type nat hook prerouting priority -100 \; } nft add chain ip nat postrouting { type nat hook postrouting priority 100 \; } nft add rule ip nat prerouting tcp dport 9000 dnat to 172.19.0.2 nft add rule ip nat postrouting ip daddr 172.19.0.1 masquerade I am not sure how to forward the same packet to other destinations, for example, 172.19.0.2. I tried the rule nft add rule nat prerouting dport 9000 dup to 172.20.0.2 in various ways, but it did not work. Can anyone help with this? Or is there any similar tool in Linux that I can use to achieve the same result?
Note: I have tried socat in combination with tee. However, I am not considering that as an option since using the fork option creates numerous child processes if one of the destinations is down.