Linux routing question

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

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

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

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 10.0.0.1, 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 10.0.0.1 device.
mswarbrickAsked:
Who is Participating?
 
giltjrConnect With a Mentor Commented:
O.K, got a copy of embedded DSL running under QEMU.

This is a bit of a mess in my personal opinion.

Start X-Windows. At the bottom near the left hand corner you should see "Panel".  Click that, and then click netcardconfig.  Set your configuration for what you need.  That should do it.

What I found is that in /opt you should see 'eth0.sh' and 'eth1.sh' files.  These contain the commands to configure the network interfaces.  I have not checked to see if any doc has been updated to reflect these "new" files.

So in bootlocal.sh you can have the echo to enable routing, the command to start syslogd that was there to start with and that should  be it.

The eth0 and eth1 ".sh" files in /opt should do the rest.
0
 
giltjrCommented:
You need to make the default route on the Linux box 10.0.0.1.

What OS is PC A running?

I personally would change the default route on PC A to 10.0.0.1 and then setup a specific route for 192.168.20.0/24 pointing to 10.0.0.100.
0
 
wdfdo1986Commented:
You need to configure NAT (Network Address Translation)
You have done one step already. Do the other steps as well.
refer to this link
http://www.cyberciti.biz/faq/howto-configure-network-address-translation-or-nat/
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
giltjrCommented:
He should not need to configure NAT on Linux router.  All he needs to do is send the traffic to the correct router.
0
 
mswarbrickAuthor Commented:
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.
0
 
giltjrCommented:
Can you post the output from the command:

route

From your linux box?
0
 
mswarbrickAuthor Commented:
destination      Gateway       Genmask      flags        Metric    Ref   Use   Iface

192.168.20.0       *           255.255.255.0   U              0           0       0    eth1
10.0.0.0               *            255.255.255.0  U              0           0       0    eth0
0
 
mswarbrickAuthor Commented:
There is the route. Still hoping someone can help me. I appreciate the effort. Thanks.
0
 
giltjrCommented:
On the linux box issue the command:

     route add default gw 10.0.0.1 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.
0
 
mswarbrickAuthor Commented:
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!
0
 
giltjrCommented:
Try editing the file  /etc/network/interfaces and add the line

     gateway 10.0.0.1

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

    iface eth0 inet static
            address 10.0.0.100
            netmask 255.255.255.0
            gateway 10.0.0.1
0
 
mswarbrickAuthor Commented:
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?
0
 
giltjrCommented:
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.
0
 
mswarbrickAuthor Commented:
These are the commands I am entering to get everything working...

ifconfig eth0 10.0.0.100 netmask 255.255.255.0 up
ifconfig eth1 192.168.20.1 netmask 255.255.255.0 up
echo "1" >> /proc/sys/net/ipv4/ip_forward
route add default gw 10.0.0.1 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.
0
 
mswarbrickAuthor Commented:
I've been working on this all afternoon and evening. I have read that /opt/bootlocal.sh 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.
0
 
giltjrCommented:
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.
0
 
giltjrCommented:
What commands did you put in to bootlocal.sh?  

Can you post what your bootlocal.sh looked like before you started changing it?
0
 
mswarbrickAuthor Commented:
Original bootlocal.sh

#!/bin/bash
# put other system startup command here
/sbin/syslogd

Modified bootlocal.sh

#!/bin/bash
# put other system startup command here
sudo ifconfig eth0 10.0.0.100 netmask 255.255.255.0 up
sudo ifconfig eth1 192.168.20.1 netmask 255.255.255.0 up
sudo echo "1" >> /proc/sys/net/ipv4/ip_forward
sudo route add default gw 10.0.0.1 eth0
/sbin/syslogd

I tried it with and with out sudo. If I run the bootlocal.sh 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?
0
 
giltjrCommented:
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:

#!/bin/bash
# put other system startup command here
ifconfig eth0 10.0.0.100 netmask 255.255.255.0 up
echo "dideth0" > /mylog.txt
ifconfig eth1 192.168.20.1 netmask 255.255.255.0 up
echo "dideth1" >> /mylog.txt
route add default gw 10.0.0.1 eth0
echo "diddefgw" >> /mylog.txt
/sbin/syslogd

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.
0
 
mswarbrickAuthor Commented:
Ok, did that...Here are the results: Contents of mylog.txt...

dideth0
dideth1
diddefgw

By the way, if I do not have the echo "1" in the bootlocal.sh 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.
0
 
giltjrCommented:
O.K., bootlocal.sh is getting executed or the file would not exist.  So something that is getting executed after bootlocal.sh 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?
0
 
mswarbrickAuthor Commented:
I used dsl-4.4.10-syslinux.iso
0
 
mswarbrickAuthor Commented:
0
 
mswarbrickAuthor Commented:
Any progress?
0
 
giltjrCommented:
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.
0
 
mswarbrickAuthor Commented:
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.
0
 
giltjrCommented:
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 (http://www.zeroshell.org).  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.
0
 
mswarbrickAuthor Commented:
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/eth0.sh scrips from the bootlocal.sh  It works if called like that. Go figure.

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

...Mark
0
 
giltjrCommented:
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.
0
 
mswarbrickAuthor Commented:
An awesome job!
0
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.