Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

/etc/init.d/networking and Debian 8

Linux Kernel, Network, and Services configuration.
Post Reply
Message
Author
ZenNetwork
Posts: 4
Joined: 2015-08-06 11:37

/etc/init.d/networking and Debian 8

#1 Post by ZenNetwork »

I'm trying to master networking in Debian 8, and I did found some things which I don't understand how they behave.
Going from InitV to Systemd, I'm trying to understand the /etc/init.d/networking script functioning.

Here is what my tests did show so far :

The /etc/init.d/networking script is really launched, whether we use :

1. sudo sh /etc/init.d/networking [action]
2. sudo /etc/init.d/networking [action]
3. sudo service networking [action]
4. sudo systemctl [action] networking.service
5. sudo cp /etc/init.d/networking /home/[user]/Desktop/networking && \
sudo sh /home/[user]/Desktop/networking [action]

This has been tested using stop, start and restart


In cases 1/2/3/4, we get displayed : '[....] Restarting networking (via systemctl): ' . The 'Restart is deprecated' warning is not displayed anymore.

The restart command is 'hacked' by systemd and transformed into a stop/start sequence.
The 'restart' part of the script is never played ( unless in case 5, where we copy the networking script to the Desktop, and launch it there : In this case only we have the 'restart' part played, the (via systemctl) line omitted, and the 'restart is deprecated' warning displayed )

Using 'allow-hotplug eth0' in /etc/network/interfaces, we get the interface correctly restarted in all 5 scenarios. ( no more allow-hotplug problem )

This is because we have this part in the networking script 'Start' subsequence :

Code: Select all

if ifup -a $exclusions $verbose && ifup_hotplug $exclusions $verbose
With this ifup_hotplug function higher above in the networking script :

Code: Select all

ifup_hotplug () {
    if [ -d /sys/class/net ]
    then
	    ifaces=$(for iface in $(ifquery --list --allow=hotplug)
			    do
				    link=${iface##:*}
				    link=${link##.*}
				    if [ -e "/sys/class/net/$link" ]
				    then
					# link detection does not work unless we up the link
					ip link set "$iface" up || true
					if [ "$(cat /sys/class/net/$link/operstate)" = up ]
					then
					    echo "$iface"
					fi
				    fi
			    done)
	    if [ -n "$ifaces" ]
	    then
		ifup $ifaces "$@" || true
	    fi
    fi
}

This function seems to enumerate the allow-hotplug interfaces :
sudo ifquery --list --allow=hotplug

and then to individually up the ones that are down :

ifup $ifaces "$@" || true

Conclusions :

It really does seem like systemd is hacking '/etc/init.d/networking restart', changing it into stop/start.
When we copy it on the desktop and launch it from there, we now have the restart part really played.

Is there an official, recommended syntax to stop/start/restart networking ?
Why is the dire restart warning still in the networking script ( although only displayed if launched locally ) ?
There is no systemd native networking script, systemd is actually using /etc/init.d/networking.
How is systemd controlling the /etc/init.d/networking script ?

Thanks for any help to better understand all this :D

=============Tests details and Methodology=============================================================================
Here is what I got so far :

. Placing a beep at the beginning of /etc/init.d/networking ( /usr/bin/speaker-test -t sine -f 500 -l 1 )
do show that this script is launched, whether :

sudo sh /etc/init.d/networking restart
sudo /etc/init.d/networking restart
sudo service networking restart
sudo systemctl restart networking.service

In each case, we get displayed : '[....] Restarting networking (via systemctl): '

. In the Start/Stop/Restart sequences, placing a beep in the init_is_upstart test, ie :

if init_is_upstart; then
/usr/bin/speaker-test -t sine -f 500 -l 1
exit 1
fi

do show that this part is never played ( which is logical, as we're using systemd and not upstart )

. In the Start/Stop/Restart sequences, placing a beep before or after the init_is_upstart test, ie :
start)
if init_is_upstart; then
exit 1
fi
/usr/bin/speaker-test -t sine -f 400 -l 1
process_options

do show that the Start and Stop sequences are played, whenever with :

sudo sh /etc/init.d/networking restart
sudo /etc/init.d/networking restart
sudo service networking restart
sudo systemctl restart networking.service

and the restart part doesn't seem to be ever executed.

. Furthermore, completely deleting the restart part proves that it is not executed, but replaced with either :

sudo sh /etc/init.d/networking stop && sudo sh /etc/init.d/networking start
sudo /etc/init.d/networking stop && sudo /etc/init.d/networking start
sudo service networking stop && sudo service networking start
sudo systemctl stop networking.service && sudo systemctl start networking.service

because the restart functions are still functionning. ( I did use some /usr/bin/speaker-test commands with different frequencies for start, stop, and double beep for restart to be sure )

/etc/init.d/networking restart does contain the 'restart is deprecated' warning. Let's check if it should be idsplayed :

Tests with allow-hotplug :

sudo sh /etc/init.d/networking restart Functionning, sudo ifup eth0 not needed
sudo /etc/init.d/networking restart Functionning, sudo ifup eth0 not needed
sudo systemctl restart networking.service Functionning, sudo ifup eth0 not needed

sudo sh /etc/init.d/networking stop/start Functionning, sudo ifup eth0 not needed
sudo /etc/init.d/networking stop/start Functionning, sudo ifup eth0 not needed
sudo systemctl stop/start networking.service Functionning, sudo ifup eth0 not needed

So we don't have the old, usual allow-hotplug problem.

Finally, let's copy the /etc/init.d/networking script on our Desktop, and try to run it from there.
Let's place a beep in the restart section too, and try 'sudo sh ./networking restart' :

1. We get the 'restart' warning :
[warn] Running ./networking restart is deprecated because it may not re-enable some interfaces ... (warning).

instead of '[....] Restarting networking (via systemctl)'
2. We do get the beep

3. We have a functionning network, no needing sudo ifup eth0

I really does seem like systemd is hacking '/etc/init.d/networking restart', changing it into stop/start.
When we copy it on the desktop and launch it from there, we now have the restart part really played.


==============End of Testings ============================================================================================

Post Reply