Monday, September 26, 2011

A DNS server to test your mobile apps

Why would you want to set up an Internet Domain Name System server (DNS) on your laptop? Well, it can be handy to serve test domain names to your iPhone and test the mobile apps you're working on, or to use HTTPS on an insecure network with an TLS/SSL certificate you've created for your test domains.

DNS has a reputation to be tricky to set up, so I thought I'd share the steps to do it on Mac OS X. It's easy, when you know what to do.

Say you want to map the domain (an example test domain) and all the * sub-domains to IP address for example.

1) In a terminal window run the following commands:
sudo rndc-confgen -a -c /etc/rndc.key
to generate the rndc.key file as it's included by /etc/named.conf.
Named is the domain name server, rndc is the Mac OS name server control utility.

sudo launchctl load -w /System/Library/LaunchDaemons/org.isc.named.plist
to enable and start named.

2) Add the following to the /etc/named.conf file:
zone "" {
  type master;
  file "";

3) Create a /var/named/ file, containing this: 7200 IN SOA (
3 ; Serial
15 ; Refresh
3600 ; Retry
3000000 ; Expire 86400 ) ; TTL
IN MX 10
* IN A

4) Open your Mac OS System preferences, go to Network / Advanced / Dns and add to the top of the DNS servers list.

5) To test your new DNS settings try this:

6) On your iPhone go to Settings / your wifi network / DHCP and change the DNS field to your Mac OS system's IP address.

7) That's it! Now open in Safari on your iPhone. You should hit your mobile app running on

Hope this helps!

The postings on this site are my own and don’t necessarily represent positions, strategies or opinions of my employer IBM.