cable modem -> linux box -> network

i am trying to get my exturnal cable modem to be accessed by my network by useing ipchains and ipmasq i have not been able to get it to work i have made a file that had all the commands that i was told that i needed and that worked for the person that gave it to me but it does not seem to work on my linux box if anyone could help me that would be nice
Who is Participating?
ok, here is the steps...

1) configure your linux box to access the cable modem:

I'm going to give specific examples from Redhat 6.1, but should work for other versions of RedHat, and should be similar for other distros.

when you received your cable modem, you should've got your information on the setup of it.  Things you really need are: IP address/DHCP setup, gateway, and DNS settings.

Also, you want to verify that your Ethernet cards are recognized by Linux.  You can try doing a ifconfig eth0 and then a ifconfig eth1.  If they both list some settings, Linux is seeing the cards.  If not, verify that the cards are supported in your distribution and if they are, verify that the cards work (maybe under Win95/98/NT).

to quickly check if the cards are functioning, configure the card connected to the cable modem with your IP address.  If you're using @Home, you can get away with assigning the last IP address you had under Windows.  I don't know about other providers.

do the following to assign a address:
      ifconfig eth0 xx.xx.xx.xx netmask broadcast xx.xx.xx.255

where xx.xx.xx.xx is your IP address, and xx.xx.xx.255 is the first 3 octets of the address with 255 as the last octet.

at this point you should be able to ping your router/gateway.  Usually, the gateway is the first three octets with a .1 as the last octet:
      ping xx.xx.xx.1

if you can ping, then your networking is working.  Now you need to get your gateway settings working.  type the following:
      route add default gw xx.xx.xx.yy
where xx.xx.xx.yy is the gateway IP address.

Under RedHat, you can make the change permanent by editing /etc/sysconfig/network-scripts/ifcfg-eth0.  You should already have this file.  Just change the IPADDR variable and NETMASK variable.

to make the gateway setting permanent, edit /etc/sysconfig/network.  Set the GATEWAY variable to your gateway.  Also, set FORWARD_IPV4 to true, while you're here.

For your DNS settings, edit /etc/resolv.conf.  It should have the following lines in it:
      nameserver xx.xx.xx.yy
      nameserver xx.xx.xx.yy

you can have as many nameserver lines as there are nameservers listed on your configuration sheet.  I currently have two nameserver lines with @home.  At work, we have three nameservers.

after you have the cable modem working, assign a internal address to the other card.  Just substitute eth1 for eth0 in the above steps.  For the IP address, I would choose one from the 192.168.xx.yy range, where xx is the same for all of your machines and yy is unique.  This gives you 254 addresses to use, plenty for most setups.

Make sure that all of your internal computers can talk to each other and can see the linux box.  Go ahead and setup the DNS info the same way you would if you connected the cable modem directly to them, and for the gateway, set it to the IP address of the internal network card of the forwarding box.

At this point, you'll want to make sure that your kernel has forwarding turned on.  look in /proc/sys/net/ipv4 for a file called ip_forward.  If you have this file, you're set.  If not, you'll have to recompile the kernel to include the forwarding code.  Look in the FAQs for how to recompile the kernel.

If you do have ip_forward, echo "1" > /proc/sys/net/ipv4/ip_forward.

then you can do the following to turn on forwarding:
      ipchains -P forward DENY
      ipchains -A forward -s -j MASQ

I used 192.168.242.x as my network, you might have choosen something different.  Just replace my net address with your's.  The .0/24 is important.  That specifies any packet from a machine in the range of - .255 will be forwarded out.  If you misconfigure this, you won't be able to forward.

Test it out by trying to ping your gateway (the cable modem gateway, not the linux box) from another machine.  If this succeeds, than forwarding is working.  Then try something a little more complex like loading a web page... it should work if everything is configured good.

You'll probally run into problems with some applications.  Some, like ftp, have additional modules that need to be loaded to work.  On my machine, I have the following modules available to load:

look in /lib/modules/linux-???/ipv4 for your modules... ??? is whatever version of the kernel you are running.

to load one of these, just type:
      insmod ip_masq_ftp (or whatever module you want)

you only need to load them once after boot.  They stay loaded until reboot or you do a rmmod ip_masq_ftp (or whatever..)

If you have any other questions, go to the Linux Documentation project and search the howtos for the IP Masq howto.  It is a excellent resource.

Good luck,
First things first... Without ipchains running does the Linux box recognize the cable modem's presence on its outside interface and allow you to access the Internet? Also do you have basic connectivity (ping, telnet, etc) between the inside ethernet interface and other systems on your inside network?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.