1. 程式人生 > 實用技巧 >Ubuntu 18.04配置靜態IP

Ubuntu 18.04配置靜態IP

1、檢視當前的網絡卡資訊

ifconfig

可以看出是雙網絡卡,一個eth0(大網),一個eth1(小網)

2、修改(以修改小網ip eth1[192.169.3.13]為例)

①檔案位置/etc/netplan/01-netcfg.yaml

檔名可能有所不同,但是資料夾應該是相同的 /etc/netplan

②修改eth1

vi /etc/netplan/01-netcfg.yaml

# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network: version: 2 renderer: networkd ethernets: eth0: dhcp4: yes gateway4: 10.191.4.1 routes: - to: 10.190.0.0/16 via: 10.191.4.1 metric: 10 eth1: dhcp4: no addresses: - 192.169.3.6/24 gateway4: 192.169.3.1

備註:添加了eth0的閘道器和路由,因為當時實驗不新增,導致遠端的ssh斷了,如果在本機呢,就可以不用新增,直接這樣

③應用

netplan apply

④驗證

netplan apply後大網自動獲取到IP:10.191.6.35,小網為剛才填寫的192.169.3.4