Ubuntu16.04 動(dòng)態(tài)靜態(tài)ip設(shè)置
1. 動(dòng)態(tài)ip設(shè)置(eth0是網(wǎng)卡名稱)
ip route show 獲取網(wǎng)卡名字
編輯文件
sudo vi /etc/network/interfaces
并用下面的行來(lái)替換有關(guān)eth0的行
auto eth0
iface eth0 inet dhcp (配置動(dòng)態(tài))
重啟網(wǎng)絡(luò)服務(wù)
/etc/init.d/networking restart
2. 靜態(tài)ip設(shè)置(eth0是網(wǎng)卡名稱)
vim /etc/network/interfaces
添加內(nèi)容
auto eth0 (eth0網(wǎng)卡名字)
iface eth0 inet static (配置靜態(tài))
address 192.168.1.100(ip地址)
netmask 255.255.255.0(網(wǎng)絡(luò)掩碼)
gateway 192.168.1.1 (網(wǎng)關(guān))
dns-nameserver 114.114.114.114 (dns服務(wù)器)
重啟網(wǎng)絡(luò)服務(wù)
/etc/init.d/networking restart