Openvpn client linux ubuntu

How to Install & Connect OpenVPN Client on Ubuntu

Are you looking to install and connect OpenVPN Client on Ubuntu? It’s easy to do! In this guide, we’ll walk you through the process step-by-step. Assuming one of your clients wants to secure a connection to their server. The client has configured OpenVPN server on their network and provide you client configuration file. By the end, you’ll have a secure, encrypted connection to your VPN server. So, let’s get started!

Prerequisites

Before you can install OpenVPN Client on Ubuntu, you’ll need to make sure you have the following:

  • The latest version of Ubuntu is installed on your computer.
  • A reliable internet connection.
  • An OpenVPN configuration file, which you can get from your VPN provider.
  • A working VPN account.

Once you have all the prerequisites in place, you’re ready to start installing OpenVPN Client on Ubuntu.

Step 1 – Installing OpenVPN Client on Ubuntu

Installing OpenVPN Client on Ubuntu is relatively easy. Just follow the steps below and you should be up and running in no time.

    Open a terminal window on your Ubuntu machine and type in the following command: sudo apt install openvpn . This will install the OpenVPN package on your system.

sudo apt update && sudo apt install openvpn -y 
sudo nano /etc/openvpn/client.conf 

Step 2 – Connecting to a VPN Server with OpenVPN Client

Once you’ve installed OpenVPN Client on Ubuntu, you can easily connect to a VPN server. All you need to do is type in the following command in the terminal window:

sudo openvpn --config /etc/openvpn/client.conf 

This will start the OpenVPN Client and you’ll be prompted to enter your VPN username and password. Once you’ve done that, you’ll be connected to the VPN server.

Output:
Sat Feb 29 15:39:18 2020 TCP/UDP: Preserving recently used remote address: [AF_INET]69.87.218.145:1194 Sat Feb 29 15:39:18 2020 Socket Buffers: R=[212992->212992] S=[212992->212992] Sat Feb 29 15:39:18 2020 UDP link local: (not bound) Sat Feb 29 15:39:18 2020 UDP link remote: [AF_INET]69.87.218.145:1194 Sat Feb 29 15:39:18 2020 TLS: Initial packet from [AF_INET]69.87.218.145:1194, sid=6d27e1cb 524bd8cd Sat Feb 29 15:39:18 2020 VERIFY OK: depth=1, CN=Easy-RSA CA Sat Feb 29 15:39:18 2020 VERIFY OK: depth=0, CN=tecadmin-server Sat Feb 29 15:39:18 2020 Control Channel: TLSv1.3, cipher TLSv1.3 TLS_AES_256_GCM_SHA384, 2048 bit RSA Sat Feb 29 15:39:18 2020 [tecadmin-server] Peer Connection Initiated with [AF_INET]69.87.218.145:1194 Sat Feb 29 15:39:19 2020 SENT CONTROL [tecadmin-server]: 'PUSH_REQUEST' (status=1) Sat Feb 29 15:39:19 2020 PUSH: Received control message: 'PUSH_REPLY,redirect-gateway def1,dhcp-option DNS 208.67.222.222,dhcp-option DNS 208.67.220.220,route 10.8.0.1,topology net30,ping 20,ping-restart 60,ifconfig 10.8.0.6 10.8.0.5,peer-id 0,cipher AES-256-GCM' Sat Feb 29 15:39:19 2020 OPTIONS IMPORT: timers and/or timeouts modified Sat Feb 29 15:39:19 2020 OPTIONS IMPORT: --ifconfig/up options modified Sat Feb 29 15:39:19 2020 OPTIONS IMPORT: route options modified

Step 3 – Verify Connection

Once your client machine successfully established the VPN connection, A new virtual interface is created on your system named tun0. The OpenVPN server assigned an IP address to this interface based on server configuration. This IP will be in the same network as the VPN server. To view IP address of this virtual interface, type:

Output:
4: tun0: mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 100 link/none inet 10.8.0.6 peer 10.8.0.5/32 scope global tun0 valid_lft forever preferred_lft forever inet6 fe80::7226:57b1:f101:313b/64 scope link stable-privacy valid_lft forever preferred_lft forever

You can also check the OpenVPN server log to verify the connection status:

sudo tail -f /var/log/openvpn.log 

You should see the following output:

Output:
Fri Feb 21 15:39:18 2020 45.58.34.83:37445 Control Channel: TLSv1.3, cipher TLSv1.3 TLS_AES_256_GCM_SHA384, 2048 bit RSA Sat Feb 29 15:41:18 2020 45.58.34.83:37445 [client] Peer Connection Initiated with [AF_INET]45.58.34.83:37445 Sat Feb 29 15:41:18 2020 client/45.58.34.83:37445 MULTI_sva: pool returned IPv4=10.8.0.6, IPv6=(Not enabled) Sat Feb 29 15:41:18 2020 client/45.58.34.83:37445 MULTI: Learn: 10.8.0.6 -> client/45.58.34.83:37445 Sat Feb 29 15:41:18 2020 client/45.58.34.83:37445 MULTI: primary virtual IP for client/45.58.34.83:37445: 10.8.0.6 Sat Feb 29 15:41:19 2020 client/45.58.34.83:37445 PUSH: Received control message: 'PUSH_REQUEST' Sat Feb 29 15:41:19 2020 client/45.58.34.83:37445 SENT CONTROL [client]: 'PUSH_REPLY,redirect-gateway def1,dhcp-option DNS 208.67.222.222,dhcp-option DNS 208.67.220.220,route 10.8.0.1,topology net30,ping 20,ping-restart 60,ifconfig 10.8.0.6 10.8.0.5,peer-id 0,cipher AES-256-GCM' (status=1) Sat Feb 29 15:41:19 2020 client/45.58.34.83:37445 Data Channel: using negotiated cipher 'AES-256-GCM' Sat Feb 29 15:41:19 2020 client/45.58.34.83:37445 Outgoing Data Channel: Cipher 'AES-256-GCM' initialized with 256 bit key Sat Feb 29 15:41:19 2020 client/45.58.34.83:37445 Incoming Data Channel: Cipher 'AES-256-GCM' initialized with 256 bit key

Troubleshooting Tips for Installing OpenVPN Client on Ubuntu

If you’re having trouble installing OpenVPN Client on Ubuntu, here are a few troubleshooting tips that might help:

  • Make sure that your OpenVPN configuration file is correct. Double-check it for any typos or errors and make sure all the settings are correct.
  • Make sure that your internet connection is stable and fast. If your connection is slow or unreliable, it may cause issues with the installation process.
  • If you’re still having trouble, try reinstalling the OpenVPN package. You can do this by typing in the following command in the terminal window: sudo apt —purge remove openvpn followed by sudo apt install openvpn .
  • If you still can’t get it to work, try using a different OpenVPN client. There are several alternatives available such as OpenConnect, OpenVPN GUI, or Viscosity.
Читайте также:  Rdp over https linux

Alternatives to Installing OpenVPN Client on Ubuntu

If you don’t want to install OpenVPN Client on Ubuntu, there are several alternatives available. Here are some of the most popular ones:

  • OpenConnect – This is an open-source VPN client that is compatible with most VPN providers. It supports both command-line and GUI options.
  • OpenVPN GUI – This is a graphical user interface for OpenVPN. It’s user-friendly and easy to set up.
  • Viscosity – This is a commercial VPN client that supports a wide range of VPN protocols. It’s user-friendly and fully featured.

Conclusion

Installing OpenVPN Client on Ubuntu is easy. Just follow the steps outlined in this guide and you’ll be connected to a secure, encrypted VPN server in no time. Make sure to double-check your OpenVPN configuration file for any typos or errors, and if you’re still having trouble, try using a different OpenVPN client. Good luck!

If you found this guide helpful, please share it with your friends and family. And if you have any questions or comments, feel free to leave them in the comments section below.

Источник

Ubuntu → Настраиваем OpenVPN клиент Linux на примере Ubuntu

Здравствуйте.
Как и обещал, в выкладываю статью по настройке OpenVPN клиента Linux, мы с вами уже настроили OpenVPN сервер, и нам осталось настроить подключение к нему, иначе для чего он нам нужен, если к нему никто не подключается… С данным мануалом настройка будет весьма проста, эта схема была успешно оттестирована в условиях IT компании и работает по сей день.

sudo apt-get install openvpn

Теперь нам необходимо создать конфигурационный файл клиента.

nano /etc/openvpn/client.conf
# Тип подключения -клиент client # Через какое устройстов подлючаемся dev tun0 # Через какой протокол работаем, такойже как на сервере proto tcp # Адрес OpenVPN сервера и его порт (можно указать IP или URL) remote openvpn.example.org 1194 # Тип шифрования, как на OpenVPN сервере cipher AES-256-CBC # Сертификат удостоверяющего центра ca ca.crt # Сертификат и ключ клиента cert user.crt key user.key # Клиент поддерживает шифрование tls-client # Указываем путь к ключу TLS tls-auth ta.key 1 # Включаем компрессию данных comp-lzo persist-key persist-tun # В документации рекомендуется этот пункт для клиентов с нестабильым доступом, например Wi-Fi resolv-retry infinite # Не использовать специфический порт для работы nobind # Скрипт работает при подключении, он обновляет записи в resolv.conf при подключении к серверу и очищает их при отколючении от OpenVPN сервера script-security 2 up /etc/openvpn/update-resolv-conf down /etc/openvpn/update-resolv-conf # Статус-лог переданные данные и т.п. status /var/log/openvpn-status.log # Лог клиента log /var/log/openvpn.log # Уровень логирования 0 в лог попадают только записи о критических ошибках, если нужно подробнее, то выставляем 9 для дебагинга verb 0 # Количество записей после которых будет производиться запись в лог mute 20

Нам остаётся скачать c OpenVPN сервера, где живет наш удостоверяющий центр, 4 файла:

ca.crt user.crt user.key ta.key

И положить их в директорию /etc/openvpn рядом с файлом client.conf

Читайте также:  Active directory and linux dns

т.к. это у нас обычный пользователь, то он должен ходить в нашу локальную сеть, а в интрнет через свое подключение, выясним как ходят пакеты для этого выполним трассировку пакета в локальную сеть:

traceroute 172.16.1.20
traceroute to 172.16.1.20 (172.16.1.20), 30 hops max, 60 byte packets
1 172.16.10.1 (172.16.10.1) 4.066 ms 8.001 ms 7.974 ms
2 172.16.1.20 (172.16.1.20) 7.952 ms 7.931 ms 7.910 ms

Видно что пакет ушел на адрес 172.16.10.1 и с интерфеса eth1 в локальную сеть к целевому IP

Выполним трассировку к google.ru, получаем ответ вида:

traceroute google.ru
traceroute to google.ru (173.194.32.159), 30 hops max, 60 byte packets
1 111.111.111.111 (111.111.111.111) 1.360 ms 1.252 ms 1.177 ms
2 46.61.227.225 (46.61.227.225) 1.865 ms 1.271 ms 1.707 ms
3 95.167.90.39 (95.167.90.39) 18.209 ms 95.167.90.37 (95.167.90.37) 18.170 ms 95.167.90.39 (95.167.90.39) 18.496 ms
4 74.125.146.86 (74.125.146.86) 17.827 ms 17.984 ms 17.946 ms
5 216.239.42.97 (216.239.42.97) 17.771 ms 18.058 ms 18.319 ms
6 216.239.42.83 (216.239.42.83) 17.765 ms 216.239.42.49 (216.239.42.49) 19.130 ms 19.004 ms
7 72.14.236.242 (72.14.236.242) 19.287 ms 18.554 ms 18.802 ms
8 173.194.32.159 (173.194.32.159) 18.025 ms 18.269 ms 18.224 ms

Видно что ответ вылетел черз шлюз сети к которой подключен клиент, а не через наш VPN канал

Для обычного пользователя все работает как надо, чтобы проверить под пользователем supersuer нам необходимо положить ключи в директорию openvpn и поменять запись в client.conf указывающих на названия ключа и сертификата

перезапустить OpenVPN клиента и повторить трасисровку пакетов

traceroute 172.16.1.20
traceroute to 172.16.1.20 (172.16.1.20), 30 hops max, 60 byte packets
1 172.16.10.1 (172.16.10.1) 4.066 ms 8.001 ms 7.974 ms
2 172.16.1.20 (172.16.1.20) 7.952 ms 7.931 ms 7.910 ms

В локальную сеть пакеты ходят без изменений, тут ничего не поменялось

traceroute google.ru
traceroute to google.ru (173.194.122.248), 30 hops max, 60 byte packets
1 172.16.10.1 (172.16.10.1) 6.115 ms 11.448 ms 11.500 ms
2 222.222.222.222 (222.222.222.222) 11.614 ms 11.649 ms 11.676 ms
3 10.158.192.1 (10.158.192.1) 11.691 ms 11.705 ms 11.719 ms
4 v811.m9-3.caravan.ru (212.24.42.49) 11.729 ms 11.744 ms 11.751 ms
5 msk-ix-gw1.google.com (195.208.208.232) 11.736 ms 15.341 ms 15.350 ms
6 66.249.94.100 (66.249.94.100) 15.346 ms 5.884 ms 8.451 ms
7 72.14.252.22 (72.14.252.22) 49.777 ms 49.787 ms 49.796 ms
8 173.194.122.248 (173.194.122.248) 49.510 ms 49.620 ms 49.671 m

А тут видно что пакет попал на наш OpenVPN сервер и вылетел во внешний мир через интерфейс eth0
Значит и эта маршрутизация работает правильно

Читайте также:  Linux sfp module info

На этом я свой опус пожалуй и закончу, если нашли ошибку пишите в личку, возникли вопросы оставляйте их в комментариях.

Источник

Оцените статью
Adblock
detector