Static IP in Debian 9 Stretch
修改IP地址:
1.編輯文件
vim /etc/network/interfaces
1.1.設(shè)置靜態(tài)IP
auto lo
iface lo inet lookback
auto eth0
iface eth0 inet static #將網(wǎng)卡eth0設(shè)置為獲取靜態(tài)地址
address 192.168.1.10 #替換為自己的IP地址
netmask 255.255.255.0 #替換為自己的子網(wǎng)掩碼
gateway 192.168.1.1 #替換為自己的網(wǎng)關(guān)地址
1.2.設(shè)置為DHCP自動獲取IP
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp #將網(wǎng)卡eth0設(shè)置為自動獲取IP
2.重啟網(wǎng)卡服務(wù)
debian8
systemctl restart network
debian9
service networking restart
修改DNS
1.編輯文件
vim /etc/resolv.conf
2.添加DNS
nameserver 114.114.114.114 #替換為自己的DNS服務(wù)器地址
查詢IP及測試網(wǎng)絡(luò)連通
1.查詢IP
debian8
ifconfig
debian9
ip addr
2.測試網(wǎng)絡(luò)連通
ping www.baidu.com