1

Removing netplan.io causes no immediate effects (network still works), but the next time the server is restarted, there is no network. That means netplan.io is responsible for some aspect of configuration (obviously), and the OS is able to use the network, if it's properly configured.

I have tried these steps to attempt to manually bring up the network without netplan.io:

  1. ifconfig eth0 up brings some semblence of IPv6 up, but no IPv4. No network access.
  2. dhclient eth0 (after #1) hangs forever, i.e. does nothing.
  3. The ifup command does not exist.
  4. The /etc/network/interfaces file does not exist.

Here is the configuration I am able to extract from netplan get while it is installed:

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

It looks extremely basic but I somehow can't find out how to apply it without netplan.io.

My end goal is to get network working without netplan.io installed, and automatically on system startup. 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 cannot find any package that contains that file, so I can't even make it applicable.

How do I keep ethernet working without netplan.io?

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 just to find a way to perform this automatically on boot... maybe an @reboot cron job, but that feels hacky...

Dev
  • 692
  • Are you using Ubuntu? Which release? Please [edit] your question to add information, comments are an Us to You channel, used to help you make your question better, and more likely to receive an appropriate answer. – waltinator Apr 13 '22 at 12:56
  • 2
    Why are you trying to remove Python? It is a core of Ubuntu and removing it can cause all sorts of failures and crashes. You can install ifupdown and get rid of NetworkManager (if installed). ifupdown is the old way of using the /etc/network/interfaces file for your network. – Terrance Apr 13 '22 at 13:00
  • DO NOT remove Python! Many of the core system components need it, and removing it will leave you with a wholly broken system! – Thomas Ward Apr 13 '22 at 13:20
  • On Ubuntu Server, Netplan uses the YAML to create systemd-networkd settings. You can create those settings files directly to skip the Netplan step. Ubuntu Desktop is different, since it uses NetworkMnager instead of networkd. – user535733 Apr 13 '22 at 14:28
  • You seem to be trying to change Ubuntu into Not-Ubuntu. Why are you doing this? Other Linux distributions may be more easily customizable. – waltinator Apr 13 '22 at 16:34
  • @waltinator, my question is already tagged with "20.04" and "server". I'm not sure how I could be more clear about what OS I'm using. – Dev Apr 13 '22 at 19:59
  • @Terrance My server functions fine without Python, Ubuntu hasn't required it in a while. Python used to be a core component of Ubuntu but is not anymore. – Dev Apr 13 '22 at 20:00
  • @ThomasWard See my comment above. – Dev Apr 13 '22 at 20:00
  • @user535733 I am indeed using Ubuntu Server, as you can see by the question tags. Would you mind posting an answer showing how to configure systemd-networkd? – Dev Apr 13 '22 at 20:01
  • @Dev ... apt requires python though, so not sure how 'functional' your system is actually. By 'functions fine' have you actually tested updates to packages, etc.? – Thomas Ward Apr 13 '22 at 20:13
  • @ThomasWard I don't think apt ever required python, you may be thinking of the command-not-found hook. I just tested apt update and apt upgrade and both work fine. So does other package management like adding/removing packages. Note that uninstalling python3 also uninstalled all its dependents and I manually reviewed that list, which only contained netplan.io and ufw (and python3 libs). Not sure who downvoted but I don't think it was deserved. – Dev Apr 13 '22 at 20:19
  • @Dev Show us proof where Ubuntu hasn't required Python in a long time and I will rescind my comment. – Terrance Apr 13 '22 at 20:26
  • @Terrance AFAICT, the ubuntu-minimal package still includes Python (3) by default as well as a bunch of other packages that depend on it (https://askubuntu.com/a/1259446). But that doesn't change the fact that this system seems to run fine without it. Note that it was heavily stripped by the hosting provider to use around 30MB of RAM at idle, so a lot of those packages that depended on Python were clearly unnecessary for actual server operation. From memory (unsourced now, sorry), Ubuntu used to require Python 2 for some things, but doesn't anymore. – Dev Apr 13 '22 at 20:34
  • https://askubuntu.com/questions/1259418/why-is-python-preinstalled-on-ubuntu – Terrance Apr 13 '22 at 20:40
  • @Terrance that is exactly the question I just linked. This is getting off-topic now; debates about whether Python is required or not (or really anything involving Python) don't belong on a question asking about how to replace Netplan. – Dev Apr 13 '22 at 20:43
  • I already told you that you can install ifupdown and get away with using the /etc/network/interfaces file. If all you wanted to replace netplan, then why did you start off your question with trying to remove Python? – Terrance Apr 13 '22 at 20:44
  • https://askubuntu.com/questions/1031709/ubuntu-18-04-switch-back-to-etc-network-interfaces – Terrance Apr 13 '22 at 20:46
  • @Terrance please see my comments in chat. – Dev Apr 13 '22 at 21:03

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
  • 692
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.