Netplan is a utility for configuring network devices using either NetworkManager or systemd-networkd.
To be able to use systemd-networkd directly, we will need to move the netplan files to another directory, so that they are not taken into consideration - we move them into a home directory of the user ubuntu -:
We also remove the files netplan creates on start up:
Then we can reboot the system so that it reboots without netplan handling the network configuration.
When we do an "ip addr", the network interface will have no IP address.
We could also check using the below command:
The networkctl utility shows that the interface "eno1" is "off".
We now create a file called "/etc/systemd/network/20-static-address.network". The systemd.networkd service will use the above file, since it is the only file that exists in that directory:
For the above file to be taken into account, we will use the below command to restart the service:
Now, we check the interface using the "ip addr" command.
In case we want our interface to use "dhcp", we create another file as we see below - called "/etc/systemd/network/10-dhcp-address.network"-:
Since the "dhcp" file starts with a lower number -10-, it will take precedence over the static one that starts with the number -20-.
Then we restart our service:
[Match] : represents the interface to which networkd applies its settings.
[Network] : represents the setting of the network applied to interfaces.
We could keep both files -dhcp and static- and use the configuration that suits our needs by changing the priority of the files - which is based on the number that the file's name starts with -