sudo vi /etc/network/interfaces
# 一、配置网卡
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.3.222 #ubuntu ip 地址
netmask 255.255.255.0 #子网掩码
# network 192.168.3.0 #可不用配置
# broadcast 192.168.3.255 #可不用配置
gateway 192.168.3.1 #网关
# dns-* options are implemented by the resolvconf package, if installed
#dns-nameservers 8.8.8.8 # DNS,多个用半角空格隔开
# 二、配置DNS
$ sudo vi /etc/resolv.conf
search localdomain
nameserver 202.106.116.1
nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 208.67.220.220
nameserver 208.67.222.222
nameserver 202.102.192.68
# 三、重启网络
sudo /etc/init.d/networking restart #启动网卡,终端会断掉
sudo /etc/init.d/networking force-reload #强制加载,这个更好点,终端不会断掉