使用場景
- 在公司有固定網段
- 服務器指定IP
第一種 設置方式
第一步進入配置文件
sudo vim /etc/network/interfaces
第二步修改內容如下,如果存在則進行更改否則添加
注:我安裝的最新的Ubuntu16.04-server版,與14.0差別在eth0
上
auto enp0s3
iface enp0s3 inet static # 將網卡enp0s3設置為靜態IP
address 192.168.20.65 # IP地址
netmask 255.255.255.0 # 子網掩碼
network 192.168.20.0
broadcast 192.168.20.255
gateway 192.168.20.1 # 默認網關
dns-nameservers 8.8.8.8 # 谷歌DNS,可以自己設定
第三步重啟網絡服務
/etc/init.d/networking restart