26

Starting sometime around Ubuntu 18.04, the Ubuntu devs stopped using the classic /etc/init.d/networking and /etc/network/interfaces method of configuring the network and switched to some thing called netplan. This has made a lot of people very angry and been widely regarded as a bad move. Is it possible to remove netplan and use the correct /etc/network/interfaces method for configuring the network?

  • 2
    Why not just configure with netplan? In most situations, it is pretty straightforward. – chili555 May 3 '18 at 20:00
  • 2
    @chili555 It may be that I just have to accept the change and learn something new. I'd just like to know if it is trivial to revert back to the way it should be. Much like systemd, I understand that disruptive change can sometimes be beneficial and be embraced. However, this is certainly not one of those times when the change was needed or beneficial. – jdgregson May 3 '18 at 20:06
  • 1
    It is not trivial and not easily reversible in case of error. If you'd like to live dangerously, I'll be happy to propose an answer. On the other hand, we can configure netplan in a couple of minutes. Which do you prefer? PS- I don't pretend to fully understand how netplan, to the exclusion of /etc/network/interfaces, fits in to the larger systemd picture. All I can do is trust that those who introduced the change do know why it's a better fit. – chili555 May 3 '18 at 20:25
  • @chili555 This question is more or less academic, and certainly not something I would recommend anyone do in production. But it may serve to encourage offended users such as myself to begrudgingly accept that netplan is the correct way to configure networking in Ubuntu now, so by all means, suggest anything that comes to mind if you feel like exploring the question. – jdgregson May 3 '18 at 20:54
  • 1
    Or, just properly configure netplan and be done. – chili555 May 3 '18 at 21:06
28

The following procedure works for Ubuntu 18.04 (Bionic Beaver)

I. Reinstall the ifupdown package:

# apt-get update
# apt-get install ifupdown

II. Configure your /etc/network/interfaces file with configuration stanzas such as:

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

allow-hotplug enp0s3
auto enp0s3
iface enp0s3 inet static
  address 192.168.1.133
  netmask 255.255.255.0
  broadcast 192.168.1.255
  gateway 192.168.1.1
  # Only relevant if you make use of RESOLVCONF(8)
  # or similar...
  dns-nameservers 1.1.1.1 1.0.0.1

III. Make the configuration effective (no reboot needed):

# ifdown --force enp0s3 lo && ifup -a
# systemctl unmask networking
# systemctl enable networking
# systemctl restart networking

IV. Disable and remove the unwanted services:

# systemctl stop systemd-networkd.socket systemd-networkd \
networkd-dispatcher systemd-networkd-wait-online
# systemctl disable systemd-networkd.socket systemd-networkd \
networkd-dispatcher systemd-networkd-wait-online
# systemctl mask systemd-networkd.socket systemd-networkd \
networkd-dispatcher systemd-networkd-wait-online
# apt-get --assume-yes purge nplan netplan.io

Then, you're done.

Note: You MUST, of course, adapt the values according to your system (network, interface name...).

V. DNS Resolver

Because Ubuntu Bionic Beaver (18.04) make use of the DNS stub resolver as provided by SYSTEMD-RESOLVED.SERVICE(8), you SHOULD also add the DNS to contact into the /etc/systemd/resolved.conf file. For instance:

....
DNS=1.1.1.1
DNS=1.0.0.1
....

and then restart the systemd-resolved service once done:

# systemctl restart systemd-resolved

The DNS entries in the ifupdown INTERFACES(5) file, as shown above, are only relevant if you make use of RESOLVCONF(8) or similar.

  • 5
    Well, f*** them. Just apt-get install when you've got no network configuration. What a brilliant idea, Canonical. – Velkan Aug 3 '18 at 6:47
  • @Velkan You can always pre-configure your network with netplan then switch back to ifupdown later on ;) But I agreed with you. Somehow canonical take bad decisions. For instance, they break softwares that rely on ifupdown for networking configuration (no provider for netplan). This is the case for our control panel software (stable serie) where we do not want add new network configuration provider... – Nuxwin Aug 5 '18 at 9:58
  • 1
    @StephenBoston I totally agree with you. However, even if Canonical try to go ahead by introducing new technology, it could do this in less invasive manner. I mean, the choice should be left to end user. For workstations, the change from ifupdown to netplan is surely not a big deal but when you have to deal with Ubuntu servers, that's another story because most stable softwares doesn't necesserely provide adapters... That has been the same story for systemd. I've to deal with both Debian and Ubuntu everydays. The problem with Ubuntu is that they don't care much about backward compatibility. – Nuxwin Sep 1 '18 at 5:59
  • 1
    Minor correction: # systemctl unmak networking -> # systemctl unmask networking – Santosh Dec 14 '18 at 6:42
  • 1
    Also, if you use dns-domain and dns-searchin the interfaces file, you should configure the Domains parameter in resolved.conf, I think? Anyway, great job putting that all together here, probably saved me a lot of time :) – OttoEisen Dec 16 '18 at 16:26
4

Netplan and yaml are, at best, fragile in the server-only environment (indentation mistakes will cost you). Interfaces was forgiving enough that it made managing the network settings on a server quite easy.
Netplan introduces new layers. But the real problem is that U18 breaks ifupdown, and doesn't finish the job with NetPlan. If you return to /etc/network/interfaces by reinstalling ifupdown managing the DNS no longer works in the interfaces file. Any dns-nameservers entries are ignored. Instead the dns is set in /etc/resolv.conf. But you can't edit that file because it gets re-written every time the machine is booted. WTF? Netplan was designed to be managed by a GUI so those of us in the server-only camp are left with a fragile system we have to tiptoe around. Not good Ubuntu!
why not give us a way to redirect the settings in /etc/network/interfaces into netplan on bootup to help us while you finish netplan?

  • 1
    how does this answer the question? – Pierre.Vriens Oct 31 '18 at 15:51
  • @Dan Desjardins See the accepted answer regarding the DNS resolver issue.. Basically put, the DNS entries that you put into the ifupdown INTERFACES(5) file are only relevant when you make use of resolvconf(8) or similar. For the DNS stub resolver as provided by SYSTEMD-RESOLVED.SERVICE(8, you need add your DNS into the /etc/systemd/resolved.conf file. Doing this will make them persistent. Another solution is to disable the SYSTEMD-RESOLVED.SERVICE(8) service and install/setup resolvconf(8). In the hope that I'm clear enough. – Nuxwin Nov 27 '18 at 22:38
2

The Netplan team has posted an official answer on their FAQ here:

How to go back to ifupdown

...

On a running system, netplan can be removed by installing ifupdown and configuring /etc/network/interfaces manually as users have done before.

At install time, a user can opt to use ifupdown by preseeding netcfg/do_not_use_netplan=true. This is done by adding the preseed line to the command line when booting the installation media (i.e. at install media boot menu, press F6, type ‘e’, and add to the command line).

See Nuxwin's answer for more complete instructions.

1

Why not just configure with netplan?

Well, as it is configured in 18.04-Desktop, it is a single line handing over control to all interfaces to NetworkManager.

While that is probably suitable for 95% of users, remember that NetworkManager is only run once you are logged in to a session.

Should you want your machine to act as a server/desktop, for example start serving files to local machines, acting as VNP server, etc... or anything "fancy" before anyone is ever logged in, just by the simple fact it is on, you will have trouble with how it is configured in standard 18.04-Desktop.

Of course, the alternative would be to use the server-Netplan configuration, which, as far as I have read (not checked by myself), hands control over to systemd-networkd instead. In this case you'd better learn how systemd does things as a replacement of the old System V init.

Should you go this path, you still have to make change to the netplan yaml, since on a desktop version the control is given to NetworkManager.

  • At least one reason exists: Netplan does not support openvswitch. – Kamilion Aug 31 '18 at 18:07
  • 1
    netplan does not support IP aliases (eth0:0 style). I can't believe how such thing could find its way into Ubuntu server! – Hamid Fadishei Oct 11 '18 at 12:30
  • Because my netplan directories is empty ! – dsgdfg Jan 16 at 12:47
1

The key is knowing that cloud.init is the real control program.
That being said the line in the netplan config file "optional: true" is mandatory.
Knowing that made it easy.

I just removed 01-network-manager-all.yaml and copied it to /root/save/. Then put a known good config in place instead of it, 50-cloud-init.yaml: its contents follow:

network:
  version: 2
  renderer: networkd
  ethernets:
    eports:
      match: 
        name: enp*
        optional: true
  bonds:
    bond0:
      interfaces: [eports]
      addresses: [192.168.2.5/24]
      gateway4: 192.168.2.1
      nameservers:
        addresses: [127.0.0.1, 8.8.4.4]          
      parameters:
        mode: 0          
        mii-monitor-interval: 100

Then reboot and it should be working fine.

The known good config came from Configure bonded 802.3ad network using netplan on Ubuntu 18.04.

  • The question here is how to switch back to ifupdown ;) In future, you should try to answer the questions without polluting them, even through it is not always easy to stick to initial subject ;) – Nuxwin Sep 1 '18 at 6:09
0

According to this answer, the solution is to remove all operational .yaml files: Ubuntu 17.10 disable netplan

I wouldn’t remove anything without backing up. We can do so easily by simply moving the files aside. First, locate the files:

sudo updatedb
locate netplan | grep yaml

On my 18.04 system, it appears that the only operational file is /etc/netplan/01-network-manager-all.yaml. Let’s move it:

mkdir ~/netplan
sudo mv /etc/netplan/01-network-manager-all.yaml  /home/user/netplan

...where user is your user name.

Now check to make sure the file is truly gone:

ls /etc/netplan

Now make your additions to /etc/network/interfaces as required.

Reboot.

Any improvement?

Footnote: The exact process to do this is hard to find. We may need to refine a bit as we go.

  • I'll have to try that and see how it goes. The only other question would be how to apply the changes without rebooting. In the past you could use ifup/ifdown, /etc/init.d/networking restart, service networking restart, and the systemd methods, like systemctl restart networking, systemctl restart Network-Manager.service etc, but none of these were possible for me after installing Ubuntu 18.04. – jdgregson May 3 '18 at 22:05
  • What is the result of: sudo ip link set eth0 down followed by: sudo ifup -v eth0 Of course, substitute your interface for the mythical eth0. – chili555 May 3 '18 at 23:01
  • ifupdown is not installed by default, so when you call ifup it just tells you how to install it. However, sudo ip link set eth0 down followed by sudo ip link set eth0 up does turn the interface off and back on. – jdgregson May 3 '18 at 23:27
  • Awesome! So you are solved and all set? – chili555 May 3 '18 at 23:46
  • Careful, not all *.yaml files are related to netplan, so only remove those in netplan-related directories! – JanC May 5 '18 at 19:33

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.