Creating a NAT from loopback to a remote server

view full story

http://unix.stackexchange.com – My goal is to redirect connections from the local host to a remote server, and be able to change the remote address on the fly, without any client config changes. I can do this now using a nat on the external interface like so: LOCAL_IP= LOCAL_PORT=8888 REMOTE_IP= REMOTE_PORT=9999 iptables -t nat -A OUTPUT -p tcp -d $LOCAL_IP --dport $LOCAL_PORT -j DNAT --to-destination $REMOTE_IP:$REMOTE_PORT iptables -t nat -A POSTROUTING -p tcp -d $REMOTE_IP --dport $REMOTE_PORT -j SNAT --to-source $LOCAL_IP This works fine, but still couples the client's config to the hosts IP address (HowTos)