最後更新: 2023-01-16
前言
它是個 Network configuration utility
使用 yaml 格式去設置 Backend (networkd / NetworkManager)
目錄
- 安裝
- Useful Configure Options
- Get Status
- Configure Summary
安裝
apt-get install netplan.io
Backend
- networkd
- NetworkManager
ie.
network: version: 2 renderer: networkd ...
Status
netplan status
Online state: offline DNS Addresses: 127.0.0.53 (stub) DNS Search: . ● 1: lo ethernet UNKNOWN/UP (unmanaged) MAC Address: 00:00:00:00:00:00 Addresses: 127.0.0.1/8 ::1/128 ● 4: eth0 ethernet UP (unmanaged) MAC Address: 00:16:3e:84:83:41 Addresses: fe80::216:3eff:fe84:8341/64 (link) Routes: fe80::/64 metric 256
# info Show available features
netplan info
netplan.io:
website: "https://netplan.io/"
features:
- dhcp-use-domains
- auth-phase2
- ipv6-mtu
- modems
- sriov
- openvswitch
- activation-mode
- eswitch-mode
- infiniband
- regdom
- vrf
- vxlan
- dbus-config
- generate-just-in-time # 開機時根據現有 DEVICEs 去建立設定檔
- generated-supplicant # generation of a supplicant configuration file for wireless
- default-routes # specifying the gateway and metric
try & apply
try: Try to apply a new netplan config to running system, with automatic rollback
Useful Configure Options
'optional: true'
declarations that allow booting to occur without waiting for those interfaces to activate fully.
Configure Summary
/etc/netplan/name.yaml
network: version: 2 ethernets: eth0: dhcp4: false addresses: [192.168.123.17/24] routes: - to: default via: 192.168.123.1 nameservers: addresses: [192.168.123.1, 8.8.8.8] search: [local]
# 多 IP
network:
version: 2
ethernets:
ens4:
addresses:
- 192.168.88.241/24
- 192.168.88.244/24
...
# Bridges
network:
version: 2
renderer: networkd
ethernets:
enp2s0:
dhcp4: no
bridges:
br0:
macaddress: 00:1a:3e:88:02:41
interfaces:
- enp2s0
parameters:
stp: false
forward-delay: 0
addresses: [192.168.123.10/24]
...
Notes
最好自定 MAC address, 否則 clone 出來的 instance 可能會撞 MAC address
- 00:1a:3e <- 沒公司佔用
- 88 <- 所在 IP network
- 02:241 <- 它的 IP 尾數
在 Bridges 情況下 "netplan try" 無效, 只能 "netplan apply" 之後等 rollback