Ubuntu安装后需要配置网络环境才能上网。
1.在命令行下修改网卡配置文件
sudo vi /etc/network/interfaces
#静态设置IP地址
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.0.178
netmask 255.255.255.0
gateway 192.168.0.1
#自动获得IP地址
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp2.设置DNS
sudo vi /etc/resolv.conf
#加入nameserver 114.114.114.1143.启动网卡
sudo /etc/init.d/networking restart4.检查下网卡配置信息
ifconfig
eth0 Link encap:Ethernet HWaddr 00:16:76:3E:D3:5F
inet addr:192.168.0.178 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::216:76ff:fe3e:d35f/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:200398 errors:0 dropped:0 overruns:0 frame:0
TX packets:187200 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:235438130 (224.5 MiB) TX bytes:13786104 (13.1 MiB)5.最后使用ping命令查看能否联网
ping -c