输入命令1: sudo vi /etc/network/interfaces

#DHCP 自动获取ip配置
auto lo                                       # 开机自动激lo接口
iface lo inet loopback                        # 配置lo接口为环回口
auto eth0                                     #开机自动激活eth0接口
iface eth0 inet dhcp                          #配置eth0接口为DHCP自动获取

#静态分配IP地址配置
auto lo                                       # 开机自动激lo接口
iface lo inet loopback                        # 配置lo接口为环回口
auto eth0                                     #开机自动激活eth0接口
iface eth0 inet static                        #配置eth0接口为静态设置IP地址
address 192.168.1.10
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1

#DNS配置
sudo vi /etc/resolv.conf
nameserver 192.168.1.1

输入命令2:sudo /etc/init.d/networking restart    # 重启网络