Difference between revisions of "Setup OpenVPN Client in Linux Ubuntu"
(Created page with "== Purpose == We'll install an OpenVPN client in Linux Ubuntu 18 server. So this server can use OpenVPN client to connect to a vpn network. <br>Make sure we already have an o...") |
|||
Line 8: | Line 8: | ||
root@gejoreuy:~# wget -O - https://swupdate.openvpn.net/repos/repo-public.gpg| sudo apt-key add - | root@gejoreuy:~# wget -O - https://swupdate.openvpn.net/repos/repo-public.gpg| sudo apt-key add - | ||
root@gejoreuy:~# echo "deb http://build.openvpn.net/debian/openvpn/stable $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/openvpn-aptrepo.list | root@gejoreuy:~# echo "deb http://build.openvpn.net/debian/openvpn/stable $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/openvpn-aptrepo.list | ||
+ | root@gejoreuy:~# apt update | ||
+ | |||
+ | == Install OpenVPN Client == | ||
+ | |||
+ | Install OpenVPN client : | ||
+ | |||
+ | root@gejoreuy:~# apt install openvpn | ||
+ | |||
+ | Check and make sure OpenVPN client already installed : | ||
+ | |||
+ | root@gejoreuy:~# openvpn --version | ||
+ | |||
+ | Start and enable OpenVPN client : | ||
+ | |||
+ | root@gejoreuy:~# systemctl start openvpn | ||
+ | root@gejoreuy:~# systemctl enable openvpn | ||
+ | |||
+ | == Set Client Configuration == | ||
+ | |||
+ | We can put the ovpn file in this path (change the source address) : | ||
+ | |||
+ | root@gejoreuy:~# mv /source/client-name.ovpn /etc/openvpn/client/client-name.ovpn | ||
+ | |||
+ | We also can set secret file to make our vpn client can connect to vpn network automatically without asking password : | ||
+ | |||
+ | root@gejoreuy:~# vi /etc/openvpn/client/client-secret.scrt | ||
+ | |||
+ | Insert this file with two rows that contain user and password value : | ||
+ | |||
+ | username | ||
+ | password | ||
+ | |||
+ | Set the file to make only user and root can read it : | ||
+ | |||
+ | root@gejoreuy:~# chmod go-rw /etc/openvpn/client/client-secret.scrt | ||
+ | |||
+ | == Try to Connect to VPN Network == | ||
+ | |||
+ | Connect to VON network : | ||
+ | |||
+ | root@gejoreuy:~# openvpn --config /etc/openvpn/client/client-name.ovpn | ||
+ | |||
+ | Test the conection (change some-vpn-node-address with the real address) : | ||
+ | |||
+ | root@gejoreuy:~# ping some-vpn-node-address | ||
+ | PING 10.22.73.23 (10.22.73.23) 56(84) bytes of data. | ||
+ | 64 bytes from 10.22.73.23: icmp_seq=1 ttl=63 time=275 ms | ||
+ | 64 bytes from 10.22.73.23: icmp_seq=2 ttl=63 time=274 ms | ||
+ | 64 bytes from 10.22.73.23: icmp_seq=3 ttl=63 time=272 ms | ||
+ | ^C | ||
+ | --- 10.22.73.23 ping statistics --- | ||
+ | 4 packets transmitted, 3 received, 25% packet loss, time 3001ms | ||
+ | rtt min/avg/max/mdev = 272.416/273.902/275.165/1.211 ms |
Revision as of 13:58, 12 October 2020
Contents
Purpose
We'll install an OpenVPN client in Linux Ubuntu 18 server. So this server can use OpenVPN client to connect to a vpn network.
Make sure we already have an ovpn file that created in OpenVPN server. Please refer to this page Setup OpenVPN Server in AWS VPC.
Preparation
root@gejoreuy:~# wget -O - https://swupdate.openvpn.net/repos/repo-public.gpg%7C sudo apt-key add - root@gejoreuy:~# echo "deb http://build.openvpn.net/debian/openvpn/stable $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/openvpn-aptrepo.list root@gejoreuy:~# apt update
Install OpenVPN Client
Install OpenVPN client :
root@gejoreuy:~# apt install openvpn
Check and make sure OpenVPN client already installed :
root@gejoreuy:~# openvpn --version
Start and enable OpenVPN client :
root@gejoreuy:~# systemctl start openvpn root@gejoreuy:~# systemctl enable openvpn
Set Client Configuration
We can put the ovpn file in this path (change the source address) :
root@gejoreuy:~# mv /source/client-name.ovpn /etc/openvpn/client/client-name.ovpn
We also can set secret file to make our vpn client can connect to vpn network automatically without asking password :
root@gejoreuy:~# vi /etc/openvpn/client/client-secret.scrt
Insert this file with two rows that contain user and password value :
username password
Set the file to make only user and root can read it :
root@gejoreuy:~# chmod go-rw /etc/openvpn/client/client-secret.scrt
Try to Connect to VPN Network
Connect to VON network :
root@gejoreuy:~# openvpn --config /etc/openvpn/client/client-name.ovpn
Test the conection (change some-vpn-node-address with the real address) :
root@gejoreuy:~# ping some-vpn-node-address PING 10.22.73.23 (10.22.73.23) 56(84) bytes of data. 64 bytes from 10.22.73.23: icmp_seq=1 ttl=63 time=275 ms 64 bytes from 10.22.73.23: icmp_seq=2 ttl=63 time=274 ms 64 bytes from 10.22.73.23: icmp_seq=3 ttl=63 time=272 ms ^C --- 10.22.73.23 ping statistics --- 4 packets transmitted, 3 received, 25% packet loss, time 3001ms rtt min/avg/max/mdev = 272.416/273.902/275.165/1.211 ms