Friday, March 5, 2010

Configuring NIC interface :

 

When you find that you are not connected to the network, then follow these steps to troubleshoot the problem :

Go to terminal and type :

$ /sbin/ifconfig

You should see this:

etho Link encap:Ethernet HWaddr 00:50:56:85:00:23

inet addr:192.168.0.135 Bcast:192.168.0.255 Mask:255.255.255.0

UP LOOPBACK RUNNING MULTICAST MTU:1500 Metric:1

RX packets:50 error:0 dropped:0 overruns:0 frame:0

TX packets:0 error:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:0

Interrupt:9 Base address:0x1000

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:6 error:0 dropped:0 overruns:0 frame:0

TX packets:6 error:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:0

If you don't see the eth0 line, then Linux did not recognize your NIC, or it is not enabled. Check if the NIC is enabled by entering this command:

$ ifconfig eth0 -- (you can also try: $ ifconfig eth0 up) -- where eth0 is the name of your NIC.

You should see something similar to this outputted:

eth0 Link encap:Ethernet HWaddr 00:A0:CC:24:BA:02

inet addr:192.168.203.2 Bcast:192.168.203.255

Mask:255.255.255.0

UP BROADCAST RUNNING MT:1500 Metric:1 .....

If you don't see the "inet addr..." and "Bcast:..." IP numbers then you need to install a NIC that is supported by your version of Linux (the easiest route for newbies...but costs a few dollars if you don't have one), or go to your NIC's manufacturer's website (or other driver sites) and see if they have a driver for your NIC and version of Linux.

In most of the linux distributions the compiled drivers modules are found in: /lib/modules/kernel-version/ directory .

The modules related to the NIC are present in the location :

/lib/modules/kernel-version/kernel/drivers/net/

(In My case the drivers are located here, it may slightly vary for your distribution)

When you do a `ls` in the above mentioned directory you will see something like this :

Dejavu : /lib/modules/kernel-version/net/# ls

3c501.ko  ewrk3.ko ne.ko 3c503.ko fealnx.ko ni5010.ko 3c505.ko hp100.ko ni52.ko 3c507.ko hp.ko ni65.ko 3c509.ko hp-plus.ko pcnet32.ko 3c515.ko ip_conntrack_amanda.ko ppp_async.ko 8139cp.ko ip_conntrack_ftp.ko ppp_generic.ko 8139too.ko ip_conntrack_h323.ko pppoe.ko 82596.ko ip_conntrack_irc.ko pppox.ko 8390.ko ac3200.ko ip_conntrack_quake3.ko sch_htb.ko amd8111e.ko ip_conntrack_rtsp.ko sch_ingress.ko at1700.ko ip_conntrack_talk.ko sch_sfq.ko b44.ko ip_conntrack_tftp.ko sis900.ko bsd_comp.ko ip_nat_amanda.ko slhc.ko cls_fw.ko ip_nat_cuseeme.ko smc9194.ko ip_conntrack_mms.ko ppp_synctty.ko cls_u32.ko ip_nat_ftp.ko smc-ultra.ko cs89x0.ko ip_nat_h323.ko softdog.ko de4x5.ko ip_nat_irc.ko starfire.ko depca.ko ip_nat_mms.ko sundance.ko 3c59x.ko ip_conntrack_egg.ko ppp_deflate.ko dgrs.ko ip_nat_quake3.ko tlan.ko dmfe.ko ip_nat_rtsp.ko tulip.ko e100.ko ip_nat_talk.ko typhoon.ko e2100.ko ip_nat_tftp.ko via-rhine.ko eepro100.ko lance.ko wd.ko eepro.ko lp486e.ko winbond-840.ko eexpress.ko mii.ko zlib_deflate.ko epic100.ko natsemi.ko zlib_inflate.ko eth16i.ko ne2k-pci.ko

These are the modules for different types of interfaces. For our experiment I'm considering the module of RealTek 8139 chipset based NIC i.e., 8139too.ko

So here I'll be installing driver for RealTek 8139 chipset based NIC.

Go to the directory of the driver:

# cd /lib/modules/kernel-version/kernel/drivers/net/

Then we will install the driver:

CODE

# install -m 644 8139too.ko

Load the driver:

CODE

# /sbin/insmod 8139too.ko ( You can also use modprobe in place of insmod which is a better option).

# depmod -a

CODE

# cd

( come back to the home directory )

CODE

# netconfig

( to configure your networkcard )

CODE

# ifconfig eth0 up

( will put your connection up ) ( ifconfig eth0 down to kill it )

If all went well:

CODE

# netstat -i

( Will show you the ¨eth0¨ and ¨lo¨ )

Now try to ping a welknown host like your ISP or www.google.com

CODE

# ping www.google.com

You should be able to see traffic there and your connection is O.K.

If not, a reboot, after editing your modules.conf ( see next part ) sometimes helps.

Now you still have to edit your modules.conf for the modules to be loaded at boot:

CODE

$ su

< password >

# vim /etc/modules.conf

Goto insert mode by typing 'i' without quotes and insert the below mentioned line.

NOTE: There will already be a few lines in modules.conf, do not change those ! Only add the line:

QUOTE

alias eth0 8139too

and save the file and quit by typing wq

That´s all there is to it folks !

 
Things You Should Know About Linux !!!