Tuesday, October 25, 2011

DHCPDISCOVER, DHCPOFFER, DHCPREQUEST, REPEAT

Upon installation of the new network card, I figured it would be pretty easy going given the reviews online specifically for FreeNAS. But for some reason, I was having trouble getting an IP address. And whenever it did, it would loose it when rebooted for what seemed like 24 hours before I could get another one. Even configuring a static IP did the same thing. Weird.

I checked everything on my router and it seemed fine.
Again, this is where consulting the FreeBSD documentation came in handy. I learned two important command-line commands for trouble shooting this problem:
dhclient
ifconfig

Using these, I was able to log into the shell and configure the network adapter manually and monitor the responses.

dhclient did this:
DHCPDISCOVER some junk
DHCPDISCOVER some junk
DHCPDISCOVER some junk
DHCPOFFER from host junk
DHCPREQUEST some junk

Then it would repeat until I unplugged the cable to get it to stop.

According to this, my FreeNAS was finding the DHCP server, getting an offer, requesting it, but not being acknowledged and went back to looking for a DHCP server. Strange.

And being I already troubleshot the router, it became apparent that it was my new gigabit network card that was suspect.

Checking the hardware documentation (remember that from a previous post?) it said that the re(4) driver would cover the RTL811xS chipset. Mine was coming up as re(0). I didn't know what that meant, if my network adapter was being recognized differently. But I was starting to think this might be the problem: FreeBSD drivers for my hardware.

I went to the Realtek website and found they had drivers for FreeBSD. That being said, I thought, I'll try it and see if it works.

I downloaded the tarball, saved it to a usb drive, then stuck it in my FreeNAS box and booted it up. This is when I discovered that mounting a usb drive in FreeBSD is different than other Linux flavors. For FreeBSD you have to use mount_msdosfs. Then you'd mount it just as you would in any other Linux distribution.

Once mounted, I checked the tarball to see what was in it:
rtl_bsd_drv/if_re.c
rtl_bsd_drv/if_re.h
rtl_bsd_drv/Makefile
rtl_bsd_drv/Readme.txt

I then extracted the source code (the .c file), the header file (the .h file), the Makefile, and the readme to the FreeNAS file system. To read the Readme, I copied it back to the usb drive and opened it on my Windows 7 machine. Blank.

Darn it all.

Explaining this all to a co-worker the next day, he told me about VI. Just search it in Google.

Using the command: vi readme.txt I was able to open it and read it. The text that follows is from the Readme.txt for the driver:

This driver is modified by Realtek Semiconductor corp. and it has been tested OK on FreeBSD v5.4, FreeBSD v6.4, FreeBSD v7.3, and FreeBSD v8.0. To update the driver, you may use method 1. If method 1 failed, you must use method 2 which is more complex.

Method 1:
1.Copy if_re.ko in "modules" directory to "/modules" directory and overwrite the existing file.

2.Modify the file"/boot/defaults/loader.conf" and set "if_re_load" in "Network driver" section to "Yes"

3.Reboot.

Method 2:
Because the FreeBSD kernel has default drivers to support RTL8139C and RTL8169S. To use the RTL8139C+, RTL8169SB, RTL8169SC, RTL8168B, and RTL8101E, you need to update your NIC driver by recompiling your FreeBSD kernel.

The main steps you have to do:(FreeBSDSrcDir means the directory of FreeBSD source code and it may be "/usr/src/sys")

1. keep the original driver source code:

# cd /usr/src/sys/dev/re
# cp if_re.c if _re.c.org
# cd /usr/src/sys/modules
# cp Makefile Makefile.org
# cd /usr/src/sys/modules/re
# cp Makefile Makefile.org
# cd /usr/src/sys/i386/conf/
# cp GENERIC GENERIC.org

2. Recompile your kernel (you must install your FreeBSD souce code first!!)

# vim /usr/src/sys/i386/conf/GENERIC/ and delete re
# vim /usr/src/sys/modules/Makefile and delete re
# cd /usr/src/sys/i386/conf
# /usr/sbin/config GENERIC

(for FreeBSD 5.x/6.x/7.x/8.x)
# cd ../compile/GENERIC
(for FreeBSD 4.x)
# cd ../../compile/GENERIC

# make depend
# make
# make install
# reboot

3.update the driver source code:

Copy the driver source code ( if_re.c and if_rereg.h) into /usr/src/sys/dev/re

Copy the Makefile into /usr/src/sys/modules/re

4. build the driver:

# cd /usr/src/sys/modules/re
# make clean
# make
# cdif

5. install the driver

# cd /usr/src/sys/modules/re
# kldload ./if_re.ko

6. configurate the static IP address

# ifconfig re0 xxx.xxx.xxx.xxx

7. configurate the IP address by DHCP

# /sbin/dhclient re0

The user can use the following command to change link speed and duplexmode.

1. For auto negotiation,

# ifconfig re media autoselect

2. For 1000Mbps full-duplex,

# ifconfig re media 1000baseTX mediaopt full-duplex

3. For 100Mbps full-duplex,

# ifconfig re media 100baseTX mediaopt full-duplex

4. For 100Mbps half-duplex,

# ifconfig re media 100baseTX -mediaopt full-duplex

5. For 10Mbps full-duplex,

# ifconfig re media 10baseT/UTP mediaopt full-duplex

6. For 10Mbps half-duplex,

# ifconfig re media 10baseT/UTP -mediaopt full-duplex

No comments:

Post a Comment