Chapter 2. Basic networking configuration

Table of Contents
2.1. Hardware
2.2. Configuration of interfaces
2.3. Configuration of interfaces (IPv6)
2.4. Resolving

2.1. Hardware

Network cards (NICs)

Drivers for NICs are installed as kernel modules. The module for your NIC has to be loaded during the initialization of Slackware. On most systems the NIC is automatically detected and configured during the installation of Slackware Linux. You can reconfigure your NIC with the netconfig command. netconfig adds the driver (module) for the detected card to /etc/rc.d/rc.netdevice.

It is also possible to manually configure which modules should be loaded during the initialization of the system. This can be done by adding a modprobe line to /etc/rc.d/rc.modules. For example, if you want to load the module for 3Com 59x NICs (3c59x.o), add the following line to /etc/rc.d/rc.modules


/sbin/modprobe 3c59x

PCMCIA cards

Supported PCMCIA cards are detected automatically by the PCMCIA software. The pcmcia-cs packages from the "a" diskset provides PCMCIA functionality for Slackware Linux.

2.2. Configuration of interfaces

Network cards are available under Linux through so-called "interfaces". The ifconfig(8) command can be used to display the available interfaces:


# ifconfig -a
eth0      Link encap:Ethernet  HWaddr 00:20:AF:F6:D4:AD  
          inet addr:192.168.1.1  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1301 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1529 errors:0 dropped:0 overruns:0 carrier:0
          collisions:1 txqueuelen:100 
          RX bytes:472116 (461.0 Kb)  TX bytes:280355 (273.7 Kb)
          Interrupt:10 Base address:0xdc00 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:77 errors:0 dropped:0 overruns:0 frame:0
          TX packets:77 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:8482 (8.2 Kb)  TX bytes:8482 (8.2 Kb)

Network cards get the name ethn, in which n is a number, starting with 0. In the example above, the first network card (eth0) already has an IP address. But unconfigured interfaces have no IP address, the ifconfig will not show IP addresses for unconfigured interfaces. Interfaces can be configured in the /etc/rc.d/rc.inet1.conf file. You can simply read the comments, and fill in the required information. For example:


# Config information for eth0:
IPADDR[0]="192.168.1.1"
NETMASK[0]="255.255.255.0"
USE_DHCP[0]=""
DHCP_HOSTNAME[0]=""

In this example the IP address 192.168.1.1 with the 255.255.255.0 netmask is assigned to the first ethernet interface (eth0). If you are using a DHCP server you can change the USE_DHCP="" line to USE_DHP[n]="yes" (swap "n" with the interface number). Other variables, except DHCP_HOSTNAME are ignored when using DHCP. For example:


IPADDR[1]=""
NETMASK[1]=""
USE_DHCP[1]="yes"
DHCP_HOSTNAME[1]=""

The same applies to other interfaces. You can activate the new settings by rebooting the system or by executing /etc/rc.d/rc.inet1.

2.3. Configuration of interfaces (IPv6)

2.3.1. Introduction

IPv6 is the next generation internet protocol. One of the advantages is that it has a much larger address space. In IPv4 (the internet protocol that is commonly used today) addresses are 32-bit, this address space is almost completely used right now, and there is a lack of IPv4 addresses. IPv6 uses 128-bit addresses, which provides an unimaginable huge address space (2^128 addresses). IPv6 uses another address notation, first of all hex numbers are used instead of decimal numbers, and the address is noted in pairs of 16-bits, separated by a colon (":"). Let's have a look at an example address:


fec0:ffff:a300:2312:0:0:0:1

A block of zeroes can be replaced by two colons ("::"). Thus, thee address above can be written as:


fec0:ffff:a300:2312::1

Each IPv6 address has a prefix. Normally this consists of two elements: 32 bits identifying the address space the provider provides you, and a 16-bit number that specifies the network. These two elements form the prefix, and in this case the prefixlength is 32 + 16 = 48 bits. Thus, if you have a /48 prefix you can make 2^16 subnets and have 2^80 hosts on each subnet. The image below shows the structure of an IPv6 address with a 48-bit prefix.

Figure 2-1. The anatomy of an IPv6 address

There are a some specially reserved prefixes, most notable include:

Table 2-1. Important IPv6 Prefixes

PrefixDescription
fe80::Link local addresses, which are not routed.
fec0::Site local addresses, which are locally routed, but not on or to the internet.
2002::6to4 addresses, which are used for the transition from IPv4 to IPv6.

2.3.2. Slackware IPv6 support

The Linux kernel binaries included in Slackware Linux do not support IPv6 by default, but support is included as a kernel module. This module can be loaded using modprobe:


# modprobe ipv6

You can verify if IPv6 support is loaded correctly by looking at the kernel output using the dmesg:


$ dmesg
[..]
IPv6 v0.8 for NET4.0

IPv6 support can be enabled permanently by adding the following line to /etc/rc.d/rc.modules:


/sbin/modprobe ipv6

Interfaces can be configured using ifconfig. But it is recommended to make IPv6 settings using the ip command, which is part of the "iputils" package that can be found in the extra/ directory of the Slackware tree.

2.3.3. Adding an IPv6 address to an interface

If there are any router advertisers on a network there is a chance that the interfaces on that network already received an IPv6 address when the IPv6 kernel support was loaded. If this is not the case an IPv6 address can be added to an interface using the ip utility. Suppose we want to add the address "fec0:0:0:bebe::1" with a prefix length of 64 (meaning "fec0:0:0:bebe" is the prefix). This can be done with the following command syntax:


# ip -6 addr add <ip6addr>/<prefixlen> dev <device>

For example:


# ip -6 addr add fec0:0:0:bebe::1/64 dev eth0

2.4. Resolving

Hostname

Each computer on the internet has a hostname. If you do not have a hostname that is resolvable with DNS, it is still a good idea to configure your hostname, because some software uses it. You can configure the hostname in /etc/HOSTNAME. A single line with the hostname of the machine will suffice. Normally a hostname has the following form: host.domain.tld, for example darkstar.slackfans.org. Be aware that the hostname has to be resolvable, meaning that Linux should be able to convert the hostname to an IP address. You can make sure the hostname is resolvable by adding it to /etc/hosts. Read the following section for more information about this file.

/etc/hosts

/etc/hosts is a table of IP addresses with associated hostnames. This file can be used to name computers in a small network. Let's look at an example of the /etc/hosts file:


127.0.0.1       	localhost
192.168.1.1             tazzy.slackfans.org tazzy
192.168.1.2             gideon.slackfans.org

The localhost line should always be present. It assigns the name "localhost" to a special interface, the loopback. In this example the names "tazzy.slackfans.org" and "tazzy" are assigned to the IP address 192.168.1.1, and the name "gideon.slackfans.org" is assigned to the IP address 192.168.1.2. On the system with this file both computers are available via the mentioned hostnames.

It is also possible to add IPv6 addresses, which will be used if your system is configured for IPv6. This is an example of a /etc/hosts file with IPv4 and IPv6 entries:


# IPv4 entries
127.0.0.1               localhost
192.168.1.1             tazzy.slackfans.org tazzy
192.168.1.2             gideon.slackfans.org

# IPv6 entries
::1			localhost
fec0:0:0:bebe::2	flux.slackfans.org	

Please note that "::1" is the default IPv6 loopback.

/etc/resolv.conf

The /etc/resolv.conf file is used to specify which nameservers the system should use. A nameserver converts hostnames to IP addresses. Your provider should have given you at least two name name server addresses (DNS servers). You can add these nameservers to /etc/resolv.conf by adding the line "nameserver ipaddress" for each nameserver. For example:


nameserver 192.168.1.1
nameserver 192.168.1.69

You can check wether the hostnames are tranlated correctly or not with the host hostname command. Swap "hostname" with an existing hostname, for example the website of your internet service provider.