Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

At the moment I'm working at a company and the problem is they allow SSH on wifi but not on their wired network. At the moment I push everything through a vpn, but that gives overhead on an already slow network.

I was wondering how I could make all my traffic go through my eth0 but make my ssh connection use wlan0 instead of eth0.

It's important all other traffic goes through eth0 as the wifi here is extremely slow, but just fast enough for a simple shell.

share|improve this question
    
+1 Cool question. A general answer would be really interesting to read. I think you should add the tag iptables to your post. Also, the answer will most likely not be Ubuntu specific, so maybe this question should be migrated to superuser.com –  Geoff Feb 15 '12 at 15:38
    
There are a bunch of somewhat related questions on superuser about this. I haven't found an exact match. I imagine a similar (but more common) idea is to put all torrent traffic through eth1 leaving eth0 for other tasks, for example. –  Geoff Feb 15 '12 at 15:43
1  
add comment

3 Answers

up vote 4 down vote accepted

Set up eth0 as the default route, set up an alternate route through wlan0, and configure the ssh traffic to go through the alternate route.

Install the iproute package to manipulate routing tables through the ip command. Mark the outgoing packets that you want to re-route, and set up a routing rule to route those packets through a different interface. Untested:

iptables -t mangle -A OUTPUT -p tcp --dport ssh -o eth0 -j MARK --set-mark 1
ip rule add fwmark 1 table 1
ip route add 0.0.0.0/0 table 1 dev wlan0
share|improve this answer
add comment

It's somewhat complex. You will need to create an alternative route table, use iptables to mark the package and add a routing rule to force the kernel to use the alternate routing table when the package is marked.

You have a good tutorial for a somewhat more complex setup here.

share|improve this answer
add comment

Are you wanting this to be used on just your computer or are you wanting to route all traffic on your network this way? If just yours do you have both eth0 and wlan0 interfaces running and configured to access your network? Just some basic questions so that i can better assist with the proper answer.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.