Tuesday, November 4, 2008

Creating Local DNS entries on the Leopard

I recently had a problem with a WCF service which would not resolve correctly on my Mac. It turned out that although I was accessing the Service using an IP address the WSDL XML file contained a number of references to the host name. To address this I needed to create a local DNS lookup so it could resolve correctly.


In Windows this is a simple matter of editing the Hosts file in the C:\WINDOWS\system32\drivers\etc\hosts file.

For the Mac OSX we use the command:
sudo dscl localhost -create /Local/Default/Hosts/myHost IPAddress [IPAddress], then Enter the administrator password. Where myHost is the name of the host and IPAddess the address to resolve too.
Removing the entry is a matter of entering:
sudo dscl localhost -delete /Local/Default/Hosts/myHost