Netplan: Difference between revisions
Jump to navigation
Jump to search
(→config) |
(→dhcp) |
||
| (3 intermediate revisions by the same user not shown) | |||
| Line 14: | Line 14: | ||
sudo netplan apply | sudo netplan apply | ||
Debug plan: | |||
sudo netplan --debug apply | sudo netplan --debug apply | ||
# note "apply --debug" does not work | # note "apply --debug" does not work | ||
| Line 30: | Line 31: | ||
- | - | ||
Ubuntu to regen machine-id | Ubuntu to regen machine-id <ref>https://unix.stackexchange.com/questions/402999/is-it-ok-to-change-etc-machine-id</ref> | ||
rm -f /etc/machine-id /var/lib/dbus/machine-id | rm -f /etc/machine-id /var/lib/dbus/machine-id | ||
# dbus-uuidgen --ensure=/etc/machine-id | # dbus-uuidgen --ensure=/etc/machine-id | ||
dbus-uuidgen --ensure | dbus-uuidgen --ensure | ||
cp /var/lib/dbus/machine-id /etc/machine-id | #cp /var/lib/dbus/machine-id /etc/machine-id | ||
systemd-machine-id-setup | |||
# verify: | |||
cat /etc/machine-id /var/lib/dbus/machine-id | cat /etc/machine-id /var/lib/dbus/machine-id | ||
hostnamectl | |||
== examples == | == examples == | ||
| Line 73: | Line 77: | ||
ref: https://github.com/canonical/netplan/blob/main/examples/dhcp.yaml | ref: https://github.com/canonical/netplan/blob/main/examples/dhcp.yaml | ||
== vlan == | |||
<pre> | |||
network: | |||
version: 2 | |||
ethernets: | |||
eno1: | |||
... eno1 config ... | |||
vlans: | |||
vlan100: | |||
id: 100 | |||
link: eno1 | |||
addresses: [10.0.0.100/24] | |||
# dhcp4: true | |||
</pre> | |||
== Renderer == | |||
Warning: If both systemd-networkd and NetworkManager are active on the same interface, conflicts may occur. The renderer setting ensures control is delegated correctly. | |||
=== networkd === | |||
<pre> | |||
network: | |||
version: 2 | |||
renderer: networkd | |||
</pre> | |||
=== NetworkManager === | |||
This system is being managed by NetworkManager. | |||
Default: | |||
<pre> | |||
# Let NetworkManager manage all devices on this system | |||
network: | |||
version: 2 | |||
renderer: NetworkManager | |||
</pre> | |||
More: | |||
<pre> | |||
# Let NetworkManager manage all devices on this system | |||
network: | |||
version: 2 | |||
renderer: NetworkManager | |||
ethernets: | |||
enp3s0: | |||
dhcp4: true | |||
</pre> | |||
Apply configuration: | |||
sudo netplan apply | |||
Verify backend: | |||
nmcli device status | |||
Warning: If both systemd-networkd and NetworkManager are active on the same interface, conflicts may occur. The renderer setting ensures control is delegated correctly. | |||
== keywords == | |||
Latest revision as of 18:09, 15 April 2026
config
# /etc/netplan/01-netcfg.yaml
network:
ethernets:
ens18:
dhcp4: true
version: 2
-
sudo netplan apply
Debug plan:
sudo netplan --debug apply # note "apply --debug" does not work
-
# networkctl IDX LINK TYPE OPERATIONAL SETUP 1 lo loopback carrier unmanaged 2 ens18 ether routable configured 2 links listed.
-
Ubuntu to regen machine-id [1]
rm -f /etc/machine-id /var/lib/dbus/machine-id # dbus-uuidgen --ensure=/etc/machine-id dbus-uuidgen --ensure #cp /var/lib/dbus/machine-id /etc/machine-id systemd-machine-id-setup # verify: cat /etc/machine-id /var/lib/dbus/machine-id hostnamectl
examples
https://github.com/canonical/netplan/tree/main/examples
static
network:
version: 2
renderer: networkd
ethernets:
enp3s0:
addresses:
- 10.10.10.2/24
nameservers:
search: [mydomain, otherdomain]
addresses: [10.10.10.1, 1.1.1.1]
routes:
- to: default
via: 10.10.10.1
ref: https://github.com/canonical/netplan/blob/main/examples/static.yaml
dhcp
network:
version: 2
renderer: networkd
ethernets:
enp3s0:
dhcp4: true
ref: https://github.com/canonical/netplan/blob/main/examples/dhcp.yaml
vlan
network:
version: 2
ethernets:
eno1:
... eno1 config ...
vlans:
vlan100:
id: 100
link: eno1
addresses: [10.0.0.100/24]
# dhcp4: true
Renderer
Warning: If both systemd-networkd and NetworkManager are active on the same interface, conflicts may occur. The renderer setting ensures control is delegated correctly.
networkd
network: version: 2 renderer: networkd
NetworkManager
This system is being managed by NetworkManager.
Default:
# Let NetworkManager manage all devices on this system network: version: 2 renderer: NetworkManager
More:
# Let NetworkManager manage all devices on this system
network:
version: 2
renderer: NetworkManager
ethernets:
enp3s0:
dhcp4: true
Apply configuration:
sudo netplan apply
Verify backend:
nmcli device status
Warning: If both systemd-networkd and NetworkManager are active on the same interface, conflicts may occur. The renderer setting ensures control is delegated correctly.