Link to home
Start Free TrialLog in
Avatar of mswarbrick

asked on

Linux routing question

I am configuring Linux to route for is Damn Small Linux, which is based on Knoppix, a Debian version of Linux...

Two interfaces on the linux
I turned on routing with  echo "1" >> /proct/sys/net/ipv4/ip_forward.

I have two PCs running windows. ..
PC A is on the network - Default Gateway set to
PC B is on the network. Default Gateway set to

I want PC A and B to be able to ping each other. I have already accomplished that. I can do that with this setup. However. I also want PC A to be able to reach the Internet.
To reach the Internet, it must send to, as that is the route to the Internet.

Question: What commands can I setup on my linux router so that it will send packets for the 192.168.20.x network as it is now, to that network, but if it is Internet traffic, it will send it out to the device.
Avatar of giltjr
Flag of United States of America image

You need to make the default route on the Linux box

What OS is PC A running?

I personally would change the default route on PC A to and then setup a specific route for pointing to
You need to configure NAT (Network Address Translation)
You have done one step already. Do the other steps as well.
refer to this link
He should not need to configure NAT on Linux router.  All he needs to do is send the traffic to the correct router.
Avatar of mswarbrick


I appreciate the responses, however no one has told me how to do this. Just telling me what to make the default route does not help me because I don't know how to do that. I need someone to tell me specifically what commands to enter at the command line to make all this happen.

I believe that giltjr is correct when he says that I do NOT need to configure NAT. I have static IPs set on these other two PCs. The two PCs are running Windows and I have their default gateways set to point to the linux router.

I appreciate the help and I really hope someone can give me the information to do this. Thanks in advance.
Can you post the output from the command:


From your linux box?
destination      Gateway       Genmask      flags        Metric    Ref   Use   Iface       *    U              0           0       0    eth1               *    U              0           0       0    eth0
There is the route. Still hoping someone can help me. I appreciate the effort. Thanks.
On the linux box issue the command:

     route add default gw eth0

and see if that works.  If that does, I'll have to research to see how to make the permanent across re-boots of DSL.
Sir, you are a genius!  Thanks! That works!  Yes, if you can please tell me how to make that permanent even after reboot. While your at it, in case you know, I need to make some other commands permanent too - so if there is a script that I can put the commands in to make them run on startup, that would be helpful to know what and where that file is. Also, I don't want this to load xwindows on start. If you know how to turn that off that would be helpful. Thank you so very much for your help!
Try editing the file  /etc/network/interfaces and add the line


to the section that configures eth0.  Should end up looking something like

    iface eth0 inet static
Ok, I will try that....But I also need this to run on startup as well...

echo "1" >> /proc/sys/net/ipv4/ip_forward

in order to turn on routing...or is that command permanent?

I also need to run the ifconfig commands at startup to assign the static ips...or is that also permanent?
Unless you have something that changes ip_forward back to 0 or deletes the file, it should be permanent.

If you look at  /etc/network/interfaces it should have the config for all of the interfaces.

If it does not then you can add the config for eth1 to the file.
These are the commands I am entering to get everything working...

ifconfig eth0 netmask up
ifconfig eth1 netmask up
echo "1" >> /proc/sys/net/ipv4/ip_forward
route add default gw eth0

After a reboot I have to manually enter all that in again to get it working.
Is there a startup script I can put these in so they will run everytime it boots?

I looked at the /etc/network/interfaces as you suggested. However it has no config there except for lo. I could put something in there but I don't know what syntax to use. Also I still need to run the other commands. So I am thinking I just need to know the startup script that would be an equivalent of autoexec.bat in old windows.
I've been working on this all afternoon and evening. I have read that /opt/ is the last startup script to run after boot. I put all the commands in there but it didn't work. I then ran that script manually after putting in the commands. That works. It acts like that script is not running on startup....but I think more likely its this: I am running the script from a su root promt...perhaps on startup it does not have the privledges needed?  I put sudo in front of everyline in the script but that didn't work.

If you can find an answer for this it would truly be awesome.

Thanks again.
I'll have to do some reading.  Although "Linux" is "Linux" each distribution does it own thing in a lot of ways.

You should not need to do sudu at boot time.  Typically anything that runs at boot is done as root.
What commands did you put in to  

Can you post what your looked like before you started changing it?

# put other system startup command here


# put other system startup command here
sudo ifconfig eth0 netmask up
sudo ifconfig eth1 netmask up
sudo echo "1" >> /proc/sys/net/ipv4/ip_forward
sudo route add default gw eth0

I tried it with and with out sudo. If I run the manually all the commands execute and it works, bit if I just reboot things do not work - however, the echo "1" command is apparently working as when I look at the ip_forward file the 1 is there. Perhaps the ifconfig commands are being overwritten by another process further in the boot cycle?
As I stated before, once you do echo "1" >> /proc/sys/net/ipv4/ip_forward it should stay set forever.  No need to redo it.

Does syslogd start?

You should not need the sudo, all of these command should be issues as root.

Can you try:

# put other system startup command here
ifconfig eth0 netmask up
echo "dideth0" > /mylog.txt
ifconfig eth1 netmask up
echo "dideth1" >> /mylog.txt
route add default gw eth0
echo "diddefgw" >> /mylog.txt

and see if the file /mylog.txt exists and has the string echoed in them.  If the file does exist and has the string in them, then something else is resetting the network config.
Ok, did that...Here are the results: Contents of mylog.txt...


By the way, if I do not have the echo "1" in the then ip_forward is back at 0 after a reboot. I just double-checked to make certain that is the case.

I do not know how to determine if syslogd has started.
O.K., is getting executed or the file would not exist.  So something that is getting executed after is resetting everything.

I have not used DSL, so I will need to do some research to see what could be doing this.

What iso did you use to install DLS?
I used dsl-4.4.10-syslinux.iso
Any progress?
Trying to get DSL up and running from a thumb drive and not having any luck.  Going to try another computer tomorrow.

Did you add the configuration for the network to the file /etc/network/interfaces?

If not, try that.
Yes, I tried that. No luck. I am beginning to think DSL linux is a real pain. I can use any Linux that is small - like 300 MB or less. I don't need xwindows.
300MB or less what?  Disk space or RAM?

Although they go beyond just being a router you may want to look at Smoothwall or Untangle.  They are firewalls as well as routers.

Then there is Zeroshell (  It currently needs at least a Pentium process running 233 Mhz (yes M ) and 92MB of RAM.

I personally have not used any of these.
Avatar of giltjr
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes! Everything works now. I want to give you a sincere thank you for your effort on this. You definitely went above and beyond the call of duty!  I want to make sure you get awarded all the points I can give you. Please let me know how to do that to your maximum benefit.

An interested note: It calls the /opt/ scrips from the  It works if called like that. Go figure.

Thank you again for all of your expert help. It is very much appreciated.

Just award the points as you see fit and give the grade you see fit.    You can't award any more points that you made the question (500) and the best grade is an A.
An awesome job!