Пакет OpenVPN
Установка сервиса
Debian/Ubuntu
CentOS 7
Настройка client/server конфигурации
Настройка с использованием клиентских сертификатов
Настройка сервера
# cp ca.* /etc/ssl/certs/
# cp gate.crt /etc/ssl/certs/
# cp gate.key /etc/ssl/private/
gate# cat /etc/openvpn/openvpn1.conf
dev tun
# port 1194
# proto udp
keepalive 10 120
server 192.168.200+X.0 255.255.255.0
push "route 192.168.100+X.0 255.255.255.0"
#push "route 192.168.X.0 255.255.255.0"
#push "dhcp-option DNS 192.168.X.10"
#push "block-outside-dns"
#push "dhcp-option DOMAIN corpX.un"
dh /etc/openvpn/dh2048.pem
ca /etc/ssl/certs/ca.crt
crl-verify /etc/ssl/certs/ca.crl
cert /etc/ssl/certs/gate.crt
key /etc/ssl/private/gate.key
status /var/log/openvpn1-status.log
Тестирование конфигурации
# openvpn --config /etc/openvpn/openvpn1.conf
# timeout 5 openvpn --port 65500 --config /etc/openvpn/openvpn1.conf; test $? -eq 124 && echo OK
Включение и запуск
# systemctl enable openvpn@openvpn1
# systemctl start openvpn@openvpn1
Настройка клиента
Windows
Start OpenVPN GUI
C:\>notepad C:\Users\student\OpenVPN\config\user1.ovpn
dev tun
# port 1194
# proto udp
client
remote 172.16.1.X
ca ca.crt
cert user1.crt
key user1.key
Linux
debian:~# apt install openvpn resolvconf wget
debian:~# openvpn --script-security 2 --up /etc/openvpn/update-resolv-conf --down /etc/openvpn/update-resolv-conf --config user1.ovpn
Индивидуальная настройка параметров клиентов
gate# cat /etc/openvpn/openvpn1.conf
...
client-config-dir ccd
#route 192.168.100+Y.0 255.255.255.0
...
gate# cat /etc/openvpn/ccd/userN
ifconfig-push 192.168.200+X.4*N+2 192.168.200+X.4*N+1
#iroute 192.168.100+Y.0 255.255.255.0
Использование PAM аутентификации
gate# less /etc/pam.d/login
gate# cat /etc/openvpn/openvpn1.conf
...
#### crl-verify ...
ca /etc/ssl/certs/server.crt
cert /etc/ssl/certs/server.crt
...
plugin /usr/lib/x86_64-linux-gnu/openvpn/plugins/openvpn-plugin-auth-pam.so login
verify-client-cert none
username-as-common-name
#duplicate-cn #несколько подключений под одной учетной записью
cmd run as admin C:\>notepad C:\Program Files\OpenVPN\config\client.ovpn
...
auth-user-pass
<ca>
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
</ca>
Использование RADIUS аутентификации и учета
Настройка peer2peer конфигурации
Debian/Ubuntu/FreeBSD
gate.corpX.un# cd /etc/openvpn/
gate.corpX.un# openvpn --genkey --secret static.key
gate.corpX.un# scp static.key gate.corpY.un:/etc/openvpn/
gate.corpX.un# cat connect_to_Y.conf
dev tun
remote 172.16.1.Y
port 1195
# proto udp
keepalive 10 120
ifconfig 192.168.X+Y.X 192.168.X+Y.Y
route 192.168.100+Y.0 255.255.255.0
secret /etc/openvpn/static.key
FreeBSD
# cd /usr/local/etc/rc.d/
# ln -s openvpn connect_to_Y
# cat /etc/rc.conf
...
connect_to_Y_enable=yes
Мониторинг сервиса
gate# cat /var/log/openvpn1-status.log
gate# tail -f /var/log/syslog
gate# cat /etc/openvpn/openvpn1.conf
...
management localhost 7505
# management 0.0.0.0 7505
...
gate# telnet localhost 7505
status
kill user1