配置网络,主要涉及到etc下的文件。
resolv.conf是nameserver,就是DNS。
network下的interfaces是配置eth0的信息的。还有lo的信息。
ifconfig eth0 up /down的命令,不能重新启动网络。
init.d下的network 命令,可以启动网络。
network restart命令就行。
root@ubuntu:/etc/init.d# ./networking restart
* Reconfiguring network interfaces... RTNETLINK answers: No such processSIOCDELRT: No such process
[ OK ]
root@ubuntu:/etc/init.d# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0c:29:da:ff:a7
inet addr:192.168.1.20 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:feda:ffa7/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1727 errors:0 dropped:0 overruns:0 frame:0
TX packets:116 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:162017 (162.0 KB) TX bytes:5681 (5.6 KB)
Interrupt:19 Base address:0x2024
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:5198 errors:0 dropped:0 overruns:0 frame:0
TX packets:5198 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:399506 (399.5 KB) TX bytes:399506 (399.5 KB)
root@ubuntu:/etc/init.d#
root@ubuntu:/etc/init.d# ping www.163.com
PING 163.xdwscache.glb0.lxdns.com (60.210.18.169) 56(84) bytes of data.
64 bytes from 60.210.18.169: icmp_seq=1 ttl=58 time=9.74 ms
64 bytes from 60.210.18.169: icmp_seq=2 ttl=58 time=9.42 ms
64 bytes from 60.210.18.169: icmp_seq=3 ttl=58 time=9.89 ms
64 bytes from 60.210.18.169: icmp_seq=4 ttl=58 time=9.88 ms
64 bytes from 60.210.18.169: icmp_seq=5 ttl=58 time=9.51 ms
64 bytes from 60.210.18.169: icmp_seq=6 ttl=58 time=9.36 ms
64 bytes from 60.210.18.169: icmp_seq=7 ttl=58 time=9.77 ms
64 bytes from 60.210.18.169: icmp_seq=8 ttl=58 time=9.44 ms
64 bytes from 60.210.18.169: icmp_seq=9 ttl=58 time=10.0 ms