I had some of my code (terrible as usual) pointing to an IP Address. I had downloaded my code to a local machine and wanted to use the same code to function of my local server!
I had the following options:
- Update the ipaddresses in my code to the localhost
- Cleanup the code to use a config file
Both of these are going to take some time and effort.
To overcome the problem, I decided to use a small hack!
I decided to point the address on my localsystem back to my localhost using the following command:
sudo iptables -t nat -A OUTPUT -p all -d 220.127.116.11 -j DNAT --to-destination 127.0.0.1
That's it! My code works on my local machine like magic using the same remote ipaddress code
For doing the same on Mac OSX:
sudo ifconfig lo0 alias 18.104.22.168
sudo ifconfig lo0 -alias 22.214.171.124
Further, check links here: https://serverfault.com/questions/102416/iptables-equivalent-for-mac-os-x/673551#673551
sudo ifconfig lo0 126.96.36.199 alias echo "rdr pass on lo0 inet proto tcp from any to 188.8.131.52 port 27017 -> 127.0.0.1 port 27017" | sudo pfctl -ef -
Subscribe to Santosh writes here
Get the latest posts delivered right to your inbox