You are not logged in.

#1 2012-05-15 12:28:26

MystX
Member
Registered: 2009-06-04
Posts: 42

[SOLVED] Separate internet and LAN interfaces

Hi guys,

I have just added a wireless connection to one of my PCs to access a local network, while I have a wired connection for internet access.
wlan0 IP of 203.114.xxx.xxx, while eth0 will be 192.168.0.xxx (local). I'm using netcfg.

My question is, how do I make sure that any traffic for everything other than 203.114.xxx.xxx goes through eth0, and not wlan0?

If both profiles are active, I have no internet connection (and DNS doesnt work), but if I disable the wlan0 profile, then refresh eth0 I get an internet connection again.

This is the output of 'ip route' with both profiles connected:

default via 192.168.0.1 dev eth0
default via 203.114.159.254 dev wlan0  metric 303
192.168.0.0/24 dev eth0  proto kernel  scope link  src 192.168.0.2
203.114.158.0/23 dev wlan0  proto kernel  scope link  src 203.114.158.159  metric 303

I guess I had to add/remove some sort of routes, but will that make sure that traffic is sent to the right interface?

Thanks for any help

Last edited by MystX (2012-05-27 09:16:39)

Offline

#2 2012-05-15 13:12:50

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: [SOLVED] Separate internet and LAN interfaces

Remove the 'default via 203....' route.

General observation: 203.114.158.xxx is a public routable subnet (assigned to a New Zealand ISP, in case you're interested), and should not be used on any internal network.

Offline

#3 2012-05-15 13:16:29

MystX
Member
Registered: 2009-06-04
Posts: 42

Re: [SOLVED] Separate internet and LAN interfaces

How would I go about removing that route?

tomk wrote:

General observation: 203.114.158.xxx is a public routable subnet (assigned to a New Zealand ISP, in case you're interested), and should not be used on any internal network.

It's funny you should say that. The address I'm given on wlan0 is actually an IP from this ISP. It's an open public network where one pays for data usage, and is given an public routable IP rather than a local one. I just described it as above to simplify things, as I will only be using it to access other machines on the same network and do not want to use internet or DNS on that network.

Offline

#4 2012-05-15 14:35:24

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: [SOLVED] Separate internet and LAN interfaces

"ip route ..." is what you're looking for, the man page has the details.

And that sounds like a strange setup. If you're getting internet access through eth0, why can't you get to the 203.114 network that way?

Offline

#5 2012-05-16 10:06:24

MystX
Member
Registered: 2009-06-04
Posts: 42

Re: [SOLVED] Separate internet and LAN interfaces

I have removed that route, and still have the same problem sad

tomk wrote:

that sounds like a strange setup. If you're getting internet access through eth0, why can't you get to the 203.114 network that way?

The reason is that I have a small data cap. Accessing the wireless locally allows me to access all the PCs on it, without eating into my internet data cap.


EDIT: It seems that restarting the eth0 netcfg profile AFTER removing the wlan0 route fixed the problem. Is there any way to cause this to happen automatically?
Something like:
POST_UP='ip route del default via 203.114.159.254 dev wlan0 && netcfg -r wired'
in the wlan0 profile perhaps?

Last edited by MystX (2012-05-16 10:24:56)

Offline

#6 2012-05-16 10:31:50

Gcool
Member
Registered: 2011-08-16
Posts: 1,456

Re: [SOLVED] Separate internet and LAN interfaces

I've read your description a few times now and still can't make any sense of it I'm afraid.

So if I understand correctly, your eth0 interface is how you access the internet (you get a 192.168.x.x ip from your router) and this is to remain like that? Your wlan0 interface is supposed to be used to access other resources on your local lan and not have internet access?

If this is correct, where does that 213.114.x.x ip on your wlan0 come from? Are you connecting to some wifi network which assigns that to you (which is kinda pointless if it's meant to be used for your local lan)?


Burninate!

Offline

#7 2012-05-16 10:33:43

MystX
Member
Registered: 2009-06-04
Posts: 42

Re: [SOLVED] Separate internet and LAN interfaces

Gcool: Thats all correct. Im using the wlan0 network to access things without using up internet, so it's not pointless.

Offline

#8 2012-05-16 10:40:54

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: [SOLVED] Separate internet and LAN interfaces

Gcool - I was confused too smile, but basically both connections go to the internet. He just wants to restrict the wireless one to the 203.114.158.x subnet, for whatever reason.

MystX, don't know if you're concerned about security, but if you are, connecting wlan0 direct to the internet should bother you. Set up a firewall if it bother you enough. smile

Offline

#9 2012-05-16 10:44:14

MystX
Member
Registered: 2009-06-04
Posts: 42

Re: [SOLVED] Separate internet and LAN interfaces

It doesn't really bother me as the PC being connected is a server which is rather exposed anyway. Firewalls etc are set up, and will be refusing connections from anything outside the 203.114. subnet.

Does anyone know how to set up this situation to be relatively automatic? Removing the route and restarting the wired network manually every time the wireless dies is not really an option

Offline

#10 2012-05-16 15:00:11

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: [SOLVED] Separate internet and LAN interfaces

You were on the right track in post #5 - keep experimenting.

Offline

#11 2012-05-27 09:15:04

MystX
Member
Registered: 2009-06-04
Posts: 42

Re: [SOLVED] Separate internet and LAN interfaces

Just to sum this up for future google-fooers.
The problem has been solved reasonably for me. My netcfg profile for the wireless now contains:

POST_UP='ip route del default via 203.114.159.254 dev wlan0 && netcfg -r wired'

I have noticed that samba stops working upon the wireless connecting (probably due to the wired connection being restarted) so my wired profile now contains:

POST_UP='rc.d restart samba'

too.

Offline

Board footer

Powered by FluxBB