AWS 中的 OpenVPN 无法正常工作 - 相同的配置在 DigitalOcean 中有效

AWS 中的 OpenVPN 无法正常工作 - 相同的配置在 DigitalOcean 中有效

我正在尝试在 AWS 环境中设置 VPN 服务器。我使用与在运行的 Digital Ocean 主机上使用的相同配置设置了服务器(服务器 IP 范围和端口不同),并且我可以从运行 tunnelblick 的客户端进行连接。

但是,当我连接到 AWS VPN 服务器时,我的客户端 tunX 设备上没有收到 IP 地址,也没有更新任何路由。当我连接到 DigitalOcean 时,我从 openvpn server.conf 中获取了服务器 IP 范围内的 IP 地址

我在 AWS 上的 VPC 上的 NACL 允许所有入站流量和所有出站流量。

只有一个安全组与 EC2 实例关联,并且允许所有协议为 All、端口范围为 All 且目标为 0.0.0.0/0 的流量

实例上禁用源/目标检查,但启用此功能后会发生相同的行为。

我的 EC2 实例所关联的子网具有通向有效互联网网关的路由,并且可以访问互联网

我的AWS /etc/openvpn/server.conf如下:

port 1194
proto udp
dev tun
ca /etc/openvpn/easy-rsa/keys/ca.crt
cert /etc/openvpn/easy-rsa/keys/ip-foo.crt
key /etc/openvpn/easy-rsa/keys/ip-foo.key
user nobody
group nogroup
dh /etc/openvpn/easy-rsa/keys/dh2048.pem
server 10.8.20.0 255.255.255.0
ifconfig-pool-persist ipp.txt
keepalive 10 120
comp-lzo
push "route 172.100.0.0 255.255.0.0"
push "redirect-gateway def1 bypass-dhcp"
push "dhcp-option DNS 8.8.8.8"
persist-key
persist-tun
status openvpn-status.log
verb 3

我的 DigitalOcean server.conf 是

port 443
proto udp
dev tun
ca /etc/openvpn/easy-rsa/keys/ca.crt
cert /etc/openvpn/easy-rsa/keys/foo.crt
key /etc/openvpn/easy-rsa/keys/foo.key 
user nobody
group nogroup
dh /etc/openvpn/easy-rsa/keys/dh2048.pem
server 10.8.4.0 255.255.255.0
ifconfig-pool-persist 443ipp.txt
keepalive 10 120
comp-lzo
push "redirect-gateway def1"
push "dhcp-option DNS 8.8.8.8"
persist-key
persist-tun
verb 3

示例客户端日志位于https://pastebin.com/tYwAKFwn

连接到 AWS 服务器时,我在 journalctl -f 的输出中看到以下内容

Feb 23 10:01:11 ip-172-100-54-88 ovpn-server[1872]: my.public.ip:56720 TLS: Initial packet from [AF_INET]my.public.ip:56720, sid=f565fbbe 3fc25003
Feb 23 10:01:11 ip-172-100-54-88 ovpn-server[1872]: my.public.ip:56720 VERIFY OK: depth=1, C=GB, ST=Your Province, L=Your City, O=Your Organisation, OU=Your organisational unit, CN=Your Organisation CA, name=EasyRSA, emailAddress=Organisation CA e-mail
Feb 23 10:01:11 ip-172-100-54-88 ovpn-server[1872]: my.public.ip:56720 VERIFY OK: depth=0, C=GB, ST=Your Province, L=Your City, O=Your Organisation, OU=Your organisational unit, CN=vpnclient, name=EasyRSA, emailAddress=Organisation CA e-mail
Feb 23 10:01:11 ip-172-100-54-88 ovpn-server[1872]: my.public.ip:56720 WARNING: 'link-mtu' is used inconsistently, local='link-mtu 1542', remote='link-mtu 1558'
Feb 23 10:01:11 ip-172-100-54-88 ovpn-server[1872]: my.public.ip:56720 WARNING: 'cipher' is used inconsistently, local='cipher BF-CBC', remote='cipher AES-256-CBC'
Feb 23 10:01:11 ip-172-100-54-88 ovpn-server[1872]: my.public.ip:56720 WARNING: 'keysize' is used inconsistently, local='keysize 128', remote='keysize 256'
Feb 23 10:01:11 ip-172-100-54-88 ovpn-server[1872]: my.public.ip:56720 Data Channel Encrypt: Cipher 'BF-CBC' initialized with 128 bit key
Feb 23 10:01:11 ip-172-100-54-88 ovpn-server[1872]: my.public.ip:56720 WARNING: this cipher's block size is less than 128 bit (64 bit).  Consider using a --cipher with a larger block size.
Feb 23 10:01:11 ip-172-100-54-88 ovpn-server[1872]: my.public.ip:56720 Data Channel Encrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
Feb 23 10:01:11 ip-172-100-54-88 ovpn-server[1872]: my.public.ip:56720 Data Channel Decrypt: Cipher 'BF-CBC' initialized with 128 bit key
Feb 23 10:01:11 ip-172-100-54-88 ovpn-server[1872]: my.public.ip:56720 WARNING: this cipher's block size is less than 128 bit (64 bit).  Consider using a --cipher with a larger block size.
Feb 23 10:01:11 ip-172-100-54-88 ovpn-server[1872]: my.public.ip:56720 Data Channel Decrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
Feb 23 10:01:11 ip-172-100-54-88 ovpn-server[1872]: my.public.ip:56720 Control Channel: TLSv1.2, cipher TLSv1/SSLv3 DHE-RSA-AES256-GCM-SHA384, 2048 bit RSA
Feb 23 10:01:11 ip-172-100-54-88 ovpn-server[1872]: my.public.ip:56720 [vpnclient] Peer Connection Initiated with [AF_INET]my.public.ip:56720
Feb 23 10:01:11 ip-172-100-54-88 ovpn-server[1872]: vpnclient/my.public.ip:56720 MULTI_sva: pool returned IPv4=10.8.20.6, IPv6=(Not enabled)
Feb 23 10:01:11 ip-172-100-54-88 ovpn-server[1872]: vpnclient/my.public.ip:56720 MULTI: Learn: 10.8.20.6 -> vpnclient/my.public.ip:56720
Feb 23 10:01:11 ip-172-100-54-88 ovpn-server[1872]: vpnclient/my.public.ip:56720 MULTI: primary virtual IP for vpnclient/my.public.ip:56720: 10.8.20.6

AWS 服务器上 ifconfig tun0 的输出为

tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          inet addr:10.8.20.1  P-t-P:10.8.20.2  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

但我从未在 tun 设备上获取 IP,也无法 ping 10.8.20.1

任何指点都将不胜感激!

答案1

目前我没有时间去浏览你的东西,但我有一个用于 openvpn 的工作设置。

以下几点可能会有帮助:

相关内容