Логи подключения клиента к openvpn серверу(подключение удачно проходит, ip получает из нашего пула, dns тоже удачно приходят вроде как):
Ниже в логах есть предупреждение интересное, но redirect-privat я вроде нигде не использовал а вот redirect-gateway опцию я использовал как в клиентском конфиге так и на сервере, так как это рекомендовалось в мануалах.
2024-09-08 19:54:52 WARNING: You have specified redirect-gateway and redirect-private at the same time (or the same option multiple times). This is not well supported and may lead to unexpected results
root@tester-VirtualBox:/home/tester/Downloads# openvpn --config ./tester.ovpn
Note: --data-cipher-fallback with cipher 'AES-256-CBC' disables data channel offload.
OpenVPN 2.6.9 x86_64-pc-linux-gnu [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [PKCS11] [MH/PKTINFO] [AEAD] [DCO]
library versions: OpenSSL 3.0.13 30 Jan 2024, LZO 2.10
DCO version: N/A
Enter Private Key Password: ••••••••••
TCP/UDP: Preserving recently used remote address: [AF_INET]192.168.1.51:1194
Socket Buffers: R=[212992->212992] S=[212992->212992]
UDPv4 link local: (not bound)
UDPv4 link remote: [AF_INET]192.168.1.51:1194
TLS: Initial packet from [AF_INET]192.168.1.51:1194, sid=a97af0f4 b802a614
VERIFY OK: depth=1, CN=ChangeMe
VERIFY KU OK
Validating certificate extended key usage
++ Certificate has EKU (str) TLS Web Server Authentication, expects TLS Web Server Authentication
VERIFY EKU OK
VERIFY OK: depth=0, CN=server
Control Channel: TLSv1.3, cipher TLSv1.3 TLS_AES_256_GCM_SHA384, peer certificate: 2048 bits RSA, signature: RSA-SHA256, peer temporary key: 253 bits X25519
[server] Peer Connection Initiated with [AF_INET]192.168.1.51:1194
TLS: move_session: dest=TM_ACTIVE src=TM_INITIAL reinit_src=1
TLS: tls_multi_process: initial untrusted session promoted to trusted
PUSH: Received control message: 'PUSH_REPLY,redirect-gateway def1,dhcp-option DNS 8.8.8.8,dhcp-option DNS 8.8.4.4,route-gateway 10.8.0.1,topology subnet,ping 10,ping-restart 120,ifconfig 10.8.0.2 255.255.255.0,peer-id 0,cipher AES-256-GCM'
WARNING: You have specified redirect-gateway and redirect-private at the same time (or the same option multiple times). This is not well supported and may lead to unexpected results
OPTIONS IMPORT: --ifconfig/up options modified
OPTIONS IMPORT: route options modified
OPTIONS IMPORT: route-related options modified
OPTIONS IMPORT: --ip-win32 and/or --dhcp-option options modified
net_route_v4_best_gw query: dst 0.0.0.0
net_route_v4_best_gw result: via 192.168.1.254 dev enp0s3
ROUTE_GATEWAY 192.168.1.254/255.255.255.0 IFACE=enp0s3 HWADDR=08:00:27:ec:97:0a
TUN/TAP device tun0 opened
net_iface_mtu_set: mtu 1500 for tun0
net_iface_up: set tun0 up
net_addr_v4_add: 10.8.0.2/24 dev tun0
net_route_v4_add: 192.168.1.51/32 via 192.168.1.254 dev enp0s3 table 0 metric -1
net_route_v4_add: 0.0.0.0/1 via 10.8.0.1 dev [NULL] table 0 metric -1
net_route_v4_add: 128.0.0.0/1 via 10.8.0.1 dev [NULL] table 0 metric -1
Initialization Sequence Completed
Data Channel: cipher 'AES-256-GCM', peer-id: 0
Timers: ping 10, ping-restart 120
Вот шаблон конфига .ovpn для пользователя:
client
dev tun // наш виртуальный интерфейс
proto udp4 // Только IpV4
remote 192.168.1.51 1194 // ip нашего openvpn сервака(наша VM)
resolv-retry infinite
nobind
persist-key
persist-tun
remote-cert-tls server
data-ciphers AES-256-GCM
data-ciphers-fallback AES-256-CBC
auth SHA256
tun-mtu 1500
auth-nocache
redirect-gateway def1 // Весь трафик через vpn сервер
pull // Получать настройки(DNS итд) от сервера
verb 3
Конфиг openvpn сервера в нашем docker контейнере:
port 1194
dev tun // наш виртуальный интерфейс
topology subnet
proto udp4
tun-mtu 1500
push "redirect-gateway def1" // отправляем клиенту что весь трафик должен идти через нас
push "dhcp-option DNS 8.8.8.8" // задаем DNS
push "dhcp-option DNS 8.8.4.4"
tls-auth /etc/openvpn/ta.key 0
ca /etc/openvpn/easy-rsa/pki/ca.crt
cert /etc/openvpn/easy-rsa/pki/issued/server.crt
key /etc/openvpn/easy-rsa/pki/private/server.key
dh /etc/openvpn/easy-rsa/pki/dh.pem
crl-verify /etc/openvpn/easy-rsa/pki/crl.pem
server 10.8.0.0 255.255.255.0
keepalive 10 120
data-ciphers AES-256-GCM
data-ciphers-fallback AES-256-CBC
auth SHA256
user nobody
group nogroup
persist-key
persist-tun
status openvpn-status.log 10
log-append /var/log/openvpn.log
verb 5
В логах openvpn сервера я вижу что он дропает мои пакеты так как ему не нравится ip(bad source address from client)
ess from client [192.168.1.51], packet dropped
R2024-09-08 18:04:21 us=982940 tester/192.168.1.51:56940 MULTI: bad source address from client [192.168.1.51], packet dropped