Note: this Tech Note is NOT WordPress specific, and is a little but more technical than normal. I’ve assumed a certain knowledge of unix command lines, DNS, IP addresses and smartphone network configuration.
I have an app. This app was built by an agency that I worked with, but makes use of an HTTP REST API that I built.
The API is moving to a new host, and the software that runs it is getting a serious upgrade. So, I wanted to test that the API still works, which I can do with the excellent PostMan Chrome extension (or any number of similar tools).
But I also wanted to actually, properly, test the app too! And to do that I’d need to some how spoof DNS for my smartphone that runs the app.
With a bit of help from @keiron I came across dnsChef: a Python-based DNS proxy. This lets me set up my laptop as a DNS server that I can tell my phone to use for DNS and that can send spoof IP addresses to my phone.
Here’s what to do (instructions for a Mac – Mac’s, by the way, come with Python installed).
sudo python setup.py install
Next, download and unzip dnsChef.
Then, you’ll need to run dnsChef, tell it to listen on your laptop’s external IP address, and tell it to mangle the IP address for a domain. Let’s say we want to listen on 192.168.1.45 as that’s our laptop’s IP address, and we want to “cook” google.com to be on 220.127.116.11, you would run:
sudo ./dnschef.py -i 192.168.1.45 --fakeip 18.104.22.168 --fakedomains google.com
Once that’s up and running you’ll need to go to your phone and manually configure the network to use 192.168.1.45 (or whatever) as the DNS server.
And that’s about it!