19

I recently upgraded my 16.04 server system to 18.04, and then tried to use netplan to set up networking. Unfortunately, now my network settings are broken and I don't know which files belong to which network configuration system.

The /etc/network/interfaces file still contains data, and there are a bunch of other files in /etc/network whose purpose I don't know.

What I want to do is start over with the following config:

network:
  version: 2
  renderer: networkd
  ethernets:
    enp4s0:
      dhcp4: yes
      dhcp6: yes
  bridges:
    br0:
      interfaces: [enp4s0]
      dhcp4: true
      parameters:
        stp: false
        forward-delay: 0

Can anyone tell me what files I actually need and what's just cruft that should be deleted? This system is only supposed to have one bridged network device and have openssh-server, lxc, and docker running. This is what's currently there:

# tree network
network
├── fan
├── if-down.d
│   ├── resolvconf
│   └── ubuntu-fan
├── if-post-down.d
│   ├── bridge -> /lib/bridge-utils/ifupdown.sh
│   ├── ifenslave
│   ├── ubuntu-fan
│   ├── vlan
│   └── wireless-tools
├── if-pre-up.d
│   ├── bridge -> /lib/bridge-utils/ifupdown.sh
│   ├── ethtool
│   ├── ifenslave
│   ├── vlan
│   └── wireless-tools
├── if-up.d
│   ├── 000resolvconf
│   ├── avahi-daemon
│   ├── ethtool
│   ├── ifenslave
│   ├── ip
│   ├── openssh-server
│   └── ubuntu-fan
├── interfaces
└── interfaces.d

5 directories, 21 files
# tree netplan
netplan
└── 01-netcfg.yaml

0 directories, 1 file
# tree NetworkManager/
NetworkManager/
└── conf.d
    └── 10-ubuntu-fan.conf
0xC0000022L
  • 5,720
Karl
  • 341

1 Answers1

31

If you are upgrading to 18.04 and want to use netplan instead of ifupdown, then you should do the following:

  1. make sure you have a way to access your server if the network goes down
  2. make sure the package netplan.io is installed (it should be on 18.04).
  3. create a netplan yaml according to your config. There are many examples to choose from.
  4. sudo netplan apply
  5. sudo apt purge ifupdown
  6. Reboot
  7. You should now be "migrated", and networkctl, ip addr, etc, should show your interfaces.

Note, there will still be cruft in /etc/network/. You can remove/archive:

  • /etc/network/interfaces
  • /etc/network/interfaces.d/

The rest are "hook" directories, that other packages put files in that try to react to the network state of the system. These files should be left alone.

If you have any files that you have put in there, these same facilities are better done by integrating into systemd unit files, or by using networkd-dispatcher. See more on the netplan FAQ.

Eliah Kagan
  • 117,780
dpb
  • 7,069
  • I followed these instructions on Ubuntu 18.04 and what happened was it created a new user account called 'netplan-daemon' which was available when I restart in Gnome, and the NetworkManager settings in the Bionic Beaver GUI disappeared, leaving only the VPN configuration option. Not sure why but the results were bad for me. – jsstuball Feb 06 '19 at 10:04
  • 2
    make sure you are apt install netplan.io. note the .io! I made the same mistake as you so I had to apt purge netplan – kfix Feb 27 '19 at 05:33
  • My configuration is super simple with one interface but when I ran step 5 "sudo apt purge ifupdown" the machine became inaccessible. What could be the reason for that. – oᴉɹǝɥɔ May 14 '20 at 02:06
  • Like @oᴉɹǝɥɔ, I found that my ssh connection was aborted when running "apt purge ifpdown". When I logged back in by other means (without rebooting), I found that the ethernet interface was down. The solution is to use a semicolon in the shell command to do both commands one after the other: apt -y purge ifupdown ; netplan apply – rohanc Jun 23 '20 at 06:22
  • I also had to apt purge resolvconf as discussed here – gerardw Jan 28 '21 at 10:40
  • before sudo netplan apply one could use sudo netplan try and make sure things work – ignacio May 09 '22 at 09:14
  • I had problems because my interface was still eth0 and I wanted to name it ens160. That helped me: https://askubuntu.com/questions/1317036/how-to-rename-a-network-interface-in-20-04 – uav Aug 19 '22 at 15:15
  • Didn't work for me... Then I found this: https://gist.github.com/mss/7a8e048dd51e5ef928039f1450ba8f31 with steps: 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 Next steps were: -made configuration for netplan (with static IP) /etc/netplan/01-netplan.yaml #not some other name netplan --debug generate

    that shows error in yaml configuration

    netplan --debug apply reboot

    – Greg G May 25 '23 at 11:30