And*_*gin 5 networking router openwrt ssl iptables
目前我的路由器面临一个非常奇怪的问题。我有TP-Link TL-WDR4300 rev。1.7 运行 OpenWRT 18.06.1。
问题最初出现在1-2个月前,当时我有OpenWRT 15.05,而路由器上的最后一次配置更改(升级到18.06.1之前)大约是一年前。
因此,1-2 个月前,我注意到某些网站无法在所有浏览器中的所有设备(带 iOS 的 iPhone、Android 手机、Ubuntu 笔记本电脑、Windows 笔记本电脑)上加载。但是,如果设备与 WiFi 断开连接并使用例如蜂窝网络,则网站会立即加载。
我的 ISP 是 Deutsche Telekom,没有加载的网站的一个很好的例子是https://telekom.de,通常预计可以访问。
我已经升级到最新的稳定版 OpenWRT 并开始调查这个问题。日志中没有丢弃的数据包或路由器上与问题相关的任何其他错误消息。Curl 能够直接在路由器上获取受影响网站 (telekom.de) 的内容:
root@OpenWrt:~# curl --tlsv1.0 -v https://telekom.de
> GET / HTTP/1.1
> Host: telekom.de
> User-Agent: curl/7.60.0
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Date: Sat, 01 Sep 2018 20:56:23 GMT
< Server: Apache
< Location: https://www.telekom.de/start
< Content-Length: 236
< Content-Type: text/html; charset=iso-8859-1
<
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="https://www.telekom.de/start">here</a>.</p>
</body></html>
Run Code Online (Sandbox Code Playgroud)
在所有客户端上它仍然不起作用:
$ curl --tlsv1.0 -v https://telekom.de
* Rebuilt URL to: https://telekom.de/
* Hostname was NOT found in DNS cache
* Trying 46.29.100.76...
* Connected to telekom.de (46.29.100.76) port 443 (#0)
* successfully set certificate verify locations:
* CAfile: none
CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
* Unknown SSL protocol error in connection to telekom.de:443
* Closing connection 0
curl: (35) Unknown SSL protocol error in connection to telekom.de:443
Run Code Online (Sandbox Code Playgroud)
我尝试将 Windows 笔记本电脑直接连接到德国电信的 PPPoE 光纤调制解调器,网站开始正常加载。我还将一台 Windows 笔记本电脑变成了 WiFi 路由器,所有客户端都能够加载有问题的网站。
我最初的想法是该问题可能与 IPv6 相关(另一个可能相关的问题在这里),我已经对其进行了配置(在未正确配置之前)。它没有帮助,并且在 Windows 客户端的适配器设置中禁用 IPv6 也无济于事。
当使用 OpenWRT 作为路由器时,浏览器尝试执行 TLS 握手一段时间(1-2 分钟),然后显示“安全连接失败”消息。
这是 Wireshark 捕获的 Telekom.de TLS 握手。
以下是我的一些路由器设置:
界面截图:
iptables -L -v 的输出(我没有使用标准的 OpenWRT 防火墙配置,因为它包含很多链,对我来说太复杂了,所以我在启动时通过 iptables-restore 命令重写它):
Chain INPUT (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
5651 481K ACCEPT all -- lo any anywhere anywhere
137K 17M ACCEPT all -- any any anywhere anywhere ctstate RELATED,ESTABLISHED
184 10370 logdrop all -- any any anywhere anywhere ctstate INVALID
0 0 ACCEPT udp -- pppoe-wan any anywhere anywhere udp dpt:bootpc
0 0 ACCEPT udp -- l2tp-voip any anywhere anywhere udp dpt:bootpc
67318 4219K ACCEPT all -- br-lan any anywhere anywhere
5423 290K logdrop all -- any any anywhere anywhere
Chain FORWARD (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
423K 49M ACCEPT all -- br-lan pppoe-wan anywhere anywhere
0 0 ACCEPT all -- br-lan l2tp-voip anywhere anywhere
0 0 ACCEPT all -- br-lan br-lan anywhere anywhere
1324K 1610M ACCEPT all -- pppoe-wan br-lan anywhere anywhere ctstate RELATED,ESTABLISHED
0 0 ACCEPT all -- l2tp-voip br-lan anywhere anywhere ctstate RELATED,ESTABLISHED
0 0 logdrop all -- any any anywhere anywhere
Chain OUTPUT (policy ACCEPT 188K packets, 25M bytes)
pkts bytes target prot opt in out source destination
Chain logdrop (3 references)
pkts bytes target prot opt in out source destination
5607 300K LOG all -- any any anywhere anywhere LOG level warning prefix "dropped: "
5607 300K DROP all -- any any anywhere anywhere
Run Code Online (Sandbox Code Playgroud)
iptables -t nat -L -v 的输出:
Chain PREROUTING (policy ACCEPT 59800 packets, 4849K bytes)
pkts bytes target prot opt in out source destination
Chain INPUT (policy ACCEPT 39692 packets, 2880K bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 29226 packets, 2171K bytes)
pkts bytes target prot opt in out source destination
Chain POSTROUTING (policy ACCEPT 2123 packets, 232K bytes)
pkts bytes target prot opt in out source destination
35523 2660K MASQUERADE all -- any pppoe-wan anywhere anywhere
2 1098 MASQUERADE all -- any l2tp-voip anywhere anywhere
Run Code Online (Sandbox Code Playgroud)
/etc/config/network 的内容:
cat /etc/config/network
config interface 'loopback'
option ifname 'lo'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'
config globals 'globals'
option ula_prefix 'xxxx:xxxx:xxxx:xxxx::/64'
config interface 'lan'
option ifname 'eth0.1'
option type 'bridge'
option proto 'static'
option ipaddr '192.168.x.x'
option netmask '255.255.255.0'
option ip6addr 'xxxx:xxxx:xxxx:xxxx::1/64'
config interface 'wan'
option proto 'pppoe'
option password 'yyyyyyyy'
option ifname 'eth0.7'
option username 'zzzzzzzzzzzzzzzzzzzzzzzzzzz@t-online.de'
option ipv6 '1'
config interface 'wan6'
option ifname '@wan'
option proto 'dhcpv6'
option reqprefix 'auto'
option reqaddress 'try'
config switch
option name 'switch0'
option reset '1'
option enable_vlan '1'
config switch_vlan
option device 'switch0'
option vlan '1'
option vid '1'
option ports '0t 2 3 4 5'
config switch_vlan
option device 'switch0'
option vlan '3'
option vid '7'
option ports '0t 1t'
config interface 'voip'
option proto 'l2tp'
option server 'ooo.ooo.ooo.ooo'
option username 'xxxxxxxxxxx'
option password 'xxxxxxxxxxx'
option defaultroute '0'
option peerdns '0'
option delegate '0'
option ipv6 '0'
config route
option interface 'voip'
option target 'xxxxxxxxxxxxxxx'
option netmask 'xxxxxxxxxxx'
option gateway 'xxxxxxxxxx'
Run Code Online (Sandbox Code Playgroud)
这个问题的原因是什么?
更新:根据类似问题的建议,我尝试为 pppoe-wan ( ifconfig pppoe-wan mtu xxxx )设置不同的 MTU (1400,1476,1480 )。不幸的是,它没有帮助。
更新 2: 在 ubuntuforums.org 上,通过重新安装 Ubuntu 解决了类似的问题。我刚刚尝试重新刷新 OpenWRT(遵循https://openwrt.org/toh/tp-link/tl-wdr4300#flash_overwrite;然后我应用了我的配置)。不幸的是它没有帮助。
这似乎是 MTU 和碎片的问题。以太网 MTU 为 1500,而 PPPoE MTU 为 (1500-8) = 1492。
仅在路由器上设置 MTU 没有帮助。您可以减少传出数据包中的 MSS 大小设置。
将此规则添加到iptables
,假设ppp0
是您的 PPPoE 接口:
-A 转发 -o ppp0 -p tcp -m tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu
另一种选择是固定大小:
-A 转发 -o ppp0 -p tcp -m tcp --tcp-flags SYN,RST SYN -j TCPMSS --set-mss 1400
归档时间: |
|
查看次数: |
1600 次 |
最近记录: |