For those of us the roam around on network connections, OpenDNS and Google Public DNS provide public DNS servers which offer better security than using arbitrary DNS that’s assigned to us when we connect to a network. This means that rather than trusting the assigned DNS server — which could be a malicious third party that’s attempting a man-in-the-middle attack — we always use a trusted server.
In OS X, normally, one can specify custom DNS servers in Network Preferences, but when using Internet Tethering with the iPhone, no options are available.
It’s possible to set DNS configuration on the command line, though, as mentioned in this MacOSXHints article.
This technique can be used within a shell script to make things easier.
As it happens, if you have a jailbroken iPhone, the trick works there too — just
ssh in as root, copy the script over, and run it from the iPhone.
The one caveat is that the DHCP client both on the iPhone and on Mac OS X will routinely reset the servers — I haven’t found a way to combat this yet, other than routinely re-running the script.
We have been using mobile broadband from my iPhone while we’ve been travelling; our current provider seems to go offline almost every evening — a quirk which I’ve just discovered is related to their faulty DNS server.
Using Google’s public DNS servers instead fixes this problem, so I was after a way to configure both the iPhone and OS X to use the servers.