Ifup error due to faulty /etc/network/interfaces

Creating a bug report/issue

Required Information

  • DietPi version | 8.20.1
  • Distro version | bullseye
  • Kernel version | 5.10.0-23-amd64 #1 SMP Debian 5.10.179-3 (2023-07-27) x86_64 GNU/Linux
  • Architecture | amd64
  • SBC model | Native PC (x86_64)

Steps to reproduce

When I restarted the PC, eth0 didn’t come up. I was already thinking of a hardware problem until I found out that ifup eth0 threw an error saying it can’t read /etc/network/interfaces due to an error in line 19.

Line 19 belongs to the WiFi section which I disabled due to non-existing WLAN hardware.
Line 19 is showing the “address” which is empty, but ifup is expecting a value.
I commented out the complete wifi section and now I was able to start eth0 without any error.

As soon as I start dietpi-config and apply the network settings (Ethernet enabled, WIFI disabled), the values I commented out are back (which makes sense since interfaces shouldn’t be edited manually).

But why are there values listed which lead to an error while starting the network devices?
Is this a bug or did something go wrong earlier in my configuration?

I’m quite puzzled right now and don’t know where to start fixing this.
Any idea from this great community out there?

Your help is highly appreciated since the one and only network interface is the heart of a server :wink:

Thank you all and best regards,
Huettenwirt

Expected behaviour

dietpi-config is able to start and stop all network devices

Actual behaviour

dietpi-config writes values to /etc/network/interfaces which can’t be parsed by ifup resulting in no ethernet connection

Extra details

Here’s the content of etc/network/interfaces with the faulty lines (19, 20, probably also 21) which I needed to comment out to get ifup to work

# Location: /etc/network/interfaces
# Please modify network settings via: dietpi-config
# Or create your own drop-ins in: /etc/network/interfaces.d/

# Drop-in configs
source interfaces.d/*

# Ethernet
allow-hotplug eth0
iface eth0 inet dhcp
address 192.168.0.90
netmask 255.255.255.0
gateway 192.168.0.1
#dns-nameservers 192.168.0.1

# WiFi
#allow-hotplug wlan0
iface wlan0 inet dhcp
address
netmask
gateway .1
#dns-nameservers 192.168.0.1
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

hmm I did some testing on my Rpi4B but was not able to replicate your behaviour. @MichaIng any ideas how this could happen?

Thanks a lot for your first investigation.

Just curious: How should the interfaces content look like if I enable eth0 and disable WLAN via dietpi-config?
Would the complete WLAN part by commented out?

like this for a STATIC eth0 interface

# Location: /etc/network/interfaces
# Please modify network settings via: dietpi-config
# Or create your own drop-ins in: /etc/network/interfaces.d/

# Drop-in configs
source interfaces.d/*

# Ethernet
allow-hotplug eth0
iface eth0 inet static
address 192.168.188.2
netmask 255.255.255.0
gateway 192.168.188.1
#dns-nameservers 9.9.9.9 149.112.112.112

# WiFi
#allow-hotplug wlan0
iface wlan0 inet dhcp
address 192.168.0.100
netmask 255.255.255.0
gateway 192.168.0.1
#dns-nameservers 192.168.0.11
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

Nope, just set a # into first WiFi configuration line

#allow-hotplug wlan0

So I think the issue is related to missing values for address, netmask and gateway in the wifi section

address
netmask
gateway .1

this is why ifup can’t parse the /etc/network/interfaces.

The remaining question is why dietpi-config is not filling these at least with some dummy values to ensure parsing… Something strange happened…

I also tried to deinstall, install and again deinstall the WiFi drivers via dietpi-config, hoping for some self healing, but without success…

This happens if you manually remove the lines and then re-apply network settings. The values for the WiFi interfaces are read from the file, using the second value for each key, as the first is assumed to be for Ethernet. But there never was a check about whether there is any second key. This should fix it by re-applying the defaults if the respective key is empty, including the case if the whole file is empty or does not exist: v8.21 · MichaIng/DietPi@c879ced · GitHub

1 Like

@MichaIng Thank you for your fast investigation and fix!

Just wanted to add that I didn’t manually remove any values in the first place. And I can’t reproduce what kind of issue led to the behaviour I experienced, but your consistency check will fix this anyway.
I added some values in /etc/network/interfaces for the wifi address, netmask and gateway and brought the wifi entry back to standard. After that I was able to apply network settings using dietpi-config without any issue which means ifup was able to start the devices as intended.

Thanks a lot for all the work around DietPi! Did I mention that Dietpi is my alltime favourite when it comes to home server OS? :wink:

Best,
Huettenwirt

1 Like

Jep, however it happened, it totally makes sense to have fallback values applied anyway, as long as WiFi and Ethernet blocks are both added even when disabled (I aim to change this, but larger rework/task).