Switch network configuration from ifupdown to netplan
Switch network configuration from ifupdown to netplan
In cloud servers created from pre-built images of Ubuntu 18.04, 20.04, and 22.04, ifupdown is used by default to configure the network.
You can switch network configuration from ifupdown to netplan — the procedure depends on whether the cloud-init agent is installed in the image.
If cloud-init is set
-
Remove ifupdown and restart the server:
apt purge ifupdown && reboot now
-
The cloud-init agent will independently configure the network for netplan.
If cloud-init is not installed
-
Create a configuration file for netplan (
/etc/neplan/config.yaml
). If necessary, you can add routes in theroutes
block:- Public IP address with DHCP
- Public IP address without DHCP
- Private network and /29 with DHCP
- Private network and /29 without DHCP
network:
version: 2
ethernets:
eth0:
dhcp4: true
match:
macaddress: <mac_address>
mtu: 1500
set-name: eth0Specify
<mac_address>
— MAC address of the interface.network:
version: 2
ethernets:
eth0:
addresses:
- <private_subnet>
match:
macaddress: <mac_address>
mtu: 1500
nameservers:
addresses: <nameservers_addresses>
routes:
- to: <destination_subnet>
via: <gateway>
set-name: eth0Specify:
<private_subnet>