Меню Рубрики

Vpn l2tp ipsec linux

Установка и настройка L2TP VPN-сервера на Ubuntu Server

L2TP сервер удобен тем, что позволяет использовать встроенные средства Windows для подключения. В данной инструкции рассмотрим процесс его установки и настройки на Ubuntu 16.04 и 18.04. В итоге мы получим:

  • VPN-сервер, использующий туннельный протокол L2TP.
  • Защита соединения посредством общего ключа + аутентификация пользователя.
  • Доступ к локальной сети.

Мы выполним следующие настройки:

Настройка IPSEC

Для управления IPSec используется пакет strongswan — установим его командой:

apt-get install strongswan

Открываем конфигурационный файл для настройки ipsec:

Для config setup добавим:

config setup
virtual_private=%v4:10.0.0.0/8,%v4:192.168.0.0/16,%v4:172.16.0.0/12
protostack=netkey

* где virtual_private для нас является наиболее важным параметром и определяет приватные сети. В данном примере просто перечислены сети, зарезервированные под локальные — мы можем указать и другие.

. а также вставляем ниже:

conn l2tpvpn
type=transport
authby=secret
pfs=no
rekey=no
keyingtries=2
left=%any
leftprotoport=udp/l2tp
leftid=@l2tpvpnserver
right=%any
rightprotoport=udp/%any
auto=add

  • type — тип соединения. Возможны варианты tunnel ( хост-хост, хост-подсеть или подсеть-подсеть); transport (хост-хост); passthrough (без обработки IPsec).
  • authby — способы аутентификации двух узлов. Возможны варианты secret (по паролю) или rsasig (цифровые подписи RSA).
  • pfs — расшифровывается как Perfect Forward Secrecy. Позволяет активировать совершенную секретность в канале ключей соединения.
  • rekey — перепроверить соединение, когда оно истекает.
  • keyingtries — число попыток, чтобы «договориться» о соединении или его замене.
  • left — IP-адрес левого участника (сервера). %any означает, что адрес может быть любой.
  • leftprotoport — определяет протокол и порт, на котором будет работать левая сторона (сервер). В данном примере указан UDP и порт 1701.
  • leftid — идентификация левого участника соединения.
  • right — IP-адрес правого участника (клиента). %any означает, что адрес может быть любой.
  • rightprotoport — определяет протокол и порт, на котором будет работать правая сторона (клиент). В данном примере указан UDP и любой порт.
  • auto — операция, которая должна запуститься автоматически при старте IPsec.

Создаем секретный ключ — для этого открываем на редактирование файл:

%any %any : PSK «my_key_password»

* в данном примере мы устанавливаем общий пароль my_key_password для соединений с любого IP.

Разрешаем автозапуск strongswan и перезапускаем службу:

systemctl enable strongswan

systemctl restart strongswan

Устанавливаем сервер L2TP:

apt-get install xl2tpd

Открываем файл настройки сервера:

[global]
port = 1701
access control = no
ipsec saref = yes
force userspace = yes
auth file = /etc/ppp/chap-secrets

[lns default]
ip range = 176.16.10.10-176.16.10.200
local ip = 176.16.10.1
name = l2tpserver
pppoptfile = /etc/ppp/options.xl2tpd
flow bit = yes
exclusive = no
hidden bit = no
length bit = yes
require authentication = yes
require chap = yes
refuse pap = yes

  • port — порт UDP, на котором работает VPN. По умолчанию, 1701.
  • access control — принимать или нет запросы только от клиентов с определенными IP, перечисленными в настройках клиентов.
  • ipsec saref — указывает использовать или нет ipsec Security Association, позволяющий отслеживать несколько клиентов с одинаковыми IP-адресами.
  • force userspace — повышает производительность за счет декапсуляции пакетов L2TP.
  • auth file — путь к файлу аутентификации.
  • ip range — диапазон адресов, которые назначаются подключенным клиентам.
  • local ip — IP-адрес сервера в сети VPN.
  • name — имя сервера для процесса согласования.
  • pppoptfile — путь к файлу с настройкой pppd.
  • flow bit — позволяет добавлять в пакеты порядковые номера.
  • exclusive — если поставить в yes, сервер разрешит только одно соединение с клиентом.
  • hidden bit — скрывать или нет AVP.
  • length bit — использовать ли бит длины, указывающий полезную нагрузку.
  • require authentication — требовать ли аутентификацию.
  • require chap — требовать ли аутентификацию PPP по протоколу CHAP.
  • refuse pap — требовать ли аутентификацию PPP по протоколу PAP.

Разрешаем автозапуск vpn-сервера и перезапускаем его:

systemctl enable xl2tpd

systemctl restart xl2tpd

Открываем на редактирование конфигурационный файл:

Источник

How to Setup an L2TP/IPsec VPN Client on Linux

L2TP (which stands for Layer 2 Tunneling Protocol) is a tunneling protocol designed to support virtual private networks (VPN connections) over the internet. It is implemented in most if not all modern operating systems including Linux and VPN-capable devices.

The L2TP does not provide any authentication or encryption mechanisms directly to traffic that passes through it, it is usually implemented with the IPsec authentication suite (L2TP/IPsec) to provide encryption within the L2TP tunnel.

In this article, we will show how to set up an L2TP/IPSec VPN connection in Ubuntu and its derivatives and Fedora Linux.

This guide assumes that the L2TP/IPsec VPN server has been set up and that you have received the following VPN connection details from your organization’s or company’s system administrator.

How to Setup L2TP VPN Connection in Linux

To add an L2TP/IPsec option to the NetworkManager, you need to install the NetworkManager-l2tp VPN plugin which supports NetworkManager 1.8 and later. It provides support for L2TP and L2TP/IPsec.

To install the L2TP module on Ubuntu and Ubuntu-based Linux distributions, use the following PPA.

On RHEL/CentOS and Fedora Linux, use the following dnf command to install L2TP module.

Once the package installation is complete, click on your Network Manager icon, then go to Network Settings.

Access Network Settings

Next, add a new VPN connection by clicking on the (+) sign.

Add New VPN Connection

Then select Layer 2 Tunneling Protocol (L2TP) option from the pop-up window.

Select Layer 2 Tunneling Protocol

Next, enter the VPN connection details (gateway IP address or hostname, username and password) you received from the system administrator, in the following window.

Next, click IPsec Settings to enter the pre-shared key for the connection. Then enable IPsec tunnel to L2TP host, enter (or copy and paste the) the Pre-shared key and click Ok.

After that, click Add. Now your new VPN connection should be added.

VPN Connection Created

Next, turn on the VPN connection to start using it. If the connection details are correct, the connection should be established successfully.

Enable VPN Connection Enabled VPN Connection

Last but not least, test if the VPN is working fine. You can check your computer’s public IP address to confirm this from a web browser: it should now point to the IP of the gateway.

Confirm Your VPN Connection

That’s the end of this article. If you have any queries or thoughts to share, reach us via the feedback form below.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

We are thankful for your never ending support.

Источник

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

Ваш адрес email не будет опубликован. Обязательные поля помечены *

  • Секундомер для mac os
  • Секреты терминала в mac os x
  • Секреты mac os sierra
  • Секвенсор для mac os
  • Сделать шрифт в windows как в mac os