In the “real” world you simply add an entry to /etc/hosts like
1.2.3.4 myhost
The Mac OS X world is different. For version 10.5 and later you do the following
# Create the mapping
sudo dscl localhost -create /Local/Default/Hosts/x.y.z IPAddress 127.0.0.1
# flush the cache
sudo dscacheutil -flushcache
# Show the mappings
sudo dscl localhost -readall /Local/Default/Hosts
# Delete a mapping
sudo dscl localhost -delete /Local/Default/Hosts/x.y.z
sudo dscacheutil -flushcache
3 replies on “Forcing an IP Address”
[…] Further info here – Forcing an IP Address […]
Adding an entry to /etc/hosts works fine on 10.4 and 10.5. On 10.5 you don’t need to flush lookupd either. If the file doesn’t exist then just create it.
adding to hosts works fine for me on 10.6.6
It did change somewhere – I have some irritating sites mapped to 0.0.0.0 in my /etc/hosts. That used to send them nowhere, but now it’s sending them to localhost. But the local /etc/hosts file is still consulting. If I ping anything that’s in my hosts file, the ping goes to the IP from the hosts file, not the true IP.