Linux iptables NAT of an entire /24 subnetwork
From man iptables-extensions
:
NETMAP
This target allows you to statically map a whole network of addresses onto another network of addresses. It can only be used from rules in the nat table.
So one rule only is needed:
iptables -t nat -A PREROUTING -d 192.168.55.0/24 -i eth0 -j NETMAP --to 192.168.42.0/24
If you also want connections initially started from the "42" net to be seen correctly, complete with this second rule:
iptables -t nat -A POSTROUTING -s 192.168.42.0/24 -o eth0 -j NETMAP --to 192.168.55.0/24