Next Previous Contents

9. Setting up basic networking

9.1 Installing Netkit-base

./configure
make; make install
cd etc.sample; cp services protocols /etc
mv /usr/bin/ping /bin
 

9.2 Installing Net-tools

make; make install
mv /usr/bin/netstat /bin
cd /usr/sbin; mv ifconfig route /sbin
 

Creating the /etc/init.d/localnet bootscript

#!/bin/sh
# Begin /etc/init.d/localnet
 
check_status()
{
  if [ $? = 0 ]
  then
    echo "OK"
  else
    echo "FAILED"
  fi
}
 
echo -n "Setting up loopback device..."
/sbin/ifconfig lo 127.0.0.1
check_status
 
echo -n "Setting up hostname..."
/bin/hostname --file /etc/hostname
check_status
 
# End /etc/init.d/localnet
 

Setting up permissions and symlink

Creating the /etc/hostname file

Create a new file /etc/hostname and put the hostname in it. This is not the FQDN (Fully Qualified Domain Name). This is the name you wish to call your computer in a network.

Creating the /etc/hosts file

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:

<myip> 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 me.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).

Here's the /etc/hosts file if you don't configure a network card:

# Begin /etc/hosts (no network card version)
127.0.0.1 me.lfs.org <contents of /etc/hostname> localhost
# End /etc/hosts (no network card version)
 

Here's the /etc/hosts file if you do configure a network card:

# Begin /etc/hosts (network card version)
127.0.0.1 localhost
192.168.1.1 me.lfs.org <contents of /etc/hostname>
# End /etc/hosts (network card version)
 

Of course, change the 192.168.1.1 and me.lfs.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).

Creating the /etc/init.d/ethnet file

This sub section only applies if you are going to configure a network card. If not, skip this sub section and read on.

Create a new file /etc/init.d/ethnet containing the following:

#!/bin/sh
# Begin /etc/init.d/ethnet
 
check_status()
{
  if [ $? = 0 ]
  then
    echo "OK"
  else
    echo "FAILED"
  fi
}
 
/sbin/ifconfig eth0 <ipaddress>
check_status
 
# End /etc/init.d/ethnet
 

Setting up permissions and symlink for /etc/init.d/ethnet

Testing the network setup

ping <your FQDN>
ping <what you choose for hostname>
ping localhost
ping 127.0.0.1
ping 192.168.1.1 (only when you configured your network card)
 

All these five ping command's should work without failures. If so, the basic network is working.

9.3 Testing the system

Now that all software has been installed, bootscripts have been written and the local network is setup, it's time for you to reboot your computer and test these new scripts to verify that they actually work. You first want to execute them manually from the /etc/init.d directory so you can fix the most obvious problems (typos, wrong paths and such). When those scripts seem to work just fine manually they should also work during a system start or shutdown. There's only one way to test that. Shutdown your system with shutdown -r now and reboot into LFS. After the reboot you will have a normal login prompt like you have on your normal Linux system (unless you use XDM or some sort of other Display Manger (like KDM - KDE's version of XDM).

At this point your basic LFS system is ready for use. Everything else that follows now is optional, so you can skip packages at your own discretion. But do keep in mind that if you skip packages (especially libraries) you can break dependencies of other packages. For example, when the Lynx browser is installed, the zlib library is installed as well. You can decide to skip the zlib library, but this library isn't used by Lynx alone. Other packages require this library too. The same may apply to other libraries and programs.


Next Previous Contents