LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 11-27-2019, 11:44 AM   #1
jesusangel
LQ Newbie
 
Registered: Nov 2019
Posts: 9

Rep: Reputation: Disabled
Networking.service fails to start after setting up interfaces in initramfs


Hello,

I need to setup network in initramfs so I've set up kernel command line as follows:

Code:
linux   /vmlinuz-5.2.0-0.bpo.3-amd64 root=UUID=40d729d8-b87e-455f-a7a5-2520be1ca65a ro  quiet systemd.show_status=1 acpi=force net.ifnames=0 biosdevname=0 apparmor=1 security=apparmor rd.luks.name=32c764bd-9612-4bd0-9d0f-cda3d0a3595d=root rd.luks.options=timeout=60s rd.neednet=1 ip=10.0.0.118::10.0.0.102:255.255.255.0:lunada:eth1:none:10.0.0.103:10.0.0.104
When the kernel is loaded and the system starts, the networking service failed:

Code:
systemctl status networking
● networking.service - Raise network interfaces
   Loaded: loaded (/lib/systemd/system/networking.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Wed 2019-11-27 18:09:04 CET; 6min ago
     Docs: man:interfaces(5)
  Process: 867 ExecStart=/sbin/ifup -a --read-environment (code=exited, status=1/FAILURE)
 Main PID: 867 (code=exited, status=1/FAILURE)

Nov 27 18:09:03 lunada systemd[1]: Starting Raise network interfaces...
Nov 27 18:09:03 lunada ifup[867]: RTNETLINK answers: File exists
Nov 27 18:09:03 lunada ifup[867]: ifup: failed to bring up eth0
Nov 27 18:09:04 lunada systemd[1]: networking.service: Main process exited, code=exited, status=1/FAILURE
Nov 27 18:09:04 lunada systemd[1]: networking.service: Failed with result 'exit-code'.
Nov 27 18:09:04 lunada systemd[1]: Failed to start Raise network interfaces.
Although I just setup eth1 interface in the initramfs, it seems that the interface eth0 is already up and because of that the networking service fails.

I've added a script to bring down the interfaces in the pre-up stage:

Code:
cat /etc/network/if-pre-up.d/clean
#!/bin/bash

if [[ $IFACE =~ ^eth[0-1]$ ]]
then
        ifconfig $IFACE down
        ip addr flush dev $IFACE
fi
But it isn't working. Nevertheless, if I restart the networking service after the system boots, it works like a charm:

Code:
# systemctl restart networking
systemctl status networking
● networking.service - Raise network interfaces
   Loaded: loaded (/lib/systemd/system/networking.service; enabled; vendor preset: enabled)
   Active: active (exited) since Wed 2019-11-27 18:40:32 CET; 4s ago
     Docs: man:interfaces(5)
  Process: 2948 ExecStart=/sbin/ifup -a --read-environment (code=exited, status=0/SUCCESS)
 Main PID: 2948 (code=exited, status=0/SUCCESS)

Nov 27 18:40:32 lunada systemd[1]: Starting Raise network interfaces...
Nov 27 18:40:32 lunada systemd[1]: Started Raise network interfaces.
How can I fix the systemd networking.service to initialize the network interfaces?

I'm using Debian Buster.

Kind regards,
 
Old 11-28-2019, 02:22 AM   #2
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Not saying I know how to solve this, but...
- initramfs does not seem to come into it afaics?
- have you tried the ifup command manually (see systemctl status networking)? What's it say?
- is something like a script in /etc/network/if-pre-up.d/ even relevant on a current systemd distro? Honest question.
 
Old 11-28-2019, 05:22 AM   #3
jesusangel
LQ Newbie
 
Registered: Nov 2019
Posts: 9

Original Poster
Rep: Reputation: Disabled
Hello,

The point is, if I delete the ip option in the kernel command line, the network interface isn't activated in the initramfs and the networking service does start correctly. Nevertheless, I need the network up in the initramfs because I'm using clevis to open the root filesystem which is encrypted with LUKS.

I haven't tried to run the ifup command manually but if I do a systemctl restart networking the service works, so I think the "/sbin/ifup -a --read-environment" will also works as it's basically what the service does.

With regard to the last question, I don't know. In debian the ifup command searchs for the interfaces in the file /etc/network/interfaces. According to intefaces(5) "when ifupdown is being called with the --all option, before doing anything to interfaces, if calls all the hook scripts (pre-up or down)". I though I could bring down the interfaces in case they were bringed up before. I tried the pre-up option in the /etc/network/interfaces but then decided to move to the /etc/network/if-pre-up.d/clean script. Sadly, none of these have worked.

Kind regards,
 
Old 12-12-2019, 04:27 AM   #4
jesusangel
LQ Newbie
 
Registered: Nov 2019
Posts: 9

Original Poster
Rep: Reputation: Disabled
Hello,

I have solved this issue. The problem wasn't about the eth0 interface itself, but about the default gateway. In the ramfs I was setting a default gateway for eth1 interface, and in the interfaces configuration I was also setting another default gateway for the eth0 one. Before bringing up eth0 I was bringing it down, but I wasn't deleting the default gateway, so when ifup tried to set another default route, it failed.

I have removed the gateway from the network config in the kernel command line so now there is not a default gateway when the networking service starts, and it runs well.

Hope this will help someone out there.

Kind regards,
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
After cloning VM in vSphere, network.service fails to start Latitude Linux - Virtualization and Cloud 2 05-22-2019 07:18 AM
3 network interfaces - only works from boot with two interfaces enabled linux_driver Linux - Networking 4 11-26-2014 05:42 PM
ifup: couldn't read interfaces file "/etc/network/interfaces" dobharweim Linux - Networking 1 12-13-2013 11:20 AM
[SOLVED] /etc/network/interfaces configuration for virtual interfaces nonshatter Linux - Networking 4 10-25-2010 06:22 AM
ifup: couldn't read interfaces file "/etc/network/interfaces" debian lenny lorimer73 Linux - Networking 1 08-24-2010 03:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 11:48 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration