Ubuntu16.04下設置靜態IP

vi /etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto ens160    #設置自動啟動ens160接口
#iface ens160 inet dhcp  

iface ens160 inet static   #配置靜態IP
address 10.1.18.200  #IP地址
netmask 255.255.255.0  #子網掩碼
gateway 10.1.18.254    #默認網關
dns-nameserver 210.32.32.10

dns-nameserver 210.32.32.10 這句一定需要有,
因為以前是DHCP解析,所以會自動分配DNS 服務器地址。
而一旦設置為靜態IP后就沒有自動獲取到DNS服務器了

設置完重啟電腦

/etc/resolv.conf 文件中會自動添加

nameserver 210.32.32.10

(或者nameserver 8.8.8.8)可以根據訪問速度,選擇合適的公共DNS

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容