Topics Map >
Using /etc/hosts on MacOS X
Note: It should be noted that this is not a UW-Madison Help Desk or DoIT Middleware supported procedure, and, naturally, we can't take responsibility for any damage you do while following or attempting to follow these procedures. Be sure you understand what you are doing.
How to do host resolution on OS X.
N.B.: YMMV. This works for me. It may not work for you. I can't believe Apple created a wonderful new OS and made it next to impossible to add an arbitrary hosts entry.
/etc/hoststo include the host you want to add. For example:
## # 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 184.108.40.206 login.wisc.eduLeave the other entries (localhost and broadcasthost) alone.
- Reload the NetInfo Database:
$ sudo niload -v -m hosts . < /etc/hosts 4 items read from input Netinfo /machines contains 4 items Processing input item: ip_address: 127.0.0.1 name: localhost merging directory /machines/localhost Processing input item: ip_address: 255.255.255.255 name: broadcasthost merging directory /machines/broadcasthost Processing input item: ip_address: ::1 name: localhost merging directory /machines/localhost Processing input item: ip_address: 220.127.116.11 name: login.wisc.edu merging directory /machines/login.wisc.edu
- Test it:
$ ping login.wisc.edu PING login.wisc.edu (18.104.22.168): 56 data bytes 64 bytes from 22.214.171.124: icmp_seq=0 ttl=62 time=0.963 ms ^C --- login.wisc.edu ping statistics --- 1 packets transmitted, 1 packets received, 0% packet loss round-trip min/avg/max/stddev = 0.963/0.963/0.963/nan ms
If that doesn't work (wrong address is listed), try sending a HUP to lookupd:
$ ps auxwwww | grep lookupd root 17320 0.0 0.1 29204 2008 ?? Ss 1:35PM 0:05.84 /usr/sbin/lookupd $ sudo kill -HUP 17320
- If that doesn't work, I don't know. Try rebooting. Pretend you're running Windows and you moved the mouse or something.