After attempting to configure AirLink 101 802.11g PCI network card with an ACX111 chip under Slackware 12.1, I came to the rationalization that I needed a better understanding of Linux network initialization scripts I was able to successfully compile and install the driver and firmware but the computer would hang displayed Triggering udev events. I believe this to be because a DHCP server can not be found. While trying to troubleshoot this I found that I did not understand the network initialization process and needed a review of shell scripting. So Before I continue further, I have decided to write this post to better my understanding of the entire process of bringing up network interfaces in Linux.

The script used to bring up network interfaces at boot is /etc/rc.d/rc.inet1 and it is executed by /etc/rc.d/rc.M with this code:

#Initialize the networking hardware
if [-x /etc/rc.d/rc.inet1 ]; then
  . /etc/rc.d/rc.inet1

This if statements checks if rc.inet1 can be found and is executable by using the -x operator. If rc.inet1 exists and is executable rc.M executes it using the source operator.

Overview of /etc/rc.d/rc.inet1

  1. includes the configuration information from rc.inet1.conf
  2. Sets up logging
  3. Fills an array of interfaces from entries in rc.inet1.conf
  4. Creates a the following functions
    • lo_up() to bring up loopback interface, do nothing if loopback is already up
    • lo_down() take down the loopback interface
    • if_up() to bring up a network interface, do nothing if already up or does not exist
    • if_down() to take down a network interface
    • gateway_up() brings up the gateway if there is not yet a default route
    • gateway_down() take down an existing default gateway
    • start() start the network
    • stop() stop the network
  5. The main script

The Main Script

The execution of rc.inet1 begins with a case statement which provides various cases for starting stopping and restarting the network.
Since the script is executed by rc.M without parameters the default case is executed. The default case first calls the lo_up function to bring up the loopback device. It then iterates through the devices found in rc.inet1 using a for statement. It then uses a for loop to iterate through the devices from rc.inet1.conf which are stored in the IFNAME array. The for loop calls the if_up function passing it the name of each device. Finally gateway_up is called to bring up the gateway.

Bash Operators used in rc.inet1

. Read & execute commands from source file no matter if it is executable
-f true if the regular file exist
-a AND
-x true if the argument is an existing executable file
! not
“” and ” double quotes will display the contents of a variable, single quotes display what is enclosed literally

Other good things to know about Bash

$! PID of last process that has been started in the background (e.g. firefox &)
exit (0-255) 0 is success
$? return value of last command
$# Number of command line arguments
$0 Name of the shell script being executed.
$@ variable, which expands to all command-line parameters separated by spaces

Things that are still not clear

what's the deal with the parenthesis: i=$(($i+1))
what's the deal with the brackets: IFNAME[$i]=${IFNAME[$i]:=eth${i}}

Slackware Boot Process Links

Bash Scripting Links

Kernel Hacking links