Connecting a cable modem using USB interface under Linux


Written by: Jess Portnoy

Published under GFDL liecence (available at http://www.gnu.org/copyleft/fdl.html)

For remarks or questions: jess@actcom.net.il, jess@cables.org.il

An updated version of this guide can be downloaded at: http://www.freewebs.com/linuxnet/guidesList.html

Preface:

  1. This guide aims to instruct those who don't have any special background in Linux and networking as well as experienced users and therefore attempts to explain everything in great detail. Still, it is impossible to explain all discussed terms and commands with appropriate detail in such a brief guide. For further guidance, it is recommended to use the list of links in the ending section.

  2. The described procedure was attempted (successfully) using RedHat, kernel 2.4.18 and Terayon tj715 and Motorola SurfBoard 4200 cable modems. It should suit all cable modems currently available and all Linux kernels starting from version 2.4.3.

  3. For the benefit of comfortable reading, all commands outputs are marked in green, Italic font.

  4. All commands used here are shell commands, while implementing the instructions it's recommended to work in superuser mode (e.g: root).

  5. A Hebrew version of this guide can be obtained at: http://www.guides.co.il/download.php?guide=40

  6. If you have an Ethernet adapter attached to your PC it's preferable to use it to connect the modem, it is not only simpler but much more reliable. In order to connect the modem to the Ethernet interface, just connect the modem to the Ethernet port in your PC using the cable supplied with your modem (RJ45 non-crossable) and set your Ethernet interface (ethx) bootproto as DHCP, you can do this using your distribution's suitable UI interface (e.g: netconfig in RedHat, netconf in Mandrake) or by editing the appropriate file manually, for example in RedHat, the file path is: /etc/sysconfig/network-scripts/ifcfg-ethx

    where x is a number, to determine your eth interface ID use the command ifconfig, the first Ethernet adapter is eth0.


Here is an example of a ifcfg-eth file content:


DEVICE=ethx

ONBOOT=yes

BOOTPROTO=dhcp


If you do not have an Ethernet adapter or your Ethernet adapter is currently in use, please continue.


Needed dependencies for connecting the modem in USB interface:


  1. Kernel USB support.

    To make sure you have it type the command lsmod

    the output should be similar to the following lines:

usb-ohci               20768   0  (unused
usbcore 73152 1 [acm usb-ohci]

    it may also read usb-ehci instead of usb-ohci depending on the USB Host Controller your system is using.

  1. You will also need the CDCEther (Communication Device Class Ethernet) module. This module should also be listed in the lsmod output as following:


CDCEther               11104   1
of course you will see other lines as well in accordance to the other modules you have running.

    Note: users who work with kernel version 2.6.x should use the usbnet module replacing the CDCEther module. This input was given to me by Serge Apollon (thank you Serge).

    If you don't see the line CDCEther but you do have USB support as mentioned above, try to use the command modprobe CDCEther, if you get an output similar to this the command ended successfully:



june  4 20:14:12 K7 kernel: CDCEther.c: 0.98.6 7 Jan 2002 Brad Hards and another
june 4 20:14:12 K7 kernel: usb.c: registered new driver CDCEther

    if the module is not compiled, you'll need to recompile your kernel to support it, remember you need kernel version 2.4.3 or higher.

    It is highly recommended you use the last stable kernel version which can be downloaded from the site www.kernel.org.

    For explanations about the compilation process please refer to the list of links supplied in this guide.

  1. Kernel requirements:

In addition to TCP/IP networking, you must compile the following (listed under USB support, assuming you're using menuconfig for configuration):


USB support

USB Communication Class Ethernet device support


Configuration:


Assuming your system answers to all the requirements listed and the CDCEther module is running, you need only to write a configuration file for the right ethx, when x is a number as described in the beginning of this guide. If you have no Ethernet adapters it will be eth0, if you have one Ethernet adapter it will be eth1 and so on. You can see all interfaces currently configured in the ifconfig output.


Here is an example of such output:


eth0 Link encap:Ethernet HWaddr 00:E0:40:A2:01:16

inet addr:192.168.1.2 Bcast:192.168.1.255 Mask:255.255.255.0

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

RX packets:28003 errors:0 dropped:0 overruns:0 frame:0

TX packets:27510 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:100

RX bytes:11069246 (10.5 Mb) TX bytes:2838958 (2.7 Mb)

Interrupt:3 Base address:0xe400


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:12 errors:0 dropped:0 overruns:0 frame:0

TX packets:12 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:0

RX bytes:856 (856.0 b) TX bytes:856 (856.0 b)



As we can see, eth0 is a regular Ethernet NIC, lo always means loopback, so our cable modem interface will be eth1.


As mentioned in the preface, we're using RedHat for this guide, the procedure may vary a little in different distributions, for assistance refer to the documentation in your distribution's site.

The file to edit will be called ifcfg-eth1, located in /etc/sysconfig/network-scripts/


Here is the content of the ifcfg-eth1 file:


DEVICE=eth1 #Device name

ONBOOT=yes #load at boot

BOOTPROTO=dhcp #sets the device to receive an IP from DHCP server


after editing the file and saving it, you must initialize it using the following command: ifup eth1

then run ifconfig and make sure you get an output similar to this:


eth1 Link encap:Ethernet HWaddr 00:E0:6F:25:A1:8B

inet addr:192.168.100.33 Bcast:192.168.255.255 Mask:255.255.255.0

UP BROADCAST NOTRAILERS RUNNING MULTICAST MTU:1500 Metric:1

RX packets:15 errors:0 dropped:0 overruns:0 frame:0

TX packets:36 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:100

RX bytes:4816 (4.7 Kb) TX bytes:13464 (13.1 Kb)


Let us look at the output of eth1 closely:


Hwaddr:

That's the modem MAC ID, you can also see it in the sticker attached to your modem. This string in a unique identification of your modem.


Inet addr:

The IP address in this output is recieved from the modem's internal DHCP service, this address is given when the modem is not connected to the cable network via the coaxial cable (RF) or if the modem is not synchronized with the CMTS of the cable provider. When the modem is connected to the cable network you will receive an IP address from the cable company DHCP server, this address may vary in accordance to your ISP.


MTU:

Maximum Transmission Unit – sets the max size of a packet transmitted through the network, a bad value for this key may cause a slow connection.


How will I know it's all working?

Again let us state that the bootproto for the device must be DHCP and not set with a static IP address.

Run ifconfig, if you see the field inet addr for you eth then all is properly configured. Also, all cable modems have an internal web interface that can be viewed by opening a browser and typing 192.168.100.1.


For Ambit modems: user is root, pass is root

For Joohong superlink: user is joohong, pass is sl-2400


as far as I know all other modems do not require a password for the web interface but if needed, you can consult the internet or your cable supplier.


Possible IP address from DHCP and their meaning (true for Israeli users only):


If the three first sections are 192.168.100.xx then you're getting the IP from the DHCP service running within the modem, meaning you can't reach the cable network DHCP, this can be caused if the coaxial cable (RF) is unplugged or the modem is unable to synchronize – try to do a cold boot (unplug and then replug the power supplier) if the status hasn't changed contact your cable company.


If the first to sections are 172.22-29.xx.xx then everything is properly connected and configured but you ISP demands tunneling to it's PNS/LNS server using PPTP/L2TP, this issue is currently not covered by this guide but I plan on adding it at a later date, until I do, I've located two great guides that cover this matter, please refer to the list of links in the ending section of this guide.


If the first two sections are 172.16.xx.xx then all is properly connected and configured but you are blocked from accessing the internet in the cable company level – call your supplier.


Any other IP address means you are routed via your ISP directly to the internet (without the need to tunnel as mentioned here) and are able to use the internet.

Remember to configure your iptables for security (see references below).



Useful links for further information:


http://www.kernel.org – kernel archive

http://www.linux-usb.org – USB support information for Linux users

-http://tlug.up.ac.za/guides/lkcg/lkcg.html – a good kernel compilation guide

http://www.tldp.org – Linux documention project

http://www.whatis.com – DB for technical terms – if case you wish to review terms discussed here

http://www.linuxguruz.com/iptables/howto/iptables-HOWTO.html – iptables guide

http://www.netfilters.org – another tool for iptables configuration

http://l3ech.net/cables_linux_l2tp.php?reverse=on – A good guide for tunneling with L2TP using a cable connection

http://iglu.org.il/amit/cable/ - A guide for tunneling with PPTP using a cable connection