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.


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 table 1 dev wlan0
| improve this answer | |

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.

| improve this answer | |

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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