Basic Ethernet Configuration



Version 2.1a (Debian Slink)

Introduction:


In GNU/Linux, ethernet (network) cards are numbered eth0, eth1 and so on. Thus, if the system has only one ethernet card, it will be eth0; if it has two, they will be eth0 and eth1.

Usually, the driver for the card will have to be compiled from the source code which itself is available either from the ftp/web site of the manufacturer, or some other GNU/Linux site - for example, source for the 3Com  3c5x9 and 3c90x cards is available at http://cesdis.gsfc.nasa.gov. The source is contained in a tar.gz file which you have to download.

Note: This guide assumes you have just added an ethernet card to an already installed/configured GNU/Linux system, and deals only with configuring the actual card. If you are configuring more than one system, you should choose different IP addresses for each system, and different system names. You should also choose a network name. Creating and configuring a small network is covered in the Creating and Configuring a Small Network guide.

Compiling the Driver:

Unpack the source tar file - for example, for the  3Com 3c900 card this is 3c90x.tar.gz so therefore the command to unpack is

tar xzvf   </path-to->/ 3c90x.tar.gz

This will unpack to a new directory containing the source code file(s) and a README which should give the compile command for compiling the driver as module, which is usually what is required (the compile command should also be in the c file itself - in this case, the 3c90x.c file).

cd to the directory containing the source code, and enter the compile command. This will result in a file ending in .o - in our example, 3c90x.o - which is the required driver.
 

Configuration Guide:


1) Make a copy of the driver (e.g. on a floppy disc)

2) Place the driver in /lib/modules/<kernel number>/net

Thus,  if you are using a 2.0.36 kernel, <kernel number> would be 2.0.36

3) Place alias line in /etc/modutils/aliases (e.g. alias eth0 3c90x)

4) Run update-modules

5) Run     insmod     <path-to->/3com90x.o

6) Run     ifconfig     eth0     <chosen IP address>

An example IP address is: 192.168.1.1
 
 

7) If required, run route add -net <gateway address>

You could also run:

route add -net 192.168.1.0 eth0

which means the network 192.168.1.0 is reachable via eth0

and:

route add default gw 192.168.1.1

which defines the route for which/if a specified route is not given.

Important note: The gateway you give must be reachable - or you will get the error message "network unreachable". Also, the address/name given with the route command must exist in /etc/hosts.

Further, if you are just testing the ethernet card, are not yet connected to a network/any other system, or do not have a gateway - i.e. you are just on a LAN - comment out the entries in /etc/init.d/network relating to gateway.

8) Make entries in:

a) /etc/hosts

For example, add:

192.168.1.1     space.time.sys    space    #IP address

You should choose the names yourself. In the above example, space is the short name of the system containing the eth0 card and space.time.sys the full name of the system on the network time.sys

b) /etc/networks

For example:

#/etc/networks for time.com

 stnet1    192.168.1.0    #network address

Note: the name stnet is not important - just needed to distinguish this from other entries such as localnet, and for the routing table.

c) /etc/resolv.conf

For example:

nameserver     192.168.1.1
 

d) /etc/init.d/network

For example:

#! /bin/sh i
fconfig     lo     127.0.0.1
route     add     -net     127.0.0.0
ifconfig     eth0     192.168.1.1
route     add     -net    192.168.1.0
route     add     -net    0.0.0.0    gw    192.168.1.1

or:

#! /bin/sh
ifconfig lo 127.0.0.1
route add -net 127.0.0.0
IPADDR=192.168.1.1
NETMASK=255.255.255.0
NETWORK=192.168.1.0
BROADCAST=192.168.1.255
GATEWAY=192.168.1.1
ifconfig  eth0  ${IPADDR} netmask  ${NETMASK} broadcast  ${BROADCAST}
route     add     -net     ${NETWORK}
[ "${GATEWAY}" ]    &&   route  add  default  gw  ${GATEWAY}  metric 1
 

Notes:

(a) the route is the network address, which itself is the first three parts of the IP address plus a zero;
(b) if there is no gateway (connection to another network via a particular system) then comment out the gateway section. If there is a gateway, then the IP address of the gateway system should be added.

9) Check with ping     <IP address>

[To quit ping, enter Control+c]  If working, it should return number of packets transmitted and received, and 0% packet loss. If not working, you will get network unreachable.

If this happens, try ifconfig  eth0  up
 

10) Add name of module to /etc/modules (e.g. 3c90x)

11) Reboot

12) Running  /sbin/ifconfig  should now return both lo and eth0

If the card was PCI, you can check if the card was detected:

 cat     /proc/pci will return something akin to:

PCI devices found: Bus 0, device 15, function 0:
Ethernet controller: 3Com 3C905B 100bTX (rev 40).
Medium devsel. IRQ 9. Master Capable. Latency=80. Min Gnt=10.Max
Lat=10.
I/O at 0xfc00.
Non-prefetchable 32 bit memory at 0xfedffc00.

13) You can run netstat -i which should return

Iface
MTU ............<etc>
lo
eth0

14) Display the routing table with netstat -rn

An example:

Destination    Gateway   Genmask              Iface
192.168.1.0     0.0.0.0      255.255.255.0        eth0
127.0.0.0         0.0.0.0       255.0.0.0                lo

You can also run /sbin/route which will show the same information except it will give the name of the Destination and Gateway. If there is no gateway, there will be an *
 

Notes:

If after all the above, the "network is unreachable" or other problems arise, check the routing table. If all else fails, one thing to check is the driver - if this has been compiled from source, check the source, then re-compile.



 

Copyleft 1999 by Space-Time Systems. This document is free; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the license, or (at your option) any later version.
This document is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. See the GNU General Public License for more details.
Should you be lacking a copy of this, look at www.gnu.org/copyleft/gpl.html