2

Removing the netplan.io package from my system running Ubuntu Server 20.04 LTS ("Focal Fossa") causes no immediate effects, i.e. the network keeps working, but the next time the server is restarted there is no network. That means Netplan is responsible for some aspect of configuration (obviously), and the OS is able to use the network, if it's properly configured.

Previous failed attempts

I have tried these steps to attempt to manually bring up the network without Netplan:

  • ifconfig eth0 up — Failed.

    It brings up some semblance of IPv6, but no IPv4; no network access.

  • dhclient eth0 — Failed.

    Tried this next, hung forever, did nothing.

  • ifup — Failed.

    Command not found.

  • sudoedit /etc/network/interfaces — Failed.

    File not found.

Netplan configuration

Here is the configuration I extracted using netplan get while it was still installed:

network:
  version: 2
  ethernets:
    eth0:
      addresses:
        - "<redacted>/24"
      gateway4: <redacted>

It looks extremely basic, but I somehow can't find out how to apply it without keeping Netplan installed.

Desired outcome

My end goal is to get the network working automatically on system startup without Netplan installed. I cannot find any packages to try installing in order to facilitate this. I can only find guides on how to edit /etc/network/interfaces, but that isn't applicable here. On top of that, apt-file search cannot find any packages that contain that file, so I can't even make it applicable.

How do I keep Ethernet working without Netplan?


EDIT: I finally found a sequence of commands that properly configures the network:

ifconfig eth0 <address> netmask 255.255.255.0
route add default gw <gateway4> eth0
ifconfig eth0 up

DNS name resolution even works, too! Now I just need to find a way to perform this automatically on boot…maybe an @reboot cron job, but that feels hacky…

Dev
  • 712

2 Answers2

2

On Terrance's suggestion, I installed ifupdown which seems to be the package that adds /etc/network/interfaces. Not sure why apt-file couldn't find it.

After adding this to /etc/network/interfaces:

auto eth0
iface eth0 inet static
        address <censored>
        netmask 255.255.255.0
        gateway <censored>

and making sure the networking service was enabled (systemctl enable networking), I now have network access on every boot. Success!

Dev
  • 712
0

You don't really want to use the /etc/network/interfaces file as it is deprecated. I've completely removed netplan.io on the Server Ubuntu 22.04.1 LTS.

Create your configuration in /etc/systemd/network. I started by copying the files created by netplan.io in /run/systemd/network and then edited them until I got what I wanted. The liberal use of 'man systemd.network' is recommended.

Reboot to make sure that everything is set up and running as you want it.

Run as root to remove these packages

apt remove ifupdown cloud-init

dpkg --ignore-depends=ubuntu-minimal -r netplan.io

You are now running as close to bare metal as systemd-networkd will let you. Use the networkctl(1) command for admin stuff. And the ip(8) command is still available if necessary.