先查看網(wǎng)絡(luò)接口配置信息
ifconfig
注意:這里的網(wǎng)絡(luò)接口為eth0,如果是其他接口名字如eth1,以下注釋就為eth1的
vim /etc/network/interfaces
把iface eth0 inet dhcp 注釋掉(在前面添加#)
#iface eth0 inet dhcp //更改以后
添加
注意:一定要把含有dhcp的代碼行注釋掉
iface eth0 inet static
address 10.10.10.128 //ip根據(jù)橋接模式或NAT模式進(jìn)行更改
netmask 255.255.255.0 //子網(wǎng)掩碼
gateway 10.10.10.2 //網(wǎng)關(guān)
修改DNS配置文件,刪除已有內(nèi)容
nameserver 8.8.8.8 //google的DNS
nameserver 8.8.4.4
重啟網(wǎng)絡(luò)
/etc/init.d/networking restart
查看DNS
cat /etc/resolv.conf
注意:執(zhí)行apt-get upgrade后IP沒(méi)變,DNS變化了,原因不明!處理方法不知(網(wǎng)上方法基本都試過(guò)了),大神知道的話可以在評(píng)論指出
原文鏈接:https://www.idaobin.com/archives/176.html