Netplan: Difference between revisions

From Omnia
Jump to navigation Jump to search
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
== config ==
== config ==


/etc/netplan/01-netcfg.yaml
<pre>
<pre>
# /etc/netplan/01-netcfg.yaml
network:
network:
   ethernets:
   ethernets:
Line 9: Line 9:
   version: 2
   version: 2
</pre>
</pre>
-


  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


networkctl
-
 
<pre>
<pre>
# networkctl
IDX LINK  TYPE    OPERATIONAL SETUP
IDX LINK  TYPE    OPERATIONAL SETUP
   1 lo    loopback carrier    unmanaged
   1 lo    loopback carrier    unmanaged
Line 23: Line 28:
2 links listed.
2 links listed.
</pre>
</pre>
-
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
# 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 ==
== examples ==

Latest revision as of 05:37, 8 August 2024

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