Archivováno - Mac OS X: How to Add Hosts to Local Hosts File
This advanced document explains how to configure host information in cases where you do not have a domain name server (DNS) on the network, but need to resolve hostnames. For example, when two computers are connected with a crossover cable or a standalone hub and need to resolve hostnames, but one of the computers does not support Bonjour (formerly "Rendezvous," also known as Multicast DNS).
Mac OS X 10.2 or later
Edit the /private/etc/hosts file. For more information on how to use the hosts file, open Terminal and type: man hosts
Note: Editing this file requires root privileges.
Mac OS X 10.0 through 10.1.5
- 1. Open /Applications/Utilities/NetInfo Manager.
2. To allow editing the NetInfo database, click the padlock in the lower left corner of the window.
3. Enter your Admin password and click OK.
4. In the second column of the browser view, select the node named "machines." You will see entries for -DHCP-, broadcasthost, and localhost in the third column.
5. The quickest way to create a new entry is to duplicate an existing one. So select the "localhost" item in the third column.
6. Choose Duplicate from the Edit menu. A confirmation alert appears.
7. Click Duplicate. A new entry called "localhost copy" appears, and its properties are shown below the browser view.
8. Double-click the value of the ip_address property and enter the IP address of the other computer.
9. Double-click the value of the name property and enter the hostname you want for the other computer.
10. Click the serves property and choose Delete from the Edit menu.
11. Choose Save from the File menu. A confirmation alert appears.
12. Click Update this copy.
13. Repeat steps 6 through 12 for each additional host entry you wish to add.
14. Choose Quit from the NetInfo Manager menu. You do not need to restart the computer.
Note: If you have a number of hosts that you wish to add, you can use the niload command to add them. The file needs to be a standard UNIX hosts file. For instance, if you have a hosts file named "hosts.txt" you can enter the following command in Terminal to load the hosts into your local NetInfo database:
sudo niload hosts . < hosts.txt