PDA

View Full Version : OpenVPN connection won't start through Network Manager



bluudz
2013-09-08, 12:42
Good afternoon.

I have started using Kali just recently and I was wondering if someone is having similar problem. I'm running 1.0.5 amd64 Kali. I have installed OpenVpn network manager and OpenVpn network manager-gnome, sucesfully imported the vpn settings and cerfificates, but if I start to run VPN from network interface nothing will happen. Doesn't react at all.

If I do it through terminal it starts normally without any troubles, but I'd rather have it automatically starting when my computer starts as was happening with my previous distros.

Is there an error with Gnome Network manager maybe?
Thanks for any advice.

elfer
2013-09-09, 05:53
Good afternoon.

I have started using Kali just recently and I was wondering if someone is having similar problem. I'm running 1.0.5 amd64 Kali. I have installed OpenVpn network manager and OpenVpn network manager-gnome, sucesfully imported the vpn settings and cerfificates, but if I start to run VPN from network interface nothing will happen. Doesn't react at all.

If I do it through terminal it starts normally without any troubles, but I'd rather have it automatically starting when my computer starts as was happening with my previous distros.

Is there an error with Gnome Network manager maybe?
Thanks for any advice.

Have you tried to edit the /etc/network/interfaces file and the /etc/NetworkManager/NetworkManager.conf file? Edit /etc/network/interfaces and put a '#' in front of everything except these lines:

auto lo
iface lo inet loopback

(Be sure you have 'auto lo' on a line by it self, above 'iface lo inet loopback')
Your /etc/network/interfaces file should look something like this after (except yours might say wlan0 or wlan1 instead of eth0):

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
#allow-hotplug eth0
#iface eth0 inet dhcp


You may also want to edit the /etc/NetworkManager/NetworkManager.conf file. Under '[ifupdown]' change the value for 'managed' from 'false' to 'true'.
After you edit the file, the /etcNetworkManager/NetworkManager.conf should look something like this:

[main]
plugins=ifupdown,keyfile

[ifupdown]
managed=true

Note: Before editing either file, you might want to backup the original files first. Open a terminal and type the following lines:
cp /etc/network/interfaces /etc/network/interfaces.backup
cp /etc/NetworkManager/NetworkManager.conf /etc/NetworkManager/NetworkManager.confBackup
Not sure if it will work, but worth a try..

uwnthesis
2013-09-14, 18:29
Checked out the Server forums for any similiar problems with Openvpn. found this
http://superuser.com/questions/284865/vpn-through-networkmanager-in-debian

Secondly I found this - which looks promising
http://fooninja.net/2012/09/06/openvpn-networkmanager-problem/

I installed and configured the OpenVPN client/server on a Debian box as per Linode’s instructions (http://library.linode.com/networking/openvpn/debian-6-squeeze) (same for Ubuntu). One gotcha was that while it worked fine when starting OpenVPN manually on the client machine (/etc/init.d/openvpn start, Ubuntu 12.04.1), starting it from Network Manager made it connect but appear not to work. I found that I had to enable LZO compression in the Network Manager settings:
VPN connections -> Configure VPN -> select configured VPN and edit -> VPN tab -> Advanced. Check “Use LZO data compression”.
(Oh, and if you don’t see OpenVPN in the “Choose a VPN Connection Type” dropdown, make sure you’ve installed both network-manager-openvpn and network-manager-openvpn-gnome.)

bluudz
2013-09-15, 23:28
It did work well. Thank you very much!

One more thing I'm thinking about now while we are in the topic. Is it possible to set it up so VPN would connect automatically after system boot?

uwnthesis
2013-09-16, 15:24
It did work well. Thank you very much!

One more thing I'm thinking about now while we are in the topic. Is it possible to set it up so VPN would connect automatically after system boot?

There looks to be an "official" Debian way of doing this, and an unofficial hack. This should help you:

http://serverfault.com/questions/458591/how-to-auto-start-openvpn-client-on-ubuntu-12-04-cli (http://serverfault.com/questions/458591/how-to-auto-start-openvpn-client-on-ubuntu-12-04-cli)

On Ubuntu any VPN configuration you place in a file named /etc/openvpn/$NAME.conf will be automatically started.
So, all you have to do is copy your client.ovpn to /etc/openvpn/client.conf. I suggest you also use absolute paths in your client.conf for any keys, scripts and so on.
Of course, you might want to double check the /etc/default/openvpn file.
By default it will autostart all VPNs, but the AUTOSTART value could have been changed to none, or to be a list of the specific configurations you want automatically started.

The Hacked method
http://www.hackerway.ch/2012/12/11/how-to-auto-start-openvpn-client-in-debian-6-and-ubuntu-12-04/#comment-79




Good luck!

bluudz
2013-09-20, 09:53
As much as I tried none of the methods is working for me. Strange as it seems quite straight forward.

But on the other hand while searching for a solution I found one quite interesting tool for working with VPN's which really made me happy.

Its called VPN firewall and basicaly what it does is to only allow internet trafic when VPN is active. If it crashes than it will block all trafic. Thats quite good to protect yourself from your IP being revealed before you connect to VPN of when its down.
Link here:

https://github.com/adrelanos/VPN-Firewall

PS: If anyone got VPN working after the start I'm keen for any more suggestions.
Thanks

At0m5k
2014-06-02, 08:24
I recently had the same issue as you bluudz, so if you still haven't found a solution or if anyone else is having trouble establishing an openvpn connection automatically after logging in here's what worked for me running 3.14-kali1-amd64 #1 SMP Debian 3.14.4-1kali1 (2014-05-14) x86_64 GNU/Linux:

First off, assuming that you've made the changes to /etc/network/interfaces and /etc/NetworkManager/NetworkManager.conf as elfer mentioned, add your VPN via the gnome network manager interface if you haven't yet, making sure that the option "available to all users" in the bottom left has a checkmark.

After you've configured it check to see if it will connect manually by clicking on the network icon in the top right and selecting your VPN from VPN Connections.

Take note of the exact name of the VPN connection and the name of the wired or wireless connection you'll be using it with, just as they appear in the menu.

Next edit your VPN connection configuration file to make NetworkManager store the VPN secrets by itself rather than inside a keyring that will be inaccessible by root: open up /etc/NetworkManager/system-connections/"name of your VPN connection" and change "password-flags" and "secret-flags" from 1 to 0.

Alternatively you can add the following two lines to the same file:



[vpn-secrets]
password=your_password

If you happen to choose the first method you will have to edit your VPN connection via the network manager interface and add your password again so that it is stored properly.

Next there needs to be a shell script in /etc/NetworkManager/dispatcher.d/ in order for the VPN connection process to start automatically.

If you use the following it will connect to the VPN that you specify with the connection that you specify on restart and will reconnect to the VPN upon disconnection.


#! /bin/bash

CONNECTION_NAME="<name-of-connection>"
VPN_NAME="<name-of-vpn>"

activ_con=$(nmcli con status | grep "${CONNECTION_NAME}")
activ_vpn=$(nmcli con status | grep "${VPN_NAME}")
if [ "${activ_con}" -a ! "${activ_vpn}" ];
then
nmcli con up id "${VPN_NAME}"
fi

Make sure you chmod +x it to be executable and make sure that root has ownership and is the only account with write access. For security reasons of course.

And that's everything.

reik
2014-09-10, 16:38
Thank you elfer, finally the VPN work for me.

FUSHIA
2015-08-25, 09:57
Thanks Elfer, it works for me for my problem on VMware Kali x64.

Did this modifications and restart network-manager -> OK

GG