|
机器连接到路由器(192.168.0.1)。
root:~> ping localhost
PING localhost.zhouslab.com (221.174.16.35) 56(84) bytes of data.
64 bytes from 221.174.16.35: icmp_seq=1 ttl=56 time=46.5 ms
64 bytes from 221.174.16.35: icmp_seq=2 ttl=56 time=209 ms
64 bytes from 221.174.16.35: icmp_seq=3 ttl=56 time=46.5 ms
64 bytes from 221.174.16.35: icmp_seq=4 ttl=56 time=46.9 ms
如果将 /etc/resolv.conf 中 nameserver 192.168.0.1 注释掉
root:~> ping localhost
PING localhost.zhouslab.com (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.018 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.025 ms
可是将 nmaserver 注释掉 就不能上网了,怎么办才能上网,同时 ping localhost ping 的是 127.0.0.1 呢?
root:~> ifconfig
eth0 Link encap:Ethernet HWaddr 00:0F:B0:F6:03:4F
inet addr:192.168.0.31 Bcast:192.168.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1412 errors:0 dropped:0 overruns:0 frame:0
TX packets:1468 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1243509 (1.1 MiB) TX bytes:234670 (229.1 KiB)
Interrupt:11
lo Link encap ocal Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:103 errors:0 dropped:0 overruns:0 frame:0
TX packets:103 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:8500 (8.3 KiB) TX bytes:8500 (8.3 KiB)
root:~> route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
0.0.0.0 192.168.0.1 0.0.0.0 UG 1 0 0 eth0
root:~> cat /etc/resolv.conf
domain zhouslab.com
search zhouslab.com
nameserver 192.168.0.1
root:~> cat /etc/hosts
#
# hosts This file describes a number of hostname-to-address
# mappings for the TCP/IP subsystem. It is mostly
# used at boot time, when no name servers are running.
# On small systems, this file can be used instead of a
# "named" name server. Just add the names, addresses
# and any aliases to this file...
#
# By the way, Arnt Gulbrandsen <agulbra@nvg.unit.no> says that 127.0.0.1
# should NEVER be named with the name of the machine. It causes problems
# for some (stupid) programs, irc and reputedly talk. :^)
#
# For loopbacking.
127.0.0.1 localhost
192.168.0.31 sxzzsf.zhouslab.com sxzzsf
# End of hosts.
BTW: 我用的是slackware linux 2.6.21.5 |
|