Mac OS X Tiger for Unix Geeks

 < Day Day Up > 

Mac OS X consults both the /etc/hosts file and the /machines portion of the local directory. For example, the following entry in /etc/hosts would map the hostname xyzzy to 192.168.0.1:

192.168.0.1 xyzzy

5.8.1. Creating a Host with niload

The niload utility understands the flat file format used by /etc/hosts (ip_address name). See the hosts(5) manpage for a description of each field. To add a new host, create a file using that format and load it with niload. This example ads the host xyzzy:

$ sudo niload hosts . <<EOF > 192.168.0.1 xyzzy > EOF

If you add an entry that already exists, it will be overwritten.

The /etc/hosts file takes precedence over the local directory, so if you enter the same hostname with different IP addresses in both places, Mac OS X uses the one in /etc/hosts.

     < Day Day Up > 

    Категории