Get Social

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

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

2. Make sure that the openvpn clien version is 2.1 or above

openvpn --version

3. 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

4. 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

5. 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/
echo '/etc/init.d/openvpn restart && sleep 5 && ip r d `ip r s | grep default`' >> /etc/openvpn/

make it executable:

chmod +x /etc/openvpn/

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



sh /etc/openvpn/

as well as double-clicking