5.3 TCP/IP Configuration

At this point, your network card should be physically installed in your computer, and the relevant kernel modules should be loaded. You will not yet be able to communicate over your network card, but information about the network device can be obtained with ifconfig -a.

# ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:A0:CC:3C:60:A4
RX packets:110081 errors:1 dropped:0 overruns:0 frame:0
TX packets:84931 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:114824506 (109.5 Mb) TX bytes:9337924 (8.9 Mb)
Interrupt:5 Base address:0x8400

lo Link encap:Local Loopback
inet addr: Mask:
RX packets:2234 errors:0 dropped:0 overruns:0 frame:0
TX packets:2234 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:168758 (164.8 Kb) TX bytes:168758 (164.8 Kb)

If you just typed /sbin/ifconfig without the -a suffix, you would not see the eth0 interface, as your network card does not yet have a valid IP address or route.

While there are many different ways to setup and subnet a network, all of them can be broken down into two types: Static and Dynamic. Static networks are setup such that each node (geek lingo for thing with an IP address) always has the same IP address. Dynamic networks are setup in such a way that the IP addresses for the nodes are controlled by a single server called the DHCP server.

5.3.1 DHCP

DHCP (or Dynamic Host Configuration Protocol), is a means by which an IP address may be assigned to a computer on boot. When the DHCP client boots, it puts out a request on the Local Area Network for a DHCP server to assign it an IP address. The DHCP server has a pool (or scope) of IP addresses available. The server will respond to this request with an IP address from the pool, along with a lease time. Once the lease time for a given IP address lease has expired, the client must contact the server again and repeat the negotiation.

The client will then accept the IP address from the server and will configure the requested interface with the IP address. There is one more handy trick that DHCP clients use for negotiating the IP address that they will be assigned, however. The client will remember it's last assigned IP address, and will request that the server re-assign that IP address to the client again upon next negotiation. If possible, the server will do so, but if not, a new address is assigned. So, the negotiation resembles the following:

    Client: Is there a DHCP server available on the LAN?
    Server: Yes, there is. Here I am.
    Client: I need an IP address.
    Server: You may take for 19200 seconds.
    Client: Thank you.

    Client: Is there a DHCP server available on the LAN?
    Server:Yes, there is. Here I am.
    Client:I need an IP address. The last time we
    talked, I had;
    May I have it again?
    Server:Yes, you may (or No, you may not: take instead).
    Client: Thank you.

The DHCP client in Linux is /sbin/dhcpcd. If you load /etc/rc.d/rc.inet1 in your favorite text editor, you will notice that /sbin/dhcpcd is called about midway through the script. This will force the conversation shown above. dhcpcd will also track the amount of time left on the lease for the current IP address, and will automatically contact the DHCP server with a request to renew the lease when necessary. DHCP can also control related information, such as what ntp server to use, what route to take, etc.

Setting up DHCP on Slackware is simple. Just run netconfig and select DHCP when offered. If you have more than one NIC and do not wish eth0 to be configured by DHCP, just edit the /etc/rc.d/rc.inet1.conf file and change the related variable for your NIC to “YES”.

5.3.2 Static IP

Static IP addresses are fixed addresses that only change if manually told to. These are used in any case where an administrator doesn't want the IP information to change, such for internal servers on a LAN, any server connected to the Internet, and networked routers. With static IP addressing, you assign an address and leave it at that. Other machines know that you are always at that certain IP address and can contact you at that address always.

5.3.3 /etc/rc.d/rc.inet1.conf

If you plan on assigning an IP address to your new Slackware box, you may do so either through the netconfig script, or you may edit /etc/rc.d/rc.inet1.conf. In /etc/rc.d/rc.inet1.conf , you will notice:

    # Primary network interface card (eth0)

Then further at the bottom:


In this case, our task is merely to place the correct information between the double-quotes. These variables are called by /etc/rc.d/rc.inet1 at boot time to setup the nics. For each NIC, just enter the correct IP information, or put “YES” for USE_DHCP. Slackware will startup the interfaces with the information placed here in the order they are found.

The DEFAULT_GW variable sets up the default route for Slackware. All communications between your computer and other computers on the Internet must pass through that gateway if no other route is specified for them. If you are using DHCP, you will usually not need to enter anything here, as the DHCP server will specify what gateway to use.

5.3.4 /etc/resolv.conf

Ok, so you've got an IP address, you've got a default gateway, you may even have ten million dollars (give us some), but what good is that if you can't resolve names to IP addresses? No one wants to type in into their web browser to reach www.slackbook.org. After all, who other than the authors would memorize that IP address? We need to setup DNS, but how? That's where /etc/resolv.conf comes into play.

Chances are you already have the proper options in /etc/resolv.conf. If you setup your network connection using DHCP, the DHCP server should handle updating this file for you. (Technically the DHCP server just tells dhcpcd what to put here, and it obeys.) If you need to manually update your DNS server list though, you'll need to hand edit /etc/resolv.conf. Below is an example:

# cat /etc/resolv.conf
search lizella.net

The first line is simple. The nameserver directive tells us what DNS servers to query. By necessity these are always IP addresses. You may have as many listed there as you like. Slackware will happily check one after the other until one returns a match.

The second line is a little more interesting. The search directive gives us a list of domain names to assume whenever a DNS request is made. This allows you to contact a machine by only the first part of its FQDN (Fully Qualified Domain Name). For example, if “slackware.com” were in your search path, you could reach http://store.slackware.com by just pointing your web browser at http://store.

# ping -c 1 store
PING store.slackware.com ( 56 data bytes
64 bytes from : icmp_seq=0 ttl=64 time=0.251 ms
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 0.251/0.251/0.251 ms

5.3.5 /etc/hosts

Now that we've got DNS working fine, what if we want to bypass our DNS server, or add a DNS entry for a machine that isn't in DNS? Slackware includes the oft-loved /etc/hosts file which contains a local list of DNS names and IP addresses they should match to.

# cat /etc/hosts           localhost  locahost.localdomain       redtail        foobar.slackware.com

Here you can see that localhost has an IP address of (always reserved for localhost), redtail can be reached at, and foobar.slackware.com is