Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using openconnect to connect to vpn. After entering my credentials, I get this:

POST https://domain.name/...
Got CONNECT response: HTTP/1.1 200 OK
CSTP connected. DPD 30, Keepalive 30
Connected tun0 as xxx.xxx.xxx.xxx, using SSL
Established DTLS connection

Running ifconfig shows I have a new network interface tun0 with a certain ip address.

Question: How do I make ssh use only the network interface tun0 so that I can access computers on that private network?


My network configuration (route -n) seems to be this:   U     0      0        0 vmnet8   U     0      0        0 eth0   U     0      0        0 vmnet1     U     1000   0        0 eth0         UG    100    0        0 eth0
share|improve this question
Can you elaborate on your network configuration? With proper routing in place, any traffic destined for the network attached to tun0 will use that interface. – Eli Heady Jul 4 '11 at 18:34
up vote 24 down vote accepted

It's not the ssh client that decides through which interface TCP packets should go, it's the kernel. In short, SSH asks the kernel to open a connection to a certain IP address, and the kernel decides which interface is to be used by consulting the routing tables.

(The following assumes you're on GNU/Linux; the general concept is the same for all Unices, but the specifics of the commands to run and the way the output is formatted may vary.)

You can display the kernel routing tables with the commands route -n and/or ip route show.

OpenConnect should have added a line for the tun0 interface; connections to any address matching that line will be routed through that interface. For example, running route -n on my laptop I get the following output:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface         UG    0      0        0 eth0   U     1      0        0 eth0     U     1000   0        0 eth0   U     0      0        0 virbr0

This means that connections to hosts in the (i.e., addresses to according to CIDR notation) network will be routed through interface virbr0; those to and will go through eth0, and anything else (the line) will be routed through eth0 to the gateway host

share|improve this answer
Thanks for clarifying this for me - it seems that openconnect did not add a line for the tun0 interface. I suppose I should do this manually. – axel22 Jul 4 '11 at 18:36
@axel22 You might have a look here: bbs.archlinux.org/viewtopic.php?id=69064 for a script that uses openconnect and sets up the routes. – Riccardo Murri Jul 4 '11 at 20:25
@RiccardoMurri Would you like to answer my question – Rahul Gautam Dec 13 '12 at 10:54

If you are using Network Manager to manage your internet connections (as is the default manager on many systems), you may want to install both openconnect and network-manager-openconnect.

Once the OpenConnect plugin is installed for Network Manager, open Network Manager and click the + icon in the lower-left. You should be given a combo-box with the option VPN and then the ability to select OpenConnect Compatible VPN.

By using Network Manager to interface with OpenConnect, your routes will automagically appear and help you connect to the VPN. This is especially helpful for accessing servers over VPN, such as how FireHost does things.

share|improve this answer

Your Answer


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.