找到文件并作如下修改
sudo vim /etc/network/interfaces
# The primary network interface
auto eno1
iface eno1 inet static
address 192.168.1.111
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 202.101.172.35 202.101.172.46
修改dns解析
因?yàn)橐郧笆莇hcp解析,所以會(huì)自動(dòng)分配dns服務(wù)器地址
而一旦設(shè)置為靜態(tài)ip后就沒有自動(dòng)獲取到的dns服務(wù)器了
要自己設(shè)置一個(gè)
sudo vim /etc/resolv.conf
寫上一個(gè)公網(wǎng)的DNS,以下為浙江杭州電信DNS
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 202.101.172.35
nameserver 202.101.172.46
(注意:8.8.8.8是谷歌的DNS服務(wù)器,但是解析速度慢,還是找到一個(gè)國(guó)內(nèi)的dns來用)
重啟網(wǎng)卡
sudo /etc/init.d/networking restart