LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 03-31-2009, 09:25 PM   #1
IceDane
LQ Newbie
 
Registered: Oct 2006
Posts: 9

Rep: Reputation: 0
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!
 
Old 04-01-2009, 02:33 AM   #2
datopdog
Member
 
Registered: Feb 2008
Location: JHB South Africa
Distribution: Centos, Kubuntu, Cross LFS, OpenSolaris
Posts: 806

Rep: Reputation: 41
Quote:
Originally Posted by IceDane View Post
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.
 
Old 04-01-2009, 04:43 AM   #3
IceDane
LQ Newbie
 
Registered: Oct 2006
Posts: 9

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by datopdog View Post
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?
 
Old 04-01-2009, 04:45 AM   #4
datopdog
Member
 
Registered: Feb 2008
Location: JHB South Africa
Distribution: Centos, Kubuntu, Cross LFS, OpenSolaris
Posts: 806

Rep: Reputation: 41
Can you ping any machine on the WLAN from that machine ? It could be your host firewall blocking the packet.
 
Old 04-01-2009, 07:52 AM   #5
john test
Member
 
Registered: Jul 2008
Distribution: ubuntu 9.10
Posts: 527
Blog Entries: 1

Rep: Reputation: 35
Quote:
Originally Posted by IceDane View Post
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???
 
Old 04-01-2009, 03:01 PM   #6
IceDane
LQ Newbie
 
Registered: Oct 2006
Posts: 9

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by john test View Post
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"
 
Old 04-02-2009, 01:21 AM   #7
harry_uk
Member
 
Registered: Mar 2009
Posts: 36

Rep: Reputation: 16
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.

Last edited by harry_uk; 04-02-2009 at 01:30 AM.
 
  


Reply

Tags
ethernet, networks, route, routing, two, wired, wireless, wlan0



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Gateway to local area network routing issue tungaw2001 Linux - Networking 1 11-10-2008 08:59 AM
Routing for eth0 and wlan0 with static IPs on the same network. kelvinlo Linux - Wireless Networking 3 10-15-2007 04:54 PM
On local network - can't get to internet kook Linux - Wireless Networking 12 03-01-2005 09:45 AM
Network routing of Internet jester_69 Linux - Networking 3 12-03-2003 12:18 PM
local network okay - no internet Who Linux - Networking 7 03-26-2003 01:06 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 11:58 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration