Chapter 10. Networking configuration

Table of Contents
10.1. Hardware
10.2. Configuration of interfaces
10.3. Resolving
10.4. IPv4 Forwarding

10.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.

10.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.

10.3. 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.

/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.

10.4. IPv4 Forwarding

IPv4 forwarding connects two or more networks by sending packets which arrive on one interface to another interface. This makes it possible to let a Linux machine act as a router. For example, you can connect your home network with the internet. IPv4 forwarding can be enabled or disabled under Slackware Linux by changing the IPV4_FORWARD variable in /etc/rc.d/rc.inet2. The default setting is as follows:


IPV4_FORWARD=1

This means that IPv4 forwarding is enabled. You can disable forwarding by changing the IPV4_FORWARD value to 0. This setting can be enabled by rebooting the computer. It is also possible to enable IPv4 forwarding on a running system with the following command (0 disables forwarding, 1 enables forwarding):


# echo 0 > /proc/sys/net/ipv4/ip_forward

Be cautious! By default there are no active IP filters. This means that anyone can access other networks. Traffic can be filtered and logged with the iptables kernel packet filter. Iptables can be administrated through the iptables command. NAT (Network Address Translation) is also a subset of iptables, and can be controlled and enabled through the iptables command. NAT makes it possible to "hide" a network behind one IP address. This allows you to use the internet on a complete network with only one IP address.