Sunday, May 4, 2008

Configuring your network card

To configure an Ethernet interface on Debian the first thing to do is knowing whether the current kernel includes the support for your card or not. To know which kernel you are using, just type:
$ uname -r

Now that you know the current kernel version you need to find more details about your network card, so it's a common rule using the lspci tool. It's contained in the pciutils package, available with apt-get. Once you've installed it, execute from a terminal:
$ lspci -v | grep -i Eth
the output will be similar to this:
00:11.0 Ethernet controller: VIA Technologies, Inc. VT6102 [Rhine-II] (rev 42)

it indicates you the chipset ( VT6102 ), model (Rhine-II) e manifacturer (VIA Technologies, Inc.) for your network card.

At this point just search on GOOGLE a part of the previous command adding in the search key words such as modprobe or module, to be more concrete just search on google something like "Via-Rhine module" or "Via-Rhine modprobe" so you can immediately undestand the module (driver) name to be loaded by the user to make the kernel enable you card (usually the support will get the name ethn, where "n" is a number starting from zero indicating the quantity of ethernet cards installed on the machine).

I want to do things well, here are other examples from wubby, vicius e weezip's network cards. They provided this information:
$ lspci -v | grep -i Eth
0000:00:0a.0 Ethernet controller: 3Com Corporation 3c940 10/100/1000Base-T [Marvell] (rev 12)
chipset ( 3c940 ), model ( Marvell ) and manifacturer ( 3Com Corporation.).
Searching on google: "3c94 module" or "3c94 modprobe" you can easily see it's possible to choose one of these modules: skge and sk98lin, they can exist together but skge is more recent.

$ lspci -v | grep -i Eth
0000:00:0d.0 Ethernet controller: D-Link System Inc RTL8139 Ethernet (rev 10)
chipset ( RTL8139 ), model (unknown) and manifacturer ( D-Link System Inc. ).
Searching on google: "RTL8139 module" or "RTL8139 modprobe" you find the module is 8139too.

$ lspci -v | grep -i Eth
0000:00:0a.0 Ethernet controller: Intel Corporation 82557/8/9 [Ethernet Pro 100] (rev 0c)
chipset ( 82557/8/9 ), model ( Ethernet Pro 100 ) and manifacturer ( Intel Corporation ).
Searching on google: "82557 module" or "82557 modprobe" you find this module eepro100.

$ lspci -v | grep -i Eth
00:04.0 Ethernet controller: Silicon Integrated Systems [SiS] SiS900 PCI Fast Ethernet (rev 91)
chipset ( SiS900 ), model ( SiS900 PCI Fast Ethernet ) and manifacturer ( Silicon Integrated Systems ).
Searching on google: "sis900 module" or "sis900 modprobe" you find sis900.

$ lspci -v | grep -i Eth
0000:00:0c.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL-8139/8139C/8139C+ (rev 10)
chipset ( Realtek ), model ( RTL-xxxx ) and manifacturer ( Realtek Semiconductor Co. ).
Searching on google: "module RTL-8139/8139C/8139C+" or "RTL-8139/8139C/8139C+ modprobe" the module is 8139too.

$ lspci -v | grep -i Eth
0000:00:0d.0 Ethernet controller: MYSON Technology Inc SURECOM EP-320X-S 100/10M Ethernet PCI Adapter

chipset ( Myson ), model ( EP-320X-S ) and manifacturer ( MYSON Technology Inc ).
Searching on google: "module EP-320X-S 100/10M" or "modprobe EP-320X-S 100/10M" you find this module: fealnx.
In relation to these examples which are referred to network cards common used nowadays, I can say the module's name is almost very similar to the chipset's name.

Let's go on...

If you have only one network cards phisically connected to your motherboard almost surely your device will be /dev/eth0.

The files in /dev aren't real files (or, they are, but "special"). They are characterised by two number, the major and the minor number which identify them to the kernel. The kernel as to find a driver to handle them.

Once you've found your module's name you can continue reading :)

By using from a root terminal the "modprobe" command you can load the module
$ modprobe module_name

To verify it's loaded:
$ lsmod | grep module_name
if nothing appears the module isn't loaded, otherwise it's ready to be used.

To list which network modules are available:
$ modprobe -l | grep net | grep driver

with dmesg (used to print kernel messages) and this syntax:
$ dmesg | grep eth
you can see if your module has been recognized, if it's the right one and compatible with your hardware.

Most common error:
FATAL: Module module_name not found.

The module doesn't exist, probably you made a mistake during typing, make sure you typed the correct name. If the same error occurs the module you are trying to load it's not present in the kernel, there is only one solution, that is recompiling the kernel adding the interesting module. If you have such a bad luck, I can only give you this link: Compiling the kernel with the Debian way.

If your card isn't supported I suggest you seeing HERE and HERE to help you buying the safest products for compatibility.

Recognized and ready to be used, now there are two ways to configure it:

* 1. through the assignment of a static IP;
* 2. by using a DHCP server.

Both cases are described here:

1. Configuration through a static IP
1) With root privileges edit /etc/network/interfaces and add the red parts:
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address # (IP address)
netmask # (netmask)
gateway # (gateway)
network # (start of the network)
broadcast # (broadcast IP)
change the IP addresses used above according to your needs, and save..

2) A fast alternative consists in this: directly indicate everything by the command line this way:
$ ifconfig eth0 netmask up
$ route add default gw

In both cases enable your network interface:
$ ifup eth0

and to stop it:
$ ifdown eth0

this command:
$ ifconfig eth

Show a summary of the current state so you can immediately see if the Ethernet is configured and active.
Now it's very important to add the DNS in /etc/resolv.conf , just type as root:
$ echo "nameserver" > /etc/resolv.conf

$ echo "nameserver" >> /etc/resolv.conf

again, replace the IP addresses with the yours.
If your ISP doesn't release DNS servers it's common rule to set yor gateway as a DNS server.

2. Configuring with a DHCP server

If in the router or elsewhere a DHCP server is preconfigured to assign IPs from the inside on your net:

1) edit with root privileges /etc/network/interfaces and write down the red parts:
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

Test the network to find errors:
$ ping tuo_ip_eth0
$ ping tuo_gateway
$ ping
$ ping

In order to automatically load your ethernet card's module at boot time insert its name into /etc/modules, with
$ echo module_name >> /etc/modules

Ok, now make sure the network service will be automatically enabled with this command:
$ update-rc.d -f networking defaults

Further notes:
motan23 reports us the D-Link 302T modem provided by various Italian ISP works regularly if connected to the Ethernet interface with some adjustment listed here:
- the network must be configured with a static IP (dhcp doesn't work);
- in the network configuration the gateway must not be specified
so recapitulating /etc/network/interfaces should be like this:
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static

for now it's all :)

No comments: