CLASS="sect1" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" >

3. Using the USB interface instead of an ethernet card

3.1. USB CDCEther

If you wish to use the USB interface to accept data you will need USB subsystem support in your kernel, whether USB-ohci, USB-ehci, or whichever USB host controller driver type your system prefers. For a more in-depth discussion of this, I direct you to the Linux-USB project site.

Assuming you have USB subsystem support, to find out if your kernel supports the CDCEther (Communications Device Class Ethernet) driver as a module, in a shell, issue the command lsmod as root.

You should see output similar to the following, though a number of entries have been edited, and you shouldn't worry too much if you don't see the exact entries displayed here:


CDCEther               11040   0  (unused)
usb-ohci               17888   0  (unused)
usbcore                56768   1  [scanner CDCEther usb-ohci]

If you don't see CDCEther listed among the modules try loading the module directly:

 #  modprobe CDCEther 

If all goes well you should see the following message in your system log files, or with dmesg:


Mar  2 11:00:52 K7 kernel: CDCEther.c: 0.98.6 7 Jan 2002 Brad Hards and another
Mar  2 11:00:52 K7 kernel: usb.c: registered new driver CDCEther

If you don't have it compiled as a module, check the output of dmesg (you may need to pipe it through 'less' or 'more' like so: dmesg | less); if the driver loads as a module you will see a message similar to the above at boo- up. If not, and you want to use the USB conduit of this device, you will need to recompile your kernel to support it. You will need the 2.4.3 kernel or later. For detailed instructions on recompiling your kernel, I direct you to the Kernel-HOWTO. The options shown next will need to be selected. As an aside, you should be aware that compiling things as modules, rather than statically within the kernel, gives you a greater degree of control and greatly simplifies troubleshooting.

3.1.1. Kernel Requirements

In addition to the 'TCP/IP networking' listed in Section 2, the following should be compiled in your kernel in the 'USB support' menu (assuming you are using menuconfig):

  • USB support

  • USB Communication Class Ethernet device support

3.1.2. Grabbing the Correct Interface

Now we have to select the correct ethernet interface (/dev/ethX) to be the receipient of the DHCP service. If you run ifconfig as root you get a list of open devices:

eth0 Link encap:Ethernet HWaddr 00:D0:09:DE:D4:6F
	inet addr:192.168.1.1
	Bcast:192.168.1.255 Mask:255.255.255.0
	BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
	RX packets:0 errors:0 dropped:0 overruns:0 frame:0
	TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 
	collisions:0 txqueuelen:100
	RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) Interrupt:12 Base address:0xc400

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:5168 errors:0 dropped:0 overruns:0 frame:0
	TX packets:5168 errors:0 dropped:0 overruns:0 carrier:0
	collisions:0 txqueuelen:0 
	RX bytes:1695104 (1.6 MiB)  TX bytes:1695104 (1.6 MiB)

...where eth0 is a standard NIC, pre-configured to the IP address 192.168.1.1.

Note the HWaddr field, or hardware address, on the first line. This is the same as the MAC, or Media Access Control address, and is how we will specify the interface for each action. If you are running a Debian system, you can alter the /etc/network/interfaces file to look like this:


	# /etc/network/interfaces -- configuration file for ifup(8), ifdown(8)
	# The loopback interface
	auto lo
	iface lo inet loopback
	auto eth0
 	iface eth0 inet static
	address 192.168.1.1
	netmask 255.255.255.0
	network 192.168.1.0
	hwaddress ether 00:D0:09:DE:D4:6F
	
	auto eth1
	iface eth1 inet dhcp
	hwaddress ether 00:04:BD:DE:42:0B

The auto eth0 and auto eth1 are required to have the interfaces configured at bootup. Note that some versions of dhcp clients by default always grab eth0 for the dhcpc interface. So even after doing all the above, unless you specifically run /sbin/dhcpcd-bin eth1 it won't work. The easy way to do this at boot-up is to make an init script to load the dhcp address to the correct interface. For most distributions, such a script is in /etc/rc.d or a similar location. If you have an rc.local script, as in Slackware, you can simply add /sbin/dhclient to the end of the file. If you have a model rc.d script (such as /etc/init.d/skeleton in Debian) you can convert that to such a purpose. Whatever the case (either at the command line manually or appended to an init script), the command to run is as follows:

# ifconfig ethX hw ether 00:D0:09:DE:D4:6F up 

You can confirm it worked by calling ifconfig without options after your next reboot.