Hosts File on MAC Leopard to resolve PC names

By admin | April 11, 2009

I have just built a new Coldfusion CF8 development server for the office. The old server has been decommisioned after many years of thank-less work.

Using a MAC for development purposes i noticed i couldn’t resolve any PC names across the network.

This is due to the MAC having no DNS server to tell it the names to resolve to.

After some searching i found you can modify the hosts file on the MAC (i’m using Leopard) to resolve the names you need for development purposes.

The old NetInfo on OS X has gone so you need to either modify the hosts file itself by opening the file or using Terminal to achieve this.

Firstly i tried opening the file but i ran into read-only permission problems when trying to save the file.

NB. The etc/ folder where the hosts file lives is hidden. You can find the etc/ directory (or ANY hidden directory for that matter) using the Finder –> Go –> Go To Folder option.

Anyways, i found a method using Terminal with the following commands.

1. Open Terminal through Applications –> Utilities –> Terminal

2. type in the command line of Terminal the following:

sudo nano /etc/hosts

Terminal will ask you input a password as you have envoked the Super User profile on the system. Nano will now open.

You will see the following come up on your terminal window:

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost

3. Move the cursor down the page with arrow keys and type in your desired IP address and tab once then the PC name.

127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
192.168.0.112 YourPCName

You need to save the changes by hitting ctrl+o or ^o.

Hit enter to name it hosts, then hit ^x to exit nano.

Your cache needs to be flushed to see the changes.

There is a new command for this in 10.5 Leopard.

dscacheutil -flushcache

After this is done you should be able to resolve the PC name on your MAC.

Happy Days!

  • Share/Save/Bookmark

Topics: MAX OS X 10.5 Leopard |

One Response to “Hosts File on MAC Leopard to resolve PC names”

  1. Scott B Says:
    December 9th, 2009 at 2:57 pm

    This solved my problem - thanks.

Comments