如何删除OS X 10.5中的路由

我以某种方式configuration我的Mac路由到一个特定的IP名称(sample.com)的所有请求到回环地址(127.0.0.1)。 现在我试图删除这个,但不能确定在哪里做到这一点。

  1. / etc / hosts下没有它的条目。
  2. 路由表显示它正在将IP名称映射到Mac的IP地址。

路由表输出如下:

 互联网:

目标网关标志参考使用Netif过期
默认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链接#4 UCS 0 0 en0
 192.168.2链路#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链路#4 UHLWb 4 84777 en0

任何帮助将不胜感激!

更新:注意 – 我可以删除到192.168.2.15地址的路由 – 只是不是回环。 我猜测它需要去其他地方…

所以关键似乎是这是一个主机别名。

  1. 我find了一个有用的post

  2. 我检查了主机的caching

    sudo dscacheutil -cachedump -entries主机

  3. 我发现在/ Local / Default下面列出了主机别名

  4. 我检查了目录服务:

    sudo dscl localhost -list本地/默认/主机

  5. 果然,那是!

  6. 我删了它:

    sudo dscl localhost -delete本地/默认/主机/ sample.com

在某个时候,我们会看到重启后它是否仍然消失,但现在,问题已经解决了!

您也可以尝试刷新路由表!

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

要删除特定的路线,请使用:

 sudo route delete <ipnum> 127.0.0.1 

要获取默认路由,请使用:

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

作为最后的手段,用下面的原始内容replace当前/etc/hosts文件的内容,然后重新启动计算机。

 # 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 

在terminal执行以下命令: route delete sample.com

正如在你find的有用的文章中提到的,OS X现在像所有其他操作系统一样读取/etc/hosts ,所以不需要再调用NetInfo的Cthulhoid恐怖。