我重启了服务器,结果出现了一个奇怪的问题。我在 ArchLinux 上运行,客户端是 Ubuntu、Android 和 Mac。
问题在于通过客户端访问互联网的速度很慢,大约为 2ko/s,然后慢慢停止。
但是直接从服务器下载内容到客户端是全速的。而且,显然,服务器的互联网速度是全速的(40mo/s)。
我不知道重启后发生了什么,但是所有客户端都存在这个问题,并且只与 openvpn 转发到互联网的流量有关。
编辑:尝试使用 tcp,未解决。编辑:测试了各种 fragment/mtu 设置,无变化。
以下是我的所有配置:
╭─<root@Alduin>-</etc/openvpn>-<1:45:07>-◇
╰─➤ cat Alduin.conf ccd/Thunderaan
local 212.83.129.104
port 1194
proto udp
dev tun
ca keys/ca.crt
cert keys/Alduin.crt
key keys/Alduin.key
dh keys/dh1024.pem
server 10.8.0.0 255.255.255.0
ifconfig-pool-persist ipp.txt
push "dhcp-option DNS 10.8.0.1"
client-to-client
keepalive 5 60
ping-timer-rem
comp-lzo
persist-key
persist-tun
status openvpn-status.log
verb 3
client-config-dir ccd
topology subnet
ccd from here +++++++++++++++
ifconfig-push 10.8.0.2 255.255.255.0
push "redirect-gateway def1"
客户端配置:
client
dev tun
proto udp
remote 212.83.129.104 1194
resolv-retry infinite
nobind
persist-key
persist-tun
ca ca.crt
cert name.crt
key name.key
ns-cert-type server
comp-lzo
verb 3
一些可能对您有帮助的输出:
╭─<cubox@Alduin>-<~>-<1:49:43>-◇
╰─➤ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
link/ether b8:ac:6f:94:e2:4e brd ff:ff:ff:ff:ff:ff
inet 88.190.15.135/24 scope global eno1
valid_lft forever preferred_lft forever
inet 212.83.129.104/32 scope global eno1
valid_lft forever preferred_lft forever
inet6 2001:bc8:300a:dead::b12d/64 scope global
valid_lft forever preferred_lft forever
inet6 2a01:e0b:1000:15:baac:6fff:fe94:e24e/64 scope global dynamic
valid_lft 2592000sec preferred_lft 604800sec
inet6 fe80::baac:6fff:fe94:e24e/64 scope link
valid_lft forever preferred_lft forever
3: eno2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
link/ether b8:ac:6f:94:e2:4f brd ff:ff:ff:ff:ff:ff
6: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 100
link/none
inet 10.8.0.1/24 brd 10.8.0.255 scope global tun0
valid_lft forever preferred_lft forever
╭─<cubox@Alduin>-<~>-<1:49:47>-◇
╰─➤ route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 88-190-15-1.rev 0.0.0.0 UG 0 0 0 eno1
10.8.0.0 * 255.255.255.0 U 0 0 0 tun0
88.190.15.0 * 255.255.255.0 U 0 0 0 eno1
╭─<cubox@Alduin>-<~>-<1:49:51>-◇
╰─➤ route -6
Kernel IPv6 routing table
Destination Next Hop Flag Met Ref Use If
::1/128 :: U 256 0 0 lo
2001:bc8:300a:dead::/64 :: U 256 0 0 eno1
2a01:e0b:1000:15::/64 :: UAe 256 0 0 eno1
fe80::/64 :: U 256 0 0 eno1
::/0 fe80::225:45ff:fef6:947f UGDAe 1024 2 0 eno1
::/0 :: !n -1 1 1891 lo
::1/128 :: Un 0 2 5227 lo
2001:bc8:300a:dead::/128 :: Un 0 1 0 lo
2001:bc8:300a:dead::b12d/128 :: Un 0 1 131 lo
2a01:e0b:1000:15::/128 :: Un 0 1 0 lo
2a01:e0b:1000:15:baac:6fff:fe94:e24e/128 :: Un 0 3 29356 lo
fe80::/128 :: Un 0 1 0 lo
fe80::baac:6fff:fe94:e24e/128 :: Un 0 1 311 lo
ff00::/8 :: U 256 0 0 eno1
::/0 :: !n -1 1 1891 lo
-A POSTROUTING -s 10.8.0.0/24 -o eno1 -j MASQUERADE # The iptables rule
这里的 iptables 规则是服务器上唯一处于活动状态的规则。
╰─➤ tc qd
qdisc mq 0: dev eno1 root
qdisc pfifo_fast 0: dev tun0 root refcnt 2 bands 3 priomap 1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1
编辑:这是来自 Archlinux 客户端连接的日志。
Oct 2 16:54:17 Groat ovpn-openvpn[9216]: OpenVPN 2.2.1 x86_64-linux-gnu [SSL] [LZO2] [EPOLL] [PKCS11] [eurephia] [MH] [PF_INET6] [IPv6 payload 20110424-2 (2.2RC2)] built on Feb 13 2013
Oct 2 16:54:17 Groat ovpn-openvpn[9216]: NOTE: the current --script-security setting may allow this configuration to call user-defined scripts
Oct 2 16:54:17 Groat ovpn-openvpn[9216]: LZO compression initialized
Oct 2 16:54:17 Groat ovpn-openvpn[9216]: Control Channel MTU parms [ L:1542 D:138 EF:38 EB:0 ET:0 EL:0 ]
Oct 2 16:54:17 Groat ovpn-openvpn[9216]: Socket Buffers: R=[212992->131072] S=[212992->131072]
Oct 2 16:54:17 Groat ovpn-openvpn[9216]: Data Channel MTU parms [ L:1542 D:1450 EF:42 EB:135 ET:0 EL:0 AF:3/1 ]
Oct 2 16:54:17 Groat ovpn-openvpn[9216]: Local Options hash (VER=V4): '41690919'
Oct 2 16:54:17 Groat ovpn-openvpn[9216]: Expected Remote Options hash (VER=V4): '530fdded'
Oct 2 16:54:17 Groat ovpn-openvpn[9217]: UDPv4 link local: [undef]
Oct 2 16:54:17 Groat ovpn-openvpn[9217]: UDPv4 link remote: [AF_INET]212.83.129.104:1194
Oct 2 16:54:17 Groat ovpn-openvpn[9217]: TLS: Initial packet from [AF_INET]212.83.129.104:1194, sid=edfcb034 3452d72c
Oct 2 16:54:17 Groat ovpn-openvpn[9217]: VERIFY OK: depth=1, /C=FR/ST=FR/L=Paris/O=Dragonborn/CN=Dragonborn_CA/[email protected]
Oct 2 16:54:17 Groat ovpn-openvpn[9217]: VERIFY OK: nsCertType=SERVER
Oct 2 16:54:17 Groat ovpn-openvpn[9217]: VERIFY OK: depth=0, /C=FR/ST=FR/L=Paris/O=Dragonborn/CN=Dragonborn/[email protected]
Oct 2 16:54:17 Groat ovpn-openvpn[9217]: Data Channel Encrypt: Cipher 'BF-CBC' initialized with 128 bit key
Oct 2 16:54:17 Groat ovpn-openvpn[9217]: Data Channel Encrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
Oct 2 16:54:17 Groat ovpn-openvpn[9217]: Data Channel Decrypt: Cipher 'BF-CBC' initialized with 128 bit key
Oct 2 16:54:17 Groat ovpn-openvpn[9217]: Data Channel Decrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
Oct 2 16:54:17 Groat ovpn-openvpn[9217]: Control Channel: TLSv1, cipher TLSv1/SSLv3 DHE-RSA-AES256-SHA, 1024 bit RSA
Oct 2 16:54:17 Groat ovpn-openvpn[9217]: [Dragonborn] Peer Connection Initiated with [AF_INET]212.83.129.104:1194
Oct 2 16:54:20 Groat ovpn-openvpn[9217]: SENT CONTROL [Dragonborn]: 'PUSH_REQUEST' (status=1)
Oct 2 16:54:20 Groat ovpn-openvpn[9217]: PUSH: Received control message: 'PUSH_REPLY,dhcp-option DNS 10.8.0.1,route 212.83.129.0 255.255.255.0,route-gateway 10.8.0.1,topology subnet,ping 5,ping-restart 60,redirect-gateway def1,ifconfig 10.8.0.3 255.255.255.0'
Oct 2 16:54:20 Groat ovpn-openvpn[9217]: OPTIONS IMPORT: timers and/or timeouts modified
Oct 2 16:54:20 Groat ovpn-openvpn[9217]: OPTIONS IMPORT: --ifconfig/up options modified
Oct 2 16:54:20 Groat ovpn-openvpn[9217]: OPTIONS IMPORT: route options modified
Oct 2 16:54:20 Groat ovpn-openvpn[9217]: OPTIONS IMPORT: route-related options modified
Oct 2 16:54:20 Groat ovpn-openvpn[9217]: OPTIONS IMPORT: --ip-win32 and/or --dhcp-option options modified
Oct 2 16:54:20 Groat ovpn-openvpn[9217]: ROUTE default_gateway=192.168.1.254
Oct 2 16:54:20 Groat ovpn-openvpn[9217]: TUN/TAP device tun0 opened
Oct 2 16:54:20 Groat ovpn-openvpn[9217]: TUN/TAP TX queue length set to 100
Oct 2 16:54:20 Groat ovpn-openvpn[9217]: do_ifconfig, tt->ipv6=0, tt->did_ifconfig_ipv6_setup=0
Oct 2 16:54:20 Groat ovpn-openvpn[9217]: /sbin/ifconfig tun0 10.8.0.3 netmask 255.255.255.0 mtu 1500 broadcast 10.8.0.255
Oct 2 16:54:20 Groat ovpn-openvpn[9217]: /sbin/route add -net 212.83.129.104 netmask 255.255.255.255 gw 192.168.1.254
Oct 2 16:54:20 Groat ovpn-openvpn[9217]: /sbin/route add -net 0.0.0.0 netmask 128.0.0.0 gw 10.8.0.1
Oct 2 16:54:20 Groat ovpn-openvpn[9217]: /sbin/route add -net 128.0.0.0 netmask 128.0.0.0 gw 10.8.0.1
Oct 2 16:54:20 Groat ovpn-openvpn[9217]: /sbin/route add -net 212.83.129.0 netmask 255.255.255.0 gw 10.8.0.1
Oct 2 16:54:20 Groat ovpn-openvpn[9217]: Initialization Sequence Completed
编辑:这是直接下载文件的服务器的 tcpdump:http://sprunge.us/aaJX 以下是下载此资源的客户端:http://sprunge.us/WUCC以下是来自另一个 openvpn(正在工作)服务器的普通客户端:http://www4.slashusr.com/57552.tcpdump
编辑:正如评论中所说,这是原始的 tcpdump 捕获。从服务器捕获 tun0 失败了,我不知道为什么。服务器显示在外面,客户端在此处显示 tun0,客户在这里展示外面和服务器直接在此处下载文件。
编辑:服务器运行的是 i3,但任何时候都不会使用(即使在使用 openvpn 时也不会使用)。客户端也一样,i7 完全闲置。
编辑:问题仍然存在。请帮忙 :(
答案1
我不确定这是否是同样的原因,但我认为值得调整 tun-mtu 和 mssfix,正如openvpn-on-android-tcp-retransmissions-after-openvpn-server-reboot
编辑:我发现这个也可能有帮助[已解决] openVPN 性能不可接受 更改内核参数:net.inet.ip.fastforwarding = 1(在您的 Linux 服务器上的 /etc/sysctl.conf 中添加)
答案2
VPN 服务器也是网关服务器吗?尝试删除推送网关,您的客户端只需要有一条额外的路由。
答案3
你的后路由 iptables 规则看起来很奇怪,试试这个
-A POSTROUTING -s 10.8.0.0/24 -o eno1 -j MASQUERADE
而不是 SNAT,如果不需要它们两个,则删除 eno1 上的其中一个 IP。以太网接口上的两个公共 IP 地址看起来很奇怪。为什么要这样设置?
我猜测是你的 openvpn 服务器正在循环并来回丢弃数据包,导致了这个问题。
答案4
您是否在内部运行自己的 dns 服务器?当我运行用于内部 dns 的 powerdns 设置但未正确配置反向区域时,我的网络出现问题。在这种情况下,Wireshark 提供了答案。