Skip to content

Instantly share code, notes, and snippets.

@mss
Last active March 17, 2024 12:39
Show Gist options
  • Star 22 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save mss/7a8e048dd51e5ef928039f1450ba8f31 to your computer and use it in GitHub Desktop.
Save mss/7a8e048dd51e5ef928039f1450ba8f31 to your computer and use it in GitHub Desktop.
Migrate from ifupdown to netplan
# Tested on an upgraded Ubuntu 20.04
apt install netplan.io
systemctl unmask systemd-networkd.service
systemctl unmask systemd-resolved.service
ENABLE_TEST_COMMANDS=1 netplan migrate
netplan try
reboot
apt purge ifupdown resolvconf
ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
@slippers
Copy link

thanks

@mss
Copy link
Author

mss commented Feb 17, 2022

@slippers you're welcome. IIRC the (missing) last step was the one which originally broke my neck.

@iat963
Copy link

iat963 commented Jun 28, 2023

Thanks! I am migrating all my Ubuntu systems to this nice combination. Please note that removing resolvconf created the symbolic link /etc/resolv.conf as desired:

% ls -al /etc/resolv.conf
lrwxrwxrwx 1 root root 29 Sep 29  2017 /etc/resolv.conf -> ../run/resolvconf/resolv.conf
% sudo apt remove resolvconf
...
resolvconf.postrm: Reboot recommended
...
% ls -al /etc/resolv.conf
lrwxrwxrwx 1 root root 39 Jun 28 17:23 /etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf
%

@enoch85
Copy link

enoch85 commented Aug 18, 2023

Never got ENABLE_TEST_COMMANDS=1 netplan migrate to work.

From the documentation it says netplan ifupdown-migrate.

EDIT: That didn't work either.

EDIT2: It needs to be Ubuntu 20.04 for it to work. 22.04 doesn't work from my testing.

@rob4226
Copy link

rob4226 commented Nov 25, 2023

Thank you, this helped a lot! I never would have remembered to do that last symlink!

It's really strange but I could not find any official documentation for the netplan migrate command. It used a couple of depreciated things like gateway4 but overall it worked really well!

A couple of things I discovered it does:

  • Uses /etc/network/interfaces to generate a netplan config file named /etc/netplan/10-ifupdown.yaml
  • Renames /etc/network/interfaces to /etc/network/interfaces.netplan-converted

Note sure if it does anything else, those are just the things I noticed.

@fluidum
Copy link

fluidum commented Feb 23, 2024

Thanks for the author!

On Debian 12 I got couple of issues when I ran netplan try. I'll share my solutions:

  1. "Cannot call Open vSwitch: ovsdb-server.service is not running."

apt-get install openvswitch-switch
https://bugs.launchpad.net/ubuntu/+source/netplan.io/+bug/2041727

  1. "gateway4 has been deprecated, use default routes instead."

replaced:

      gateway4: 192.168.10.1

with:

     routes:
      - to: default
        via: 192.168.10.1

https://unix.stackexchange.com/a/681221

  1. My /etc/resolv.conf was emptied by NetworkManager somehow when turning WiFi off, so my eth0 wasn't resolving hostnames.

apt install systemd-resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment