10

According to: https://wiki.ubuntu.com/Netplan

I can disable netplan by: "preseeding netcfg/do_not_use_netplan=true (adding it the the command-line when you boot the Ubuntu Server installation media"

I'm assuming this is done via /etc/default/grub but where exactly do I add "netcfg/do_not_use_netplan=true"?

Is it added to: GRUB_CMDLINE_LINUX

I currently have this set to:

GRUB_CMDLINE_LINUX="ipv6.disable=1"

What would be the syntax to add in "netcfg/do_not_use_netplan=true" to this existing setting?

P.S. YES, I want to remove netplan, so the question is specifically about how to do that, not why.

1
  • I did a simpler and verified procedure without reboots and crossed fingers. Please, check it.
    – EnzoR
    May 17, 2018 at 8:00

5 Answers 5

13

These directions have been tested also to Ubuntu 18.04.1 and will very likely work also for any future release using netplan and systemd.

There's no need at all to fiddle with GRUB nor any manual file removal. The configuration set up in /etc/networking files and directories will survive reboots.

These are the verified steps:

  1. Check the actual interface names you are interested in with ip l for the links (aka interfaces) and with ip a for addresses.
  2. Install ifupdown with sudo apt -y install ifupdown.
  3. Purge netplan with sudo apt -y purge netplan.io.
  4. Configure /etc/network/interfaces and/or /etc/network/interfaces.d accordingly to your needs (man 5 interfaces can be of some help with examples).
  5. Restart the networking service with sudo systemctl restart networking; systemctl status networking or sudo /etc/init.d/networking restart; /etc/init.d/networking status. The output of the status command should mention active as its status.
  6. The command ip a will show whether the expected network configuration has been applied.
  7. Optionally, manually purge the remants of the netplan configuration files with sudo rm -vfr /usr/share/netplan /etc/netplan.

No reboot is needed in order to "refresh" the IP configuration: it will be active as of step no.5 . In case of troubles, double check the interface names. A typical IPv4 DHCP configuration will resemble this one:

auto enp0s3
iface enp0s3 inet dhcp

while a static IPv4 address can be configured like this:

auto enp0s3
iface enp0s3 inet static
address 192.168.255.42/24
gateway 192.168.255.254
#dns-nameservers 8.8.8.8 208.67.222.222

Beware, the dns-nameservers entry won't work (thanks @Velkan for pointing it out!): the resolver is still using /etc/resolv.conf and systemd is providing his own resolution service from 127.0.0.53. So you can manually update it (no networking restart needed!):

nameserver 8.8.8.8
nameserver 208.67.222.222

But his would be only a temporary solution to vanish after the next reboot.

To get a permanent solution you need to edit /etc/systemd/resolved.conf and add a line like this one to the "[Resolve]" stanza:

DNS=8.8.8.8 208.67.222.222

Please, refer to man 5 resolved.conf for the full documentation.

Finally, in the unlikely case any network service is not responding as expected, then that services may need a restart. But that's a weird non-standard network daemon behavior.

12
  • Did this survive a reboot? A similar procedure worked for me but upon reboot I find that netplan has taken over again Jul 18, 2018 at 14:50
  • Yes, indeed! I will re-check everything, though.
    – EnzoR
    Jul 19, 2018 at 9:53
  • 2
    It works after reboot.
    – EnzoR
    Aug 22, 2018 at 15:53
  • Step 7 is a bit wrong. Some remaining files (as you call them) could have been installed by other packages than netplan. Removing them is totally useless and could lead to issues if in future, you want to switch back to netplan. Sep 12, 2018 at 14:24
  • It isn't wrong. Stuff installed under /usr/share/netplan and /etc/netplan belong to netplan as well as those directories themselves. Unless you have evidence for something else.
    – EnzoR
    Sep 12, 2018 at 15:19
7

The exact method to do this is hard, perhaps impossible to locate now in the early days of netplan.

I currently have this set to:

GRUB_CMDLINE_LINUX="ipv6.disable=1"

I assume that you mean that your /etc/default/grub reads, in part:

# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

GRUB_DEFAULT=0
GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX="ipv6.disable=1"
<snip>

I also assume that the link you give suggests that you add the referenced wording:

# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

GRUB_DEFAULT=0
GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX="ipv6.disable=1 netcfg/do_not_use_netplan=true"
<snip>

I suggest that you do just that, followed by:

sudo update-grub

You will also need:

sudo apt install ifupdown

It may already be installed.

Finally, fill in /etc/network/interfaces manually to configure your network the way you want it.

The exact process to do this post-installation, as far as Google and I can find, doesn't exist. Reboot with your fingers crossed!

1
  • 1
    Answer from @chili555 was not enough for me. I had to remove every yaml file from netplan directories ( {/run , /lib, /etc }/netplan/*.yaml ). Then, reboot and the network should works back with /etc/network/interfaces (guess this is a normal fallback).
    – remyd1
    Jan 19, 2018 at 11:00
2

Had this issue on Ubuntu 18.10 Server 64-bits (running on Virtual Box) and the following steps allowed to remove netplan and install Network Manager - not sure if they work for ifupdown. These steps are adapted from @Uqbar's answer (thank you).

  1. Check the actual interface names you are interested in with ip l for the links (aka interfaces) and with ip a for addresses.
  2. Install Network Manager with sudo apt -y install network-manager.
  3. Purge netplan with sudo apt -y purge netplan.io.
  4. Optionally, manually purge the remnants of netplan's configuration files with sudo rm -vfr /usr/share/netplan /etc/netplan.
  5. Configure /etc/network/interfaces accordingly to your needs (man 5 interfaces can be of some help with examples). Mine is configured as follows:

    auto lo
    iface lo inet loopback
    
    auto enp0s3
    allow-hotplug enp0s3
    iface enp0s3 inet dhcp
    
  6. On file /etc/NetworkManager/NetworkManager.conf, modify the line managed=false to managed=true. This will make Network Manager manage the interfaces configured in /etc/network/interfaces.

  7. Restart the Network Manager service with sudo service network-manager restart. The output of the status command should mention active as its status.
  8. The command nmcli dev will show whether the expected network configuration has been applied. Initially interface enp0s3 (my virtual ethernet) was appearing as unmanaged. After rebooting the machine, it appeared as connected. An example output of nmcli follows:

    DEVICE           TYPE      STATE         CONNECTION
    enp0s3           ethernet  connected     Ifupdown (enp0s3)
    wlxc46e1f179799  wifi      disconnected  --
    lo               loopback  unmanaged     --
    

NOTE: I'm having some issues with processes hanging, as described here and here. I managed to change the vm.dirty_ratio and `vm.dirty_background_ratio to 10 and 5 respectively, from the defaults 20 and 10. For that, execute the following commands:

sudo sysctl -w vm.dirty_ratio=10
sudo sysctl -w vm.dirty_background_ratio=5

I'll update this answer reporting the results after running the VM for some time.

It's been a long time, but I think this problem never occurred again (can't verify as the VM is corrupted). Never really understood why; I'll leave the note here for future reference. See also my comment bellow.

3
  • How is the NOTE related to netplan etc? Seems to be a completely unrelated issue...
    – MappaM
    Aug 8, 2019 at 7:51
  • I can't remember the exact details, but, if I remember correctly, I was loosing connection via SSH with Ubuntu. The links above report some issues with network connection and suggest change the values of the mentioned parameters. Thus the note.
    – jmpcm
    Aug 12, 2019 at 11:17
  • Works for me. Especially take note of Step 6 above "modify the line managed=false to managed=true" which doesn't seem to be mentioned elsewhere. Also note that if you're using WiFi (e.g. a laptop) its configuration information is in the /etc/NetworkManager hierarchy and there are no Wlan entries in /etc/network/interfaces.
    – dave58
    May 15, 2020 at 15:39
2

Here is MY answer on how to DISABLE Netplan without uninstalling it (tested for Ubuntu 20.04.2 LTS Server and Desktop):

The solution is based on my own investigations. I do not know, if this is an official way to do it, though it is pretty much systemd like.

Netplan is executed during system boot by a systemd generator file netplan inisde /usr/lib/systemd/system-generators/. This is a symlink pointing to /usr/lib/netplan/generate. So you just have to remove it, to keep Netplan from beeing executed at boot:

DISABLE Netplan:

sudo rm /usr/lib/systemd/system-generators/netplan

Reboot your system and you will not have any configurations generated by Netplan available inside /run/... anymore.

Stop Netplan from running while system is up:

sudo chmod a-x /usr/sbin/netplan

ENABLE Netplan:

sudo ln -s /usr/lib/netplan/generate /usr/lib/systemd/system-generators/netplan

Reboot your system and Netplan will be executed during system boot and will generate back-end configurations inside /run/... again, if yaml-files are present in one of the Netplan configuration directories.

Make Netplan executable again, while system is running:

sudo chmod a+x /usr/sbin/netplan

This is all you need to do! There is no need for adding/removing netcfg/do_not_use_netplan=True to your /etc/default/grub in addition to the two commands above.

Background:

So far I could not find anything usefull that is done by netcfg/do_not_use_netplan=True. I don't and can't say that it might not do something, but I could not reproduce, that it would do something (I would expect it to do).

I can for sure say, that it does NOT stop Netplan from beeing executed at boot time. Without disabling Netplan like described above, add debug to your /etc/default/grub so that it looks like follows,

GRUB_CMDLINE_LINUX="netcfg/do_not_use_netplan=True debug"

to verify yourself.

After system boot execute

dmesg | grep netplan

and you will get something like the following:

[    0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-5.4.0-74-generic root=UUID=74a27c05-a0a8-4a7c-a757-5edda35a5933 ro debug netcfg/do_not_use_netplan=True debian-installer/language=de keyboard-configuration/layoutcode?=de
[    0.037275] Kernel command line: BOOT_IMAGE=/boot/vmlinuz-5.4.0-74-generic root=UUID=74a27c05-a0a8-4a7c-a757-5edda35a5933 ro debug netcfg/do_not_use_netplan=True debian-installer/language=de keyboard-configuration/layoutcode?=de
[    3.086458] systemd[346]: /usr/lib/systemd/system-generators/netplan succeeded.
[    3.397282] systemd[1]: unit_file_build_name_map: normal unit file: /run/systemd/system/netplan-ovs-cleanup.service

Like you can see, the command line is read correctly, but Netplan is still executed.

So I thought it because it reads "do_not_use_netplan" it would may still execute Netplan, but would not use the back-end configuration, once a valid configuration with ifupdown /etc/network/interfaces does exist.

But NO, even if ifupdown is installed and a valid configuration is placed inside /etc/network/interfaces Netplan does still generate back-end configurations and applies them and configurations from ifupdown are still ignored.

Only if I do disable Netplan like described at the beginning, the ifupdown configuration will be used and will start working like expected.

-1

As an addition to this answer, the approach does work (18.04.4 LTS) for a move back to ifup/down, and is much easier that some other proposals. I did reboot, but am not sure it was needed.

Steps:

ip a (to get the valid device names and IP addresses if required)

apt install ifupdown

vi /etc/network/interfaces # if you are doing this, you know what to put in

vi /etc/resolv.conf # if you are doing this, you know what to put in

apt purge netplan.io

init 6 # not sure if this was needed

Redundant files may still be present, but I have decided not to look for them

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.