Create a new file /etc/init.d/localnet containing the following:
cat > /etc/init.d/localnet << "EOF"
#!/bin/sh
# Begin /etc/init.d/localnet
source /etc/init.d/functions
source /etc/sysconfig/network
case "$1" in
start)
echo -n "Bringing up the loopback interface..."
/sbin/ifconfig lo 127.0.0.1
evaluate_retval
echo -n "Setting up hostname..."
/bin/hostname $HOSTNAME
evaluate_retval
;;
stop)
echo -n "Bringing down the loopback interface..."
/sbin/ifconfig lo down
evaluate_retval
;;
*)
echo "Usage: $0: {start|stop}"
exit 1
;;
esac
# End /etc/init.d/localnet
EOF
Set the proper file permissions and create the necessary symlink by running the following commands:
cd /etc/init.d &&
chmod 754 localnet &&
cd ../rcS.d &&
ln -s ../init.d/localnet S03localnet
Create a new file /etc/sysconfig/network and put the hostname in it by running:
echo "HOSTNAME=lfs" > /etc/sysconfig/network
Replace "lfs" by the name you wish to call your computer. Please not that you should not enter the FQDN (Fully Qualified Domain Name) here. That information will be put in the /etc/hosts file later.
If you want to configure a network card, you have to decide on the IP-address, FQDN and possible aliases for use in the /etc/hosts file. An example is:
<my-IP> myhost.mydomain.org aliases
Make sure the IP-address is in the private network IP-address range. Valid ranges are:
Class Networks
A 10.0.0.0
B 172.16.0.0 through 172.31.0.0
C 192.168.0.0 through 192.168.255.0
A valid IP address could be 192.168.1.1. A valid FQDN for this IP could be www.linuxfromscratch.org
If you're not going to use a network card, you still need to come up with a FQDN. This is necessary for programs like Sendmail to operate correctly (in fact; Sendmail won't run when it can't determine the FQDN).
If you don't configure a network card, create a new file /etc/hosts by running:
cat > /etc/hosts << "EOF"
# Begin /etc/hosts (no network card version)
127.0.0.1 www.mydomain.com <value of HOSTNAME> localhost
# End /etc/hosts (no network card version)
EOF
If you do configure a network card, create a new file /etc/hosts containing:
cat > /etc/hosts << "EOF"
# Begin /etc/hosts (network card version)
127.0.0.1 localhost.localdomain localhost
192.168.1.1 www.mydomain.org <value of HOSTNAME>
# End /etc/hosts (network card version)
EOF
Of course, change the 192.168.1.1 and www.mydomain.org to your own liking (or requirements if you are assigned an IP-address by a network/system administrator and you plan on connecting this machine to that network).
This section only applies if you are going to configure a network card. If you're not, skip this section.
Create a new file /etc/init.d/ethnet containing the following:
cat > /etc/init.d/ethnet << "EOF"
#!/bin/sh
# Begin /etc/init.d/ethnet
source /etc/init.d/functions
source /etc/sysconfig/network
case "$1" in
start)
for interface in `ls /etc/sysconfig/network-scripts/ifcfg* | grep -v ifcfg-lo`
do
source $interface
name=`/usr/bin/basename $interface | sed 's/^ifcfg-//g'`
echo -n "Brining up the $name interface..."
/sbin/ifconfig $name $IP broadcast $BROADCAST netmask $NETMASK
evaluate_retval
done
# echo -n "Setting up default route..."
# /sbin/route add default gw $GATEWAY
# evaluate_retval
;;
stop)
for interface in `ls /etc/sysconfig/network-scripts/ifcfg* | grep -v ifcfg-lo`
do
source $interface
name=`/usr/bin/basename $interface | sed 's/^ifcfg-//g'`
echo -n "Brining down the $name interface..."
/sbin/ifconfig $name down
evaluate_retval
done
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
;;
esac
# End /etc/init.d/ethnet
EOF
If you require a default gateway to be setup, uncomment the following three lines in the ethnet script:
# echo -n "Setting up default route..."
# /sbin/route add default gw $GATEWAY
# evaluate_retval
And run the following command:
cat >> /etc/sysconfig/network << "EOF"
GATEWAY=192.168.1.2
EOF
Change GATEWAY to match your network setup.
Which interfaces are brought up and down by the ethnet script depends on the files in the /etc/sysconfig/network-scripts directory. This directory should contain files in the form of ifcfg-x where x is the network interface to be brought up and down like eth0, eth0:1, eth1:2, and so forth.
First create the network-scripts directory by running:
mkdir /etc/sysconfig/network-scripts
Now, create new files in that directory containing the following. Example file names are ifcfg-eth0, ifcfg-eth0:3 and ifcfg-eth1:2
IP=192.168.1.1
NETMASK=255.255.255.0
BROADCAST=192.168.1.255
Of course, change the values of those three variables in every file to match the proper setup. Usually NETMASK and BROADCAST will remain the same, just the IP will change per network interface.
Set the proper file permissions and create the necessary symlink by running the following commands:
cd /etc/init.d &&
chmod 754 ethnet &&
cd ../rc1.d &&
ln -s ../init.d/ethnet K80ethnet &&
cd ../rc2.d &&
ln -s ../init.d/ethnet K80ethnet &&
cd ../rc3.d &&
ln -s ../init.d/ethnet S10ethnet &&
cd ../rc4.d &&
ln -s ../init.d/ethnet S10ethnet &&
cd ../rc5.d &&
ln -s ../init.d/ethnet S10ethnet