Create a new file /etc/init.d/localnet containing the following:
#!/bin/sh
# Begin /etc/init.d/localnet
. /etc/init.d/functions
. /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
Set the proper file permissions and create the necessary symlink by running the following commands:
root:~# cd /etc/init.d
root:init.d# chmod 744 /etc/init.d/localnet
root:init.d# cd ../rcS.d
root:rcS.d# ln -s ../init.d/localnet S03localnet
Create a new file /etc/hostname and put the hostname in it by running:
root:~# 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 containing:
# Begin /etc/hosts (no network card version)
127.0.0.1 www.linuxfromscratch.org <value of HOSTNAME> localhost
# End /etc/hosts (no network card version)
If you do configure a network card, create a new file /etc/hosts containing:
# Begin /etc/hosts (network card version)
127.0.0.1 localhost
192.168.1.1 www.linuxfromscratch.org <value of HOSTNAME>
# End /etc/hosts (network card version)
Of course, change the 192.168.1.1 and www.linuxfromscratch.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:
#!/bin/sh
# Begin /etc/init.d/ethnet
. /etc/init.d/functions
. /etc/sysconfig/network
case "$1" in
start)
echo -n "Bringing up the eth0 interface..."
/sbin/ifconfig eth0 $IPADDR broadcast $BROADCAST netmask $NETMASK
evaluate_retval
;;
stop)
echo -n "Bringing down the eth0 interface..."
/sbin/ifconfig eth0 down
evaluate_retval
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
;;
esac
# End /etc/init.d/ethnet
Edit the /etc/sysconfig/network file and add the following lines to it. Don't remove the HOSTNAME= line.
IPADDR=192.168.1.1
NETMASK=255.255.255.0
BROADCAST=192.168.1.255
Chagne the IPADDR, NETMASK and BROADCAST values to match your network setup.
Set the proper file permissions and create the necessary symlink by running the following commands:
root:~# cd /etc/init.d
root:init.d# chmod 744 /etc/init.d/ethnet
root:init.d# cd ../rc1.d
root:rc1.d# ln -s ../init.d/ethnet K90ethnet
root:rc1.d# cd ../rc2.d
root:rc2.d# ln -s ../init.d/ethnet K90ethnet
root:rc2.d# cd ../rc3.d
root:rc3.d# ln -s ../init.d/ethnet S10ethnet
root:rc3.d# cd ../rc4.d
root:rc4.d# ln -s ../init.d/ethnet S10ethnet
root:rc4.d# cd ../rc5.d
root:rc5.d# ln -s ../init.d/ethnet S10ethnet