[TriLUG] custom network intefaces during boot for Debian

John F. Davis davis at trilug.org
Thu Feb 16 10:40:04 EST 2006


Hello

Here is a script modification for /etc/init.d/networking in Debian so
that your list of network interfaces can be reconfigured during boot.
Why would you like to have a script like this?  Well, in my case,
I have a laptop with a lan based eth0 and a wifi based eth1.  If
I am not connected to a lan during boot, I have to wait for the
network interface on eth0 to time out with its dhcp request.
With this script, it displays the current network config and gives
me a chance to modify it.

Here is an example of the script running:

bic:~# /etc/init.d/networking restart
Current interfaces:
auto lo eth1
Customize networking
y
Enter interfaces besides lo.
eth0
lo eth0
New interfaces are:
auto lo eth0
* /etc/network/options is deprecated.
Setting up IP spoofing protection...done (rp_filter).
Reconfiguring network interfaces...ifup: interface lo already configured
Internet Software Consortium DHCP Client 2.0pl5
Copyright 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium.
All rights reserved.

Please contribute if you find this software useful.
For info, please visit http://www.isc.org/dhcp-contrib.html

Listening on LPF/eth0/00:0d:60:b0:4e:50
Sending on   LPF/eth0/00:0d:60:b0:4e:50
Sending on   Socket/fallback/fallback-net
DHCPREQUEST on eth0 to 255.255.255.255 port 67
DHCPREQUEST on eth0 to 255.255.255.255 port 67
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 8
DHCPOFFER from 10.0.0.4       
DHCPREQUEST on eth0 to 255.255.255.255 port 67
DHCPACK from 10.0.0.3
bound to 10.0.0.70 -- renewal in 21600 seconds.
done.
bic:~#                          


Here is the modification:

bic:/etc/init.d# diff -Naur networking.arc networking
--- networking.arc      2006-02-16 10:39:20.000000000 -0500
+++ networking  2006-02-16 10:18:40.000000000 -0500
@@ -9,6 +9,26 @@
 PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
 
 
+echo "Current interfaces:"
+foo=`grep -e ^auto /etc/network/interfaces`
+echo $foo
+echo "Customize networking"
+read userinput
+if [ "$userinput" = "y" ] ; then 
+       echo "Enter interfaces besides lo."
+       save=$1
+       read userinput
+       myinterfaces="lo $userinput"
+       echo $myinterfaces
+       sed -i -e "s/^auto\ .*/auto\ $myinterfaces/"
/etc/network/interfaces
+       echo "New interfaces are:"
+       foo=`grep -e ^auto /etc/network/interfaces`
+       echo $foo
+fi
+
+
+
+
 [ -x /sbin/ifup ] || exit 0
 
 . /lib/lsb/init-functions




More information about the TriLUG mailing list