?ifupdown 一直是 Debian/Ubuntu 系列經(jīng)典的網(wǎng)絡配置程序。不過,在 Ubuntu 18.04 LTS 版之后,這一配置程序被一個叫做 netplan 的配置程序替代了。
過去
配置路徑
1 nano /etc/network/interfaces
DHCP 動態(tài)獲取 IP
2 iface eth0 inet dhcp
靜態(tài) IP 地址
1 auto eth0
2 iface eth0 inet static
3 address 192.168.1.101
4 netmask 255.255.255.0
5 gateway 192.168.1.1
6 dns-nameservers 8.8.8.8 114.114.114.114
現(xiàn)在
準備
1 ifupdown has been replaced by netplan(5) on this system. ?See
2 /etc/netplan for current configuration.
3 To re-enable ifupdown on this system, you can run:
4 sudo apt install ifupdown
01-netcfg.yaml
50-cloud-init.yaml
99_config.yaml
DHCP 動態(tài)獲取 IP
1 network:
2 version: 2
3 renderer: networkd
4 ethernets:
5 eth0:
6 dhcp4: yes
2 ifconfig |grep -B1 inet
1 network:
2 version: 2
3 renderer: networkd
4 ethernets:
5 eth0:
6 addresses: [192.168.88.100/24]
7 gateway4: 192.168.88.2
8 nameservers:
9 addresses: [192.168.88.2, 114.114.114.114
總結
yaml 配置,一定要按照格式規(guī)范進行配置,空格和分隔符都一定要注意,不然引起錯誤很難發(fā)現(xiàn)。技術在更新,如果遇到了一些平時正常步驟都出現(xiàn)問題的情況,也許要考慮下是不是有新的技術被使用,新的程序替代了老舊的程序。