LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (http://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Routing to internet through one network, and to local ips in another network (http://www.linuxquestions.org/questions/linux-networking-3/routing-to-internet-through-one-network-and-to-local-ips-in-another-network-715931/)

IceDane 03-31-2009 09:25 PM

Routing to internet through one network, and to local ips in another network
 
Hey there.

Here's the scenario:

I have two networks. One of them is wired, the other is wireless. The wired has an internet connection and a few other computers connected to it. The wireless network has a few hosts connected to it too, but it has no internet connection.

What I've been trying, fruitlessly, to do, is make all connections that are bound to the internet, or my wired network, be routed that way, and all the connections to the hosts of the wireless network go that way.

Here's the setup..

Wired:
192.168.1.0/24 Gateway = 192.168.1.1
Route internet through here

Wireless
192.168.2.0/24 Gateway = 192.168.2.1

If my computer sends a packet to the internet, it should be routed through 192.168.1.1

If I send a packet to one of the local hosts of the wireless network, it should be routed through 192.168.2.1.

Here's the routing table I've set up(This is one of many configurations I've tried)
Code:

$ ip route show
192.168.2.1 dev wlan0  scope link
192.168.2.0/24 via 192.168.2.1 dev wlan0  src 192.168.2.4
192.168.1.0/24 dev eth2  proto kernel  scope link  src 192.168.1.36
169.254.0.0/16 dev eth2  scope link  metric 1000
default via 192.168.1.1 dev eth2

With this, and everything else, I get destination host unreachable when pinging.

The strange thing is that, if I unplug my eth cable, reboot and connect to the wireless network, everything is fine and I can access the router and the others.

That's about it.

I would seriously appreciate any help and input I can get on this. I'm trying to improve my networking skills, as I've had this idea of setting up a small linux box as a router for quite some time, for the fun of it, but I need to get routing under control before I go ruin my network lol.

Thanks!

datopdog 04-01-2009 02:33 AM

Quote:

Originally Posted by IceDane (Post 3494401)
Hey there.


If I send a packet to one of the local hosts of the wireless network, it should be routed through 192.168.2.1.

You do not need that explicitly as the host will know that to get to the 192.168.2.0/24 network the packet should leave out of the wlan0 interface since you are directly connected to that network.

IceDane 04-01-2009 04:43 AM

Quote:

Originally Posted by datopdog (Post 3494579)
You do not need that explicitly as the host will know that to get to the 192.168.2.0/24 network the packet should leave out of the wlan0 interface since you are directly connected to that network.

Yes, this is what I thought and it seemed logical - but it still doesn't seem to work. I always get destination host unreachable. What could this be?

datopdog 04-01-2009 04:45 AM

Can you ping any machine on the WLAN from that machine ? It could be your host firewall blocking the packet.

john test 04-01-2009 07:52 AM

Quote:

Originally Posted by IceDane (Post 3494401)
Hey there.

Here's the scenario:
Wired:
192.168.1.0/24 Gateway = 192.168.1.1
Route internet through here

Wireless
192.168.2.0/24 Gateway = 192.168.2.1

If my computer sends a packet to the internet, it should be routed through 192.168.1.1

If I send a packet to one of the local hosts of the wireless network, it should be routed through 192.168.2.1.

Here's the routing table I've set up(This is one of many configurations I've tried)
Code:

$ ip route show
192.168.2.1 dev wlan0  scope link
192.168.2.0/24 via 192.168.2.1 dev wlan0  src 192.168.2.4
192.168.1.0/24 dev eth2  proto kernel  scope link  src 192.168.1.36
169.254.0.0/16 dev eth2  scope link  metric 1000
default via 192.168.1.1 dev eth2


The strange thing is that, if I unplug my eth cable, reboot and connect to the wireless network, everything is fine and I can access the router and the others.
Thanks!


Just guessing that all packets are being sent out the Default Gateway expecting to be routed from there, and that when you pull the cable they head out the wlan0 interface. Again, just guessing, there must be some way to prioritize so that packets destined for the wlan ignore the Default Gateway???

IceDane 04-01-2009 03:01 PM

Quote:

Originally Posted by john test (Post 3494864)
Just guessing that all packets are being sent out the Default Gateway expecting to be routed from there, and that when you pull the cable they head out the wlan0 interface. Again, just guessing, there must be some way to prioritize so that packets destined for the wlan ignore the Default Gateway???

Yes, these are my thoughts exactly. It seems as if the default route is overriding anything else, and thus routing packets out the wired gateway, where there is no route. I have no idea how to fix this, though, in spite of having read the man page pretty thoroughly for both route and "Ip route"

harry_uk 04-02-2009 01:21 AM

Give the following commands:

Code:

#ip route delete 169.254.0.0/16 dev eth2  scope link  metric 1000
Code:

#ip route delete 192.168.2.1 dev wlan0  scope link
Code:

ip route delete 192.168.2.0/24 via 192.168.2.1 dev wlan0  src 192.168.2.4
Code:

ip route add 192.168.2.0/24 via 192.168.2.1 dev wlan0 scope link src 192.168.2.4
Now try pinging 192.168.2.1 and 192.168.1.1.

The issue must be resolved.

Regards,

Harry.


All times are GMT -5. The time now is 07:58 AM.