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>
— CIDR of the private subnet;<mac_address>
— MAC address of the interface;<nameservers_addresses>
— DNS servers. DNS Selectel:188.93.16.19
,188.93.17.19
;<destination_subnet>
is the CIDR of the destination subnet, for example0.0.0.0.0/0
;<gateway>
— IP address of the private subnet gateway, can be viewed in control panel under Cloud Platform → Servers → server page → Ports tab.
network:
version: 2
ethernets:
eth0:
dhcp4: true
match:
macaddress: <mac_address>
mtu: 1500
set-name: eth0
eth1:
addresses:
- <ip_address>/29
match:
macaddress: <mac_address>
mtu: 1500
nameservers:
addresses: <nameservers_addresses>
routes:
- to: <destinantion_subnet>
via: <gateway>
set-name: eth1Specify:
<mac_address>
— MAC address of the interface;<ip_address>
— IP address of subnet /29;<nameservers_addresses>
— DNS servers. DNS Selectel:188.93.16.19
,188.93.17.19
;<destination_subnet>
is the CIDR of the destination subnet, for example0.0.0.0.0/0
;<gateway>
— IP address of the gateway.
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: eth0
eth1:
addresses:
- <ip_address>/29
match:
macaddress: <mac_address>
mtu: 1500
nameservers:
addresses: <nameservers_addresses>
routes:
- to: <destination_subnet>
via: <gateway>
set-name: eth1Specify:
<private_subnet>
— CIDR of the private subnet;<mac_address>
— MAC address of the interface;<nameservers_addresses>
— DNS servers. DNS Selectel:188.93.16.19
,188.93.17.19
;<destination_subnet>
is the CIDR of the destination subnet, for example0.0.0.0.0/0
;<gateway>
— IP address of the gateway;<ip_address>
— IP address of subnet /29.
-
Check the syntax:
sudo netplan try
-
Apply the settings:
sudo netplan apply