Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I somehow configured my Mac to route all requests for a particular IP Name (sample.com) to the loopback address (127.0.0.1). Now I'm trying to remove this, but can't determine where to do it.

  1. There is no entry for it under /etc/hosts.
  2. The routing table shows that it is mapping the IP Name to the IP address of the Mac.

Routing table output below:

Internet:

Destination        Gateway            Flags    Refs      Use  Netif Expire
default            192.168.2.1        UGSc        4        1    en0
127                sample.com         UCS         0        0    lo0
sample.com         sample.com         UH          1     7093    lo0
169.254            link#4             UCS         0        0    en0
192.168.2          link#4             UCS         6        0    en0
192.168.2.1        0:11:22:22:3f:fa   UHLW       20    55565    en0   1070
192.168.2.15       tsema.org          UHS         0        9    lo0
192.168.2.255      link#4             UHLWb       4    84777    en0

Any help would be greatly appreciated!

Update: Note - I can delete the route to the 192.168.2.15 address - just not the loopback. I'm guessing that it needs to be removed someplace else...

share|improve this question
add comment

4 Answers

So the key seems to have been that this is a host alias.

  1. I found a useful post

  2. I checked the cache for hosts

    sudo dscacheutil -cachedump -entries Host

  3. I found the host alias listed under /Local/Default

  4. I checked the Directory Services:

    sudo dscl localhost -list Local/Default/Host

  5. Sure enough, there it was!

  6. I deleted it:

    sudo dscl localhost -delete Local/Default/Hosts/sample.com

At some point we'll see if it remains gone following a reboot, but for now, the problem has been solved!

share|improve this answer
add comment

You may also try to flush the routing tables!

# cf. http://ola-bini.blogspot.com/2008/05/faulty-routes-on-macos-x.html
sudo route flush

To delete a specific route use:

sudo route delete <ipnum> 127.0.0.1

To get the default route use:

route -n get default
netstat -rnf inet  # ... and compare it with the Routing tables

As a last resort replace the contents of your current /etc/hosts file with its original contents below and reboot your computer.

# original /etc/hosts on Mac OS X 10.6
##
# 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
share|improve this answer
add comment

Execute the following in the terminal: route delete sample.com

share|improve this answer
    
That errs: route: writing to routing socket: No such process delete host sample.com: not in table –  user40853 Apr 17 '10 at 21:25
add comment

As mentioned in the useful post you found, OS X now reads /etc/hosts like every other OS out there, so there's no need to invoke the Cthulhoid horror of NetInfo any more.

share|improve this answer
    
Right! And although it's a bit cloudy, I'm pretty sure that it was during the OSX 10.4 days that I was forced to use NetInfo to get the entry in there. Cthulhoid, indeed :) –  user40853 Apr 17 '10 at 23:14
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.