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?
7 Answers
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 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.
-
23Well, f*** them. Just
apt-get install
when you've got no network configuration. What a brilliant idea, Canonical.– VelkanCommented Aug 3, 2018 at 6:47 -
2@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... Commented Aug 5, 2018 at 9:58
-
5@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. Commented Sep 1, 2018 at 5:59
-
1Also, if you use
dns-domain
anddns-search
in the interfaces file, you should configure theDomains
parameter in resolved.conf, I think? Anyway, great job putting that all together here, probably saved me a lot of time :) Commented Dec 16, 2018 at 16:26 -
1@Nuxwin man for resolved.conf said that 'DNS=' is "A space-separated list" Commented Mar 24, 2019 at 7:40
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.
-
This appears to be ignored by the 18.04.4 installer. I tried putting this option both before and after the --- that ends the command line initially presented (on separate attempts, of course) and always end up with netplan. I may need to try installed 16.04 and doing a dist upgrade just to get what I want. Commented Mar 31, 2020 at 10:19
The answer of Nuxwin is great and almost complete, I'd just add the lines:
rm /etc/resolv.conf
ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
This will make sure that the resolver can be updated by the DHCP-client, like it was before when using interfaces.
(I would have added this as a comment but somehow one need 50 reputation to post a comment)
-
-
-
You can also optionally install the ''resolvconf'' package and put the changes in a daemon directory.– oemb1905Commented Jan 22, 2023 at 18:59
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.
-
4At least one reason exists: Netplan does not support openvswitch.– KamilionCommented Aug 31, 2018 at 18:07
-
7netplan does not support IP aliases (eth0:0 style). I can't believe how such thing could find its way into Ubuntu server! Commented Oct 11, 2018 at 12:30
-
-
2NetworkManager service starts pretty early and does not require a session or a logged-in user.– thallerCommented Oct 23, 2019 at 21:04
-
Because netplan is not ready for production, with the slightest network problems the server will go into an endless load. Commented Dec 8, 2020 at 10:38
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.
-
2The 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 ;) Commented Sep 1, 2018 at 6:09
Why not just remove netplan:
$ sudo apt remove netplan
$ rm -rf /etc/netplan
Once for all!
-
1Assuming you've never successfully connected the server to the network before to install alternate methods of configuring the network, does this leave you completely unable to configure networking? It is there a built in fallback method? Commented May 2, 2021 at 17:53
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, likesystemctl restart networking
,systemctl restart Network-Manager.service
etc, but none of these were possible for me after installing Ubuntu 18.04. Commented May 3, 2018 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.– chili555Commented May 3, 2018 at 23:01 -
ifupdown
is not installed by default, so when you callifup
it just tells you how to install it. However,sudo ip link set eth0 down
followed bysudo ip link set eth0 up
does turn the interface off and back on. Commented May 3, 2018 at 23:27 -
-
Careful, not all *.yaml files are related to netplan, so only remove those in netplan-related directories!– JanCCommented May 5, 2018 at 19:33
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./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.