Forwarding specific ports to WLAN0

1

I'm trying to connect to a VPN which doesn't allow HTTP access (or any access really, except RDP). So basically I'm trying to say to my computer, "only use PPP0 for RDP (port xxxx) and for everything else, use plain ol' WLAN0". Apparently this has something to do with iptables or routes but I can't figure out all the options and the tutorials I've found are quite too vague for me. So my question is as follows:

How do I specify that certain ports use certain interfaces, while other ports use other interfaces for requests originating at my system (Ubuntu 10.04)?

Thanks.

Brian Hicks

Posted 2010-07-13T16:13:54.193

Reputation: 237

Answers

1

It's easier to route using ip addresses. You won't even need iptables. Find out the IP or subnet you want to access through ppp0, and add a route to that (/32 for a single ip, smaller for a subnet):

sudo ip route add dev ppp0 <ipv4-address>/32

Though I'm surprised your VPN software hasn't set up a route already. Check with ip route show .

In light of your comment, your problem isn't a missing route, but too many routes. You seem to have a default route through ppp0, that you should remove.

sudo ip route del $(ip route show dev ppp0 |grep default)

And replace with a default route on wlan0, which you can let dhcp set up, or add explicitly if you know the ip of your gateway, or may already have:

sudo ip route add default via <gateway ip of your wireless lan>

Routing goes like this: you want to send a packet to an ip. If the ip you want to find is on the same link as one of your interfaces, send the packet on that link. Otherwise, find the smallest subnet that contains that ip. That subnet has a gateway address (possibly the default address, if no smaller subnet is defined). Go back to step 0, with the ip of the gateway.

Tobu

Posted 2010-07-13T16:13:54.193

Reputation: 2 584

The problem is that it uses that interface for everything. If it were using it for nothing that would work great, but that command doesn't seem to limit it to that. Is there any other way of doing it? Say telling everything but a certain IP to use WLAN0? – Brian Hicks – 2010-07-16T18:57:29.623