You are not logged in.

#1 2010-05-10 02:34:52

Brief
Member
Registered: 2008-04-05
Posts: 43

Problems with Advanced Routing using two links

Hello Guys

I have ths following situation

On my notebook i'm connected through wlan0 to my router and also connected through usb0 to my mobile phone 3g

This is what i want to do:

The ports of torrents and emule uses usb0
All the rest (80, 443, 25, 143, 22, etc) uses wlan0

So im going to have one link dedicated to my downloads and another to the rest.

Useful info:
ip wlan0: 192.168.1.100
gw wlan0: 192.168.1.1

ip usb0: 192.168.100.100
gw usb0: 192.168.100.254

Here is what I'm doing

I created a table called 3g on /etc/iproute2/rt_tables

Then

iptables -t mangle -A POSTROUTING -p tcp --dport 51413 -j MARK --set-mark 2

ip route add default via 192.168.100.254 dev usb0 table 3g

ip rule add fwmark 2 table 3g

ip route flush cache


It doesn't work, if I set another rule on ip rule like:

ip rule add to SOME_IP lookup 3g

When I access SOME_IP it uses the usb0 link as it should

But the packages that uses the port 51413 doesn't goes out through usb0

I checked it using bwm-ng and iptables -t mangle POSTROUTING -nvL (few packages are getting the mark 2) so I think the error it's here

Does anyone knows what could it be?

Thank you,
Wagner

Last edited by Brief (2010-05-10 02:40:15)


New Challenges Means New Achievements

Offline

#2 2010-05-10 05:16:36

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,224
Website

Re: Problems with Advanced Routing using two links

Perhaps it's udp traffic? There's a whole lot of other rules you need to maintain sanity when doing this kind of stuff... You might be interested in this script I wrote (well, am writing)... It works OK, but run it in PRINT_ONLY mode first to double check the output wink)
http://github.com/fukawi2/pb-route

Offline

#3 2010-05-10 10:49:10

Sin.citadel
Member
Registered: 2008-01-22
Posts: 267

Re: Problems with Advanced Routing using two links

to check that if it is actually a tcp/udp proble,, try setting the fwmark to port tcp port 80, and then goto www.whatismyipaddress.com to see if its using the 3g ip address, if this works, then the problem might be with your mangle table rules.

Offline

#4 2010-05-10 21:52:16

Brief
Member
Registered: 2008-04-05
Posts: 43

Re: Problems with Advanced Routing using two links

I've tried to set the fwmark on port 80 and it didn't worked also

I'm going to try this script in perl fukawi2, as soon as I have time to it, thanks for sharing smile


New Challenges Means New Achievements

Offline

#5 2010-05-10 23:00:14

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,224
Website

Re: Problems with Advanced Routing using two links

Brief wrote:

I'm going to try this script in perl fukawi2, as soon as I have time to it, thanks for sharing smile

No problem -- please do give any feedback on problem you find so I can fix them up smile

Offline

#6 2010-05-11 08:49:16

Sin.citadel
Member
Registered: 2008-01-22
Posts: 267

Re: Problems with Advanced Routing using two links

i think that it might be because the routing decision is made before the postrouting chain, and since the rule for fwmark is executed before the packet is fwmark'ed, it means that the kernel routes it to the default interface, and not to the 3g interface, try setting the fwmark rule to the PREROUTING mangle chain and see if it works or not.

Offline

Board footer

Powered by FluxBB