Starting openvpn client on CentOS7

Issues related to configuring your network
taylorkh
Posts: 534
Joined: 2010/11/24 15:08:33
Location: North Carolina, USA

Starting openvpn client on CentOS7

Post by taylorkh » 2016/02/18 23:23:10

My Usenet provider includes a VPN service along with Newsgroup access so I decided to play with it. Their instructions for using the vpn with Ubuntu involve the use of the network-manager-openvpn plugin. This is not in any of the repos I use for CentOS 7 so I decided to just run the openvpn client manually. If I run this command as root I can activate the vpn

Code: Select all

openvpn --config bud-b01.ovpn
after entering the credentials for my vpn account. The file bud-b01.ovpn is the configuration file supplied by the provider. I contains the parameters needed to connect to their server in Budapest. I have enhanced this to

Code: Select all

openvpn --config ams-a01.ovpn --auth-user-pass pw
where the credentials are stored in the file pw (which is accessible only to root).

The problem is... after starting the vpn, control never returns to the terminal. I have tried running openvpn in background with & but that does not seem to work either. For the moment I have taken to stashing the terminal out of sight with screen. Not the best option.

Can anyone suggest a better way to fire up openvpn without having a root shell active?

TIA,

Ken

Actually the plugins are named NetworkManager-openvpn and NetworkManager-openvpn-gnome. The first does not seem to work and the second one is colliding with SELinux - and not working. I would like to use the command line as it does work and I understand it.

taylorkh
Posts: 534
Joined: 2010/11/24 15:08:33
Location: North Carolina, USA

Re: Starting openvpn client on CentOS7

Post by taylorkh » 2016/02/19 12:56:21

The package Network-Manager-openvpn does not work. The package Network-Manager-openvpn-gnome does seem to work. I need to test to see if it is stable. I found the vpn to periodically drop when using the network manager approach in Ubuntu. CentOS was much more stable but I had only used it in the command line mode.

I would STILL like to know how to run the command line and get back control so I can close the root shell.

TIA,

Ken

scottro
Forum Moderator
Posts: 2556
Joined: 2007/09/03 21:18:09
Location: NYC
Contact:

Re: Starting openvpn client on CentOS7

Post by scottro » 2016/02/19 22:24:25

I don't use NetworkManager, but frequently read on these, and other forums that it doesn't do something or another properly. OpenVPN requires root because it has to open a route and so on.

A quick google doesn't turn up any easy way around it, but I didn't look that hard.
New users should check the FAQ and Read Me First pages

taylorkh
Posts: 534
Joined: 2010/11/24 15:08:33
Location: North Carolina, USA

Re: Starting openvpn client on CentOS7

Post by taylorkh » 2016/02/20 00:04:29

Thanks scottro,

I had first used the NetworkManager approach on Ubuntu Mate as the instructions from the VPN provider were Ubuntu specific. It would drop the VPN connection and revert to the regular Internet connection which I thought was not very cool. CentOS 6 - from all I read was more work than I was willing to do to get OpenVPN working. The command line in CentOS 7 works fine and seems stable. I guess I need to leave a connection to the VPN server open for a couple of days or until it dies and see what happens. Screen will do for now. I guess if I su first then screen I would have to become root again before I could reattach the running screen (I will have to test).

Ken

scottro
Forum Moderator
Posts: 2556
Joined: 2007/09/03 21:18:09
Location: NYC
Contact:

Re: Starting openvpn client on CentOS7

Post by scottro » 2016/02/20 01:32:14

That's how screen or tmux works. If you create the screen session as root, you'll have to be root to reattach that session.
New users should check the FAQ and Read Me First pages

taylorkh
Posts: 534
Joined: 2010/11/24 15:08:33
Location: North Carolina, USA

Re: Starting openvpn client on CentOS7

Post by taylorkh » 2016/02/20 01:44:01

Thanks again scottro,

I have confirmed that by test. Not too bad of a workaround.

Ken

User avatar
jlehtone
Posts: 4530
Joined: 2007/12/11 08:17:33
Location: Finland

Re: Starting openvpn client on CentOS7

Post by jlehtone » 2016/02/20 23:20:19

Code: Select all

sudo systemctl start openvpn@configname.service
CentOS 6 had "sudo service openvpn start", which did start all tunnels (aka /etc/openvpn/*.conf).
The systemd-version has separate .service for each connection.

That still does require root-privileges, but no shell has to stay open.

taylorkh
Posts: 534
Joined: 2010/11/24 15:08:33
Location: North Carolina, USA

Re: Starting openvpn client on CentOS7

Post by taylorkh » 2016/02/20 23:40:38

Thanks jlehtone,

I will look into that option.

Ken

scottro
Forum Moderator
Posts: 2556
Joined: 2007/09/03 21:18:09
Location: NYC
Contact:

Re: Starting openvpn client on CentOS7

Post by scottro » 2016/02/21 12:44:55

I want to add my thanks to jlehtone as well. My own personal use case is to have it open for short intervals, so I never even looked at whether or not it was a service.
New users should check the FAQ and Read Me First pages

anders_tn
Posts: 10
Joined: 2014/03/10 00:37:28

Re: Starting openvpn client on CentOS7

Post by anders_tn » 2017/12/02 10:45:37

Which package did you install to get this. When I installed OpenVPN client it didn't create any of the systemctl stuff so using "service openvpn@... start" just spits out an error that the serice files are missing :(

Post Reply