# [solved!] Add route to NetworkManager VPN

## bas89

Hi there,

I’m using a VPN connection with NetworkManager but only need this for one single target. How do I tell this NetworkManager? I think I have to add one or two “route” lines in my VPN connection->IPv4->Routes. But I can’t type in names in the lines, only IPs...

I’m searching for something like this: 

http://media.cdn.ubuntu-de.org/wiki/attachments/13/28/05-Assistent-Routing.pngLast edited by bas89 on Sun Apr 01, 2012 7:59 pm; edited 1 time in total

----------

## Veldrin

bas89,

routing only works on IP layer. 

At least networkmanagent (kde4) allows my to restrict vpn traffic only to the advertised network. networkmanager automatically handles all routing. 

What host are you trying to reach? is it the same you are building the vpn to, or is is another inside the same network? if the host is in the same network, why aren't you allowing the entire subnet on the vpn?

V.

----------

## bas89

I need to connect to a SSH server, which is only reachable from the internet and to a MATLAB license server, which is only reachable in the VPN simultaneously. The MATLAB license server is in the VPN but not the VPN server itself. I can succeed by leaving all the NetworkManager settings at default values and afterwards executing

```
route add ssh-server.com gw fritz.box wlan0
```

Then I can connect to both servers. But all traffic except this to ssh-server.com goes through my VPN because in my route list you see

```
Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

default         *               0.0.0.0         U     0      0        0 tun0

loopback        bas89-pc-gentoo 255.0.0.0       UG    0      0        0 lo

vpnserver.com   fritz.box       255.255.255.255 UGH   0      0        0 wlan0

141.44.225.0    *               255.255.255.0   U     0      0        0 tun0

ssh-server.com  fritz.box       255.255.255.255 UGH   0      0        0 wlan0

192.168.2.0     *               255.255.255.0   U     2      0        0 wlan0
```

----------

## Veldrin

how restrictive is your university? can you ssh from the university network to your server? 

If it is possible, then nothing more you need to do, as the default route already points at the vpn tunnel, and you would just do a little detour to reach you ssh server.

if it is somewhat restrictive, that you have to add a route for your ssh server:

in networkmanagement (kde4) you have inside the vpn settings, in the ipv4 tab the option to specify additional routes. I assume that the gnome version provide something similar. 

if you need to know the ip address of your ssh server, just run host ssh-server.com. host is part of bind-tools.

HTH

V

----------

## bas89

I’m using KDE, too. No, it’s not possible to connect via ssh from inside the VPN, because of that i’m asking here. In the ipv4 tab I already played with some entries. But there are several questions... Do I have to add the route to “additional addresses” or “routes”? In “routes“ there are two more options which are disabled by default. I added a rule in “routes” with the IP address of the ssh server that should be connected without VPN. But what should the gateway be? The IP address of fritz.box (192.168.2.1)? For these settings I can’t get a connection to the ssh server. Also I can’t set the interface (it shouldn’t be tun0 but wlan0).

----------

## Veldrin

In that case hardcode the route to your wireless connection. 

go to your wireless connection, select ipv4 address, then switch to routes.

there you have to add the host route to your ssh server:

```
address: 1.2.3.4 (use the real address)

netmask: 255.255.255.255

gateway: 192.168.2.1 (use the real address of your fritzbox)

metric: 1
```

then fire up your vpn connection and verify the routing table - it should still contain a route for your ssh server.

----------

## bas89

Alright, now it’s working! Great!

Many, many Thanks!    :Surprised: 

----------

