How to configure the openvpn client on linux (debian, ubuntu, mint)

Andy Wits Blog

and also make ** the prohibition of traffic leaks past vpn **

!! in Debian: everything needs to be done as root in Ubuntu and Mint, you need to add sudo to all commands.

  1. Setup openvpn client
apt-get install openvpn
  1. Make sure that the openvpn clien version is 2.1 or above
openvpn --version
  1. Start although the easiest way is to run from the line with the specification of the configuration file
openvpn --config client.ovpn

but we will do it in the Debian way

  • move the client files (crt, key, ovpn) to the /etc/openvpn directory
mv dir-with-crt-key-ovpn-files/* /etc/openvpn

(after that you need to check that the configuration file is called client.conf - if not - rename)

  • start the service
/etc/init.d/openvpn start

With the following command you can see the process

ps aux | grep openvpn

You can also check by going to the sites that define ip now works, there is a little bit to adjust

  1. Configuring startup on reboot install sysv-rc-conf package
aptitude install sysv-rc-conf

run the command sysv-rc-conf and set or disable from 2-5 levels of the mark on the service openvpn (Similarly, you can disable the network manager, if necessary) Exit the utility with the "q" command

  1. In order for the traffic not to go past vpn, we'll run openvpn with the script:

create and fill the script:

echo '#!/bin/bash' > /etc/openvpn/openvpn.sh
echo '/etc/init.d/openvpn restart && sleep 5 && ip r d `ip r s | grep default`' >> /etc/openvpn/openvpn.sh

make it executable:

chmod +x /etc/openvpn/openvpn.sh

Now you can run it from the command line by simple typing

/etc/openvpn/openvpn.sh

or

sh /etc/openvpn/openvpn.sh

as well as double-clicking

Published on Oct 31 2014 at 12:00 am
Time to read 1 minute(s)
Categories
  • System Administration

Contact me on