Need to route one ip address to another ip address? Use IP Tables.
Last night I was working on a WordPress site with my wife. I was hosting the site locally at 192.168.1.4, and I updated the “WordPress address (URL)” and “Blog address (URL)” to 192.168.1.4 so that my wife could log in to my machine and add posts. When I got to the library the next day, I was assigned a random IP address from the library’s server: so, I could not load my WordPress site locally any more!
WordPress was trying to load its files from 192.168.1.4, but I was no longer at that address. What I needed was a way to tell my system to point 192.168.1.4 to localhost: 127.0.0.1. To achieve this, I used IP Tables like so:
iptables -t nat -A OUTPUT -d 192.168.1.4 -j DNAT --to-destination 127.0.0.1
Problem solved. If you are going to do this kind of thing as a temporary fix: remember to reset your WordPress address to localhost and reset your tables to their previous configuration.