The library and other public Wifis restrict internet access to certain ports, sometimes just port 80. I'd need to be able to use ssh and other programs that require a different port.

My current solution is to tether to my phone, completely bypassing the public wifi. But then all traffic goes through my phone, which is slow.

Is there a way to connect to both connections simultaneously (connect to the phone via bluetooth or usb), and then select which traffic uses a particular connection? Ideally everything would default to one connection, and only things I manually configure would exit via the 2nd connection (my phone).

I'm on a macbook air using OSX 10.7.3.


Naturally I found the solution after posting. Connect to both internet connections, and make sure the "default" connection is higher on the list in the "set service order" menu within the network setting preferences pane. Click the "advanced" button for the phone's network connection, and copy the "router" IP address. Then in the terminal type "sudo route add [IP of box we're trying to ssh into] [router IP for phone's connection]".

Follow up question #1: how can I make this easy to activate and de-activate? Is there a way to get those specific routes configured as part of a network "location" profile? Or do I need to create an on/off script?

Follow up question #2: is there a way to do this based on destination port instead of IP address? Routes won't work. Maybe some sort of locally-running proxy?


1 Answer 1


check out 'route'. (Go to terminal and enter "man route"). You can force certain traffic to specific interfaces

Specifically, route PRINT is the same as netstat -r

This shows how tcpip will route a destination IP (with its subnet mask) to the default gateway VIA a specified interface (and how many hops/the metric it is to the destination)


 route ADD someIp MASK gatewayIp METRIC 1 IF {interfaceID}

each interface has an id, you have four. (use ipconfig ifcount to know for certain OR you can use networksetup -listallhardwarereports to display a easier-to-read listing of the same info.)

localhost (lo0), your hardwire (en0), your wireless (en1) and your phone (??). Use ifconfig to see all the details for each interface.

the interface ID for route is the interface's index. i'll be right back on how to print that out. hmm.. ipconfig is supposed to output the index but on OSX is doesn't. still looking...


On OSX the networksetup command might have a way to do what route should do. I am not personally familiar with it but its options are all somewhat self explanatory.

  • It turns out there is no "route print" in OSX, thanks for pointing out netstat -r. Any thoughts on my follow up questions?
    – mpoisot
    Apr 20, 2012 at 22:19
  • actually, it turns out all the route syntax is different... ugh.
    – mpoisot
    Apr 20, 2012 at 22:45
  • regarding q#2.. ya.. a locally hosted socks server of some kind would do what you want. address routing is just that.. for addresses. port forwarding is a different kettle of fish.
    – Sass
    Apr 21, 2012 at 0:07

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.