(1)su root
切换到root账号。
(2)查看ip、网卡等信息
执行ifconfig
我的ubuntu是装在虚拟机的,可以看到执行ifconfig后,第一行那里网卡设备是eno16777736
(3)查看/etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
#The primary network interface
auto eno16777736
iface eno16777736 inet static
address 192.168.1.211
gateway 192.168.1.1
netmask 255.255.255.0
broadcast 192.168.1.255
添加好后保存。
(4)先把Network-Manager停掉
sudo /etc/init.d/network-manager stop
(5)重启网络生效
/etc/init.d/networking restart
(6)添加dns(永久生效)
sudovi/etc/resolvconf/resolv.conf.d/base(这个文件默认是空的)
在里面插入:
nameserver x.x.x.x
nameserver y.y.y.y
如果有多个DNS就一行一个
sudoresolvconf-u
原文链接:https://www.f2er.com/ubuntu/354907.html