Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have two Interfaces eth0:: IP 192.168.1.3 netmask 255.255.255.0
eth0 is useing my dsl router as gateway to the internet.
Gateway: 192.168.1.254 DNS: 192.168.1.254 .
Interface two is eth1:: IP 192.168.2.1 netmask 255.255.0.0
eth1 is the gateway for my windows machine.
Internet is working fine, and the subnet is working just fine too.
What I'm trying to do now is that eth1 uses eth0 as gateway.
I tried it with following command::
route add default gw 192.168.1.3 dev eth1
But then an error occurs -> Network is unreachable.
Which is pretty confusing because I can ping eth0 with my windows machine just as well as eth1. But to ping eth0 it has to go over eth1. So there has to be some kind of connection. What did I do wrong? Any suggestions??
Christian
Last edited by phenix(flc); 02-05-2003 at 07:13 AM.
Originally posted by phenix(flc)
I have two Interfaces eth0:: IP 192.168.1.3 netmask 255.255.255.0
eth0 is useing my dsl router as gateway to the internet.
Gateway: 192.168.1.254 DNS: 192.168.1.254 .
Interface two is eth1:: IP 192.168.2.1 netmask 255.255.0.0
eth1 is the gateway for my windows machine.
Internet is working fine, and the subnet is working just fine too.
I tried that too before I changed it to 255.255.0.0 .
Somebody told me then that I have to change it because the 2 Interface have to be of different masks.
You were right with changing the mask to 255.255.255.0 . I jsut recognized that he didn't set up the 192.168.2.0 ip's. Now he does but the error occurs anyways.
What exactly still doesn't work? I picked the subnet mask up because it was simple but if that isn't the only problem then I would need more specific info.
you have:
eth0 192.168.1.3/255.255.255.0?
and eth1 192.168.2.1/255.255.255.0?
the DSL is 192.168.1.254 connected to eth0?
eth0 has default gateway 192.168.1.254?
everything connected to eth1 has gateway 192.168.2.1?
you activated routing on the linux machine? "echo 1 > /proc/sys/net/ipv4/ip_forward" will be a command in one of your startup scripts, /etc/rc.d/rc.inet2 in Slackware.
And you said, "Internet is working fine" by this you mean any machine on the network can see the internet?
Then you said, "But then an error occurs -> Network is unreachable." but never stated exactly what machine you were on and what you did that gave you this error.
This has nothing to do with IP Forwarding.. that's something else entirely.
Please understand that routing is something that happens between *NETWORKS*.
Your machine (linux box) knows how to reach various networks attatched to it. When it *doesn't* know how to reach a network it forwards the request on to its 'default' gateway, and hopes that *IT* knows and will tell it how to get there.
Your machine can only have 1 default gateway. It's where stuff goes when it doesn't know where else to put it.
What you did was to turn your default gateway from pointing out onto the internet (and to your isp) and back internally. You're effectively saying 'My internal network knows how to get *everywhere*. If you don't know how to get to www.yahoo.com then send it to this interface (eth1) and what's on the other end of that interface will know what to do with it.'
Which it quite clearly *doesn't*.
Your machine was set up correctly.
What you *SHOULD* see though, is a line like this :
192.168.2.0 * 255.255.255.0 U 0 0 0 eth1
And what this means is that your machine knows that any traffic destined for your private subnet of 192.168.2.xxx should be sent to your internal ethernet card of eth1. (it won't send it across eth0 out onto the internet and back).
Your *default* should stay pointing out to the internet, because at the other end of that cable is a router who *does* know the correct route to www.yahoo.com
Give the guy a break, you wouldn't like it if someone patronized you when you were wrong...
Quote:
>Can you tell me more about IP forwarding??
This has nothing to do with IP Forwarding.. that's something else entirely.
Nothing? Really?
Quote:
Please understand that routing is something that happens between *NETWORKS*.
You mean like the 192.168.1.0 network and the 192.168.2.0 network?
Quote:
your machine (linux box) knows how to reach various networks attatched to it. When it *doesn't* know how to reach a network it forwards the request on to its 'default' gateway, and hopes that *IT* knows and will tell it how to get there.
Your machine can only have 1 default gateway. It's where stuff goes when it doesn't know where else to put it.
Actually, that is correct, I'm almost impressed slick.
Quote:
What you did was to turn your default gateway from pointing out onto the internet (and to your isp) and back internally. You're effectively saying 'My internal network knows how to get *everywhere*. If you don't know how to get to www.yahoo.com then send it to this interface (eth1) and what's on the other end of that interface will know what to do with it.'
Well, actually what you tried to do was tell linux that it could use eth1 to reach 192.168.1.3 but that IP address is actually reached on the other network, eth0.
Quote:
Which it quite clearly *doesn't*.
Really? so the fact that he can get to the internet from the linux box means nothing?
Quote:
Your machine was set up correctly.
What you *SHOULD* see though, is a line like this :
192.168.2.0 * 255.255.255.0 U 0 0 0 eth1
And what this means is that your machine knows that any traffic destined for your private subnet of 192.168.2.xxx should be sent to your internal ethernet card of eth1. (it won't send it across eth0 out onto the internet and back).
Your *default* should stay pointing out to the internet, because at the other end of that cable is a router who *does* know the correct route to www.yahoo.com
Slick.
Your linux machine already knows how to "route" data to the appropriate interface; It knows how to reach all the clients on eth1, 192.168.2.0 net AND anything on eth0, 192.168.1.0 including the DSL to the internet as the default gateway. Hmm, now all you need to do is tell the linux network stack to IP forward all the data from eth1 to eth0 and back so clients on the 192.168.2.0 network can go through the linux box (and the DSL) to get to the internet.
So, as I said earlier, you should turn on packet forwarding in Linux, there is probably some network menu in Redhat that has a checkbox to turn this on, maybe some Redhat expert could point out where this is? If you can't find it, one way to make it work is to look for a file /etc/rc.d/rc.local and add this line at the bottom of it:
Code:
echo 1 > /proc/sys/net/ipv4/ip_forward
This tells linux to forward the traffic on one network card to the other network card, making it so clients on one can see the internet on the other.
Double check these and post the answers:
eth0 192.168.1.3/255.255.255.0?
eth1 192.168.2.1/255.255.255.0?
the DSL is 192.168.1.254 connected to eth0?
eth0 has default gateway 192.168.1.254?
everything connected to eth1 has gateway 192.168.2.1?
routing is turned on?
what part of it doesn't work? have to be a lot mor descriptive than "it still ain't working" here
it hangs stopping NFS? what all did you change since it did shut down?
All I changed is I activated IP forwarding.
I added the line you told me and then I opened /etc/sysconfig/network and put ipforward on yes.
And what is not working is that I can't ping 192.168.1.254 from my Windows machine (192.168.2.2). So I don't have internet. But I can ping 192.168.2.1 and 192.168.1.3
Could it be that the dns has something to do with that.
I set my windows machine on gateway 192.168.2.1 dns 192.168.2.1 alternative dns 192.168.1.254
Originally posted by Darin Give the guy a break, you wouldn't like it if someone patronized you when you were wrong...
My bad.. I shall immediately ritually disembowel myself on this handy fig newton I have at my desk.
But um.. may I first point out that I still think his problem is this :
route add default gw 192.168.1.3 dev eth1
Which I read as :
route (default) [internet side network] to dev [internal facing network card]
Anything destined for internet is going to be routed internally. His traffic is going to bounce off the inside of his internet facing network card.
I leave you in the massively capable hands of Darian. He has way more posts than I, and knows the difference between IP Forwarding and Port Forwarding *cough cough*.
nothing worked. I activated and set up ip masquerading and it didn't work. When I started the rc.firewall-2.4 everything it was supposed to do failed.
Kernel version and everything is correct so I don't know what is wrong.
After that I tried firestarter... I couldn't even install it. The signiture was wrong and there were a couple package conflicts.
I don't know what to do. Thats almost impossible that none of it is working.
Last edited by phenix(flc); 02-07-2003 at 09:20 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.