Ubuntu設定靜態IP
阿新 • • 發佈:2020-08-06
Ubuntu 18.04 和 16.04 設定方式略有不同。
18.04 設定方式:
編輯/etc/netplan/static.yaml 檔案,檔名可以自定義。
sudo vim /etc/netplan/static.yaml
輸入下面的內容,注意將網絡卡名稱修改為自己的網絡卡
network: version: 2 ethernets: enp0s3: dhcp4: false addresses: [172.16.200.6/24] gateway4: 172.16.200.1 nameservers: addresses: [172.16.200.60, 172.16.200.61]
儲存,重啟網路服務
sudo netplan apply
16.04 設定方式:
編輯 /etc/network/interfaces 檔案
sudo vim /etc/network/interfaces
輸入下面的內容,注意將網絡卡名稱修改為自己的網絡卡
auto lo
iface lo inet loopback
# The primary network interface
auto enp0s3
iface enp0s3 inet static
address 172.16.200.6
netmask 255.255.255.0
gateway 172.16.200.1
dns-nameserver 172.16.200.60
儲存,重啟網路服務
sudo /etc/init.d/networking restart