VPN на VPS/VDS хостинге

Инструкция по установке и настройке OpenVPN на хостинге.

1. Выбираем VPS хостинг

Я выбрал Zomro. Присмотрел ещё Perfect Quality Hosting. Пользуйтесь поиском.

2. Обновляем ОС

В панели управления заказываем ОС. Я выбрал Debian 11. Подключаемся с помощью PuTTY, обновляем систему:

apt update
apt upgrade

3. Загружаем скрипт

cd /rootwget https://raw.githubusercontent.com/angristan/openvpn-install/master/openvpn-install.sh

Делаем скрипт исполняемым:

chmod +x openvpn-install.sh

4. Установка OpenVPN на хостинг

./openvpn-install.sh

Перед установкой установщик задаёт вопросы..

Welcome to the OpenVPN installer!
The git repository is available at: https://github.com/angristan/openvpn-install

I need to ask you a few questions before starting the setup.
You can leave the default options and just press enter if you are ok with them.

I need to know the IPv4 address of the network interface you want OpenVPN listening to.
Unless your server is behind NAT, it should be your public IPv4 address.
IP address:

Нужно ли включать IPv6. Смотрите свой тариф. По умолчанию стоит n, так и оставляем.

Do you want to enable IPv6 support (NAT)? [y/n]: n

По умолчанию порт 1194.

What port do you want OpenVPN to listen to?
   1) Default: 1194
   2) Custom
   3) Random [49152-65535]
Port choice [1-3]: 1
Протокол UDP.
What protocol do you want OpenVPN to use?
UDP is faster. Unless it is not available, you shouldn't use TCP.
   1) UDP
   2) TCP
Protocol [1-2]: 1

Выбираем DNS сервера. Я выбрал AdGuard DNS — реклама гасится сама. 🙂

What DNS resolvers do you want to use with the VPN?
   1) Current system resolvers (from /etc/resolv.conf)
   2) Self-hosted DNS Resolver (Unbound)
   3) Cloudflare (Anycast: worldwide)
   4) Quad9 (Anycast: worldwide)
   5) Quad9 uncensored (Anycast: worldwide)
   6) FDN (France)
   7) DNS.WATCH (Germany)
   8) OpenDNS (Anycast: worldwide)
   9) Google (Anycast: worldwide)
   10) Yandex Basic (Russia)
   11) AdGuard DNS (Anycast: worldwide)
   12) NextDNS (Anycast: worldwide)
   13) Custom
DNS [1-12]: 11

Сжатие не нужно.

Do you want to use compression? It is not recommended since the VORACLE attack makes use of it.
Enable compression? [y/n]: n

Шифрование тоже.

Do you want to customize encryption settings?
Unless you know what you're doing, you should stick with the default parameters provided by the script.
Note that whatever you choose, all the choices presented in the script are safe. (Unlike OpenVPN's defaults)
See https://github.com/angristan/openvpn-install#security-and-encryption to learn more.

Customize encryption settings? [y/n]: n
Okay, that was all I needed. We are ready to setup your OpenVPN server now.
You will be able to generate a client at the end of the installation.
Press any key to continue...

5. Добавляем клиентов OpenVPN

После установки, будет предложено ввести имя пользователя.

Tell me a name for the client.
The name must consist of alphanumeric character. It may also include an underscore or a dash.
Client name: superpuperuser

Хотите ли вы защитить файл конфигурации паролем?

Do you want to protect the configuration file with a password?
(e.g. encrypt the private key with a password)
   1) Add a passwordless client
   2) Use a password for the client
Select an option [1-2]: 1

Всё. Теперь есть работающий VPN. Файл конфигурации лежит в папке /root/

Client superpuperuser added.

The configuration file has been written to /root/superpuperuser.ovpn.
Download the .ovpn file and import it in your OpenVPN client.

Теперь с помощью FileZilla нужно скачать файл конфигурации и скормить его программе OpenVPN в win’де или android’е.

6. Настройка подключения нескольких устройств

С помощью FileZilla идём по пути /etc/openvpn, прямо в нём открываем файл server.conf (Просмотр/Правка в контекстном меню). В самый низ добавляем:

duplicate-cn
max-clients 10

Сохраняем файл и соглашаемся на замену его на сервере.

Перезагружаем систему.

reboot

Теперь по одному файлу конфигурации можно подключить до 10 устройств.

7. Добавление нового пользователя

Если в будущем нужно будет добавить нового пользователя или Вы не хотите применять 6-й пункт:

./openvpn-install.sh

Применяя эту команду можно добавить / удалить пользователей и, даже, удалить сам OpenVPN.

zomro

Добавить комментарий