How can I modify this iptables rule, so that all traffic which coming for this computer will be forwarded to 192.168.42.10?
iptables -t nat -A PREROUTING -s 192.168.46.0/24 -p tcp --dport 80 -j DNAT --to-destination 192.168.42.10:80
The problem is that I create the ip tables rule from ansible and created it in different environments, where the ip address ranges are different, but I want to forward the 80 port to 192.168.42.10 always.
net.ipv4.ip_forwardneed to be enabled? – krrr Jul 17 '20 at 14:46sudo iptables -t nat -A PREROUTING -p tcp --dport 8081 -j DNAT --to-destination 192.168.0.158:80andsudo iptables -t nat -A POSTROUTING -p tcp -d 192.168.0.158 --dport 80 -j SNAT --to-source 192.168.0.178:8081– David Jun 05 '21 at 13:13