如题所述
先用 ifconfig 查看本机IP地址
如果已经正确获取到,就可以获得类似下面的结果:
eth0 Link encap:Ethernet HWaddr 00:1F:33:2A:A4:90
inet addr:192.168.0.10 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::21e:37ee:fa2b:f49e/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:169286 errors:0 dropped:0 overruns:0 frame:0
TX packets:56061 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:19461385 (18.5 MiB) TX bytes:32717062 (31.2 MiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:132732 errors:0 dropped:0 overruns:0 frame:0
TX packets:132732 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:87897011 (83.8 MiB) TX bytes:87897011 (83.8 MiB)
如果未获取到地址,eth0这里不会出现 inet addr。
为测试网络功能是否正常,可以尝试 ping 127.0.0.1或者ping localhost
最后,可以用 service network restart 来重启一下网络服务,尝试重新获取IP。
如果已经正确获取到,就可以获得类似下面的结果:
eth0 Link encap:Ethernet HWaddr 00:1F:33:2A:A4:90
inet addr:192.168.0.10 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::21e:37ee:fa2b:f49e/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:169286 errors:0 dropped:0 overruns:0 frame:0
TX packets:56061 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:19461385 (18.5 MiB) TX bytes:32717062 (31.2 MiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:132732 errors:0 dropped:0 overruns:0 frame:0
TX packets:132732 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:87897011 (83.8 MiB) TX bytes:87897011 (83.8 MiB)
如果未获取到地址,eth0这里不会出现 inet addr。
为测试网络功能是否正常,可以尝试 ping 127.0.0.1或者ping localhost
最后,可以用 service network restart 来重启一下网络服务,尝试重新获取IP。
温馨提示:答案为网友推荐,仅供参考