Skip to content

Instantly share code, notes, and snippets.

@dbkinghorn
Created June 23, 2020 17:07
Show Gist options
  • Star 28 You must be signed in to star a gist
  • Fork 10 You must be signed in to fork a gist
  • Save dbkinghorn/ed923bbcb7ec3f53bd2da5fe5e9b49b2 to your computer and use it in GitHub Desktop.
Save dbkinghorn/ed923bbcb7ec3f53bd2da5fe5e9b49b2 to your computer and use it in GitHub Desktop.
Change Ubuntu 20.04 server netplan to use NetworkManager instead of networkd
#!/usr/bin/env bash
# netplan2NM.sh
# Ubuntu server 20.04 Change from netplan to NetworkManager for all interfaces
echo 'Changing netplan to NetowrkManager on all interfaces'
# backup existing yaml file
cd /etc/netplan
cp 01-netcfg.yaml 01-netcfg.yaml.BAK
# re-write the yaml file
cat << EOF > /etc/netplan/01-netcfg.yaml
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
version: 2
renderer: NetworkManager
EOF
# setup netplan for NM
netplan generate
netplan apply
# make sure NM is running
systemctl enable NetworkManager.service
systemctl restart NetworkManager.service
echo 'Done!'
@Minichaz
Copy link

This worked for me too on 20.04 though on running the script there was an error re 01-netcfg.yaml not being found. Thanks. 👍

@poltpolt
Copy link

poltpolt commented Feb 8, 2022

  • added correct yaml for Ubuntu Server 20.04.3
  • added installation of networkmanager

https://gist.github.com/poltpolt/772618cfead9c1b63b246584024d7765

@M00NL16H7
Copy link

M00NL16H7 commented Feb 22, 2023

for anyone who may need it, i wrote a updated version for 22.04!
https://github.com/M00NL16H7/randomScripts/blob/main/netplan2NM.sh

@DevDorrejo
Copy link

you need to add to install NetworkManager, by default is not installed

@dbkinghorn
Copy link
Author

Yes, that would be a reasonable addition. What I have is only for updating netplan. On Ubuntu Server NetworkManager is not installed by default but I believe it is for Desktop. (?)

You would probably want to add something like
sudo apt-get -y -qq install network-manager
sudo systemctl enable NetworkManager --now

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