Assume I have a sever with X.X.X.X IP address and a web server with Y.Y.Y.Y IP address. How would I forward web traffic from X.X.X.X to Y.Y.Y.Y using iptables?
My servers run Linux and use iptables
Enable forwarding and tell iptable to forward. Assuming you are working on port 80 then the following:
Enable port forwarding
# echo "1" > /proc/sys/net/ipv4/ip_forward
Tell iptable your forwarding rules
# iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination Y.Y.Y.Y:80