我的盒子 A 和远程服务器 B(均为 Debian jessie)之间有一个 OpenVPN。
在服务器 B 上,我也运行 Squid3。
然后,我将 A 浏览器配置为使用 B 服务器的 VPN 地址(10.2.0.1:3128)的远程代理,仅用于端口 80(无 SSL)。
一切正常,我可以浏览互联网。我可以通过 whatismyip.com 看到请求来自公共 B 服务器地址。
我在 B 服务器上也有一个防火墙,具有以下规则:
-A INPUT-m state --state INVALID -j NFLOG --nflog-prefix "fp=bad_packets:1"
-A INPUT-m state --state INVALID -j DROP
然后我有时会注意到一些数据包被丢弃:
6月12日 09:16:20 ks1 fp=bad_packets:1 IN=tun0 OUT= MAC= SRC=10.2.0.9 DST=10.2.0.1 LEN=40 TOS=00 PREC=0x00 TTL=64 ID=58858 DF PROTO=TCP SPT=34458 DPT=3128 SEQ=3975722279 ACK=0 WINDOW=0 RST URGP=0 MARK=0
这不会阻止浏览,但我猜测肯定是某个地方存在一些错误,我只是不知道如何找到它们。
Firefox 会发生这种情况,Opera 也会发生这种情况。
这不是一个“问题”,它主要是令人讨厌,我想知道是什么污染了我的防火墙日志;)
编辑
好的,我已经运行了 tcpdump,刷新了触发 DROP 的网站:我明白您的意思,但还没有任何解释:DROP 发生在端口 45310 上,因此我在此端口上执行了 grep:我可以看到 RESET 到达,几乎都在同一个“seq”(序列?)上:3360258722:第一个看起来合法,然后之后有 6 个……不明白为什么:下一步调查是什么?
09:58:02.133295 IP 10.85.0.1.3128 > 10.85.0.9.45310: Flags [P.], seq 104724:105019, ack 12580, win 656, options [nop,nop,TS val 128061282 ecr 1013310], length 295
09:58:02.134079 IP 10.85.0.1.3128 > 10.85.0.9.45310: Flags [.], seq 105019:106375, ack 12580, win 656, options [nop,nop,TS val 128061282 ecr 1013310], length 1356
09:58:02.134091 IP 10.85.0.1.3128 > 10.85.0.9.45310: Flags [.], seq 106375:107731, ack 12580, win 656, options [nop,nop,TS val 128061282 ecr 1013310], length 1356
09:58:02.134127 IP 10.85.0.1.3128 > 10.85.0.9.45310: Flags [.], seq 107731:109087, ack 12580, win 656, options [nop,nop,TS val 128061282 ecr 1013310], length 1356
09:58:02.134133 IP 10.85.0.1.3128 > 10.85.0.9.45310: Flags [P.], seq 109087:109115, ack 12580, win 656, options [nop,nop,TS val 128061282 ecr 1013310], length 28
09:58:02.134764 IP 10.85.0.1.3128 > 10.85.0.9.45310: Flags [.], seq 109115:110471, ack 12580, win 656, options [nop,nop,TS val 128061282 ecr 1013310], length 1356
09:58:02.134779 IP 10.85.0.1.3128 > 10.85.0.9.45310: Flags [.], seq 110471:111827, ack 12580, win 656, options [nop,nop,TS val 128061282 ecr 1013310], length 1356
09:58:02.134809 IP 10.85.0.1.3128 > 10.85.0.9.45310: Flags [P.], seq 111827:112081, ack 12580, win 656, options [nop,nop,TS val 128061282 ecr 1013310], length 254
09:58:02.258393 IP 10.85.0.9.45310 > 10.85.0.1.3128: Flags [.], ack 106375, win 1444, options [nop,nop,TS val 1013362 ecr 128061282], length 0
09:58:02.264169 IP 10.85.0.9.45310 > 10.85.0.1.3128: Flags [.], ack 109087, win 1444, options [nop,nop,TS val 1013363 ecr 128061282], length 0
09:58:02.268597 IP 10.85.0.9.45310 > 10.85.0.1.3128: Flags [.], ack 110471, win 1444, options [nop,nop,TS val 1013364 ecr 128061282], length 0
09:58:02.273283 IP 10.85.0.9.45310 > 10.85.0.1.3128: Flags [.], ack 112081, win 1444, options [nop,nop,TS val 1013365 ecr 128061282], length 0
09:58:02.557676 IP 10.85.0.9.45310 > 10.85.0.1.3128: Flags [P.], seq 12580:13402, ack 112081, win 1444, options [nop,nop,TS val 1013436 ecr 128061282], length 822
09:58:02.577739 IP 10.85.0.1.3128 > 10.85.0.9.45310: Flags [P.], seq 112081:112389, ack 13402, win 678, options [nop,nop,TS val 128061393 ecr 1013436], length 308
09:58:02.577964 IP 10.85.0.1.3128 > 10.85.0.9.45310: Flags [P.], seq 112389:113541, ack 13402, win 678, options [nop,nop,TS val 128061393 ecr 1013436], length 1152
09:58:02.593245 IP 10.85.0.9.45310 > 10.85.0.1.3128: Flags [.], ack 113541, win 1444, options [nop,nop,TS val 1013445 ecr 128061393], length 0
09:58:02.596042 IP 10.85.0.1.3128 > 10.85.0.9.45310: Flags [.], seq 113541:114897, ack 13402, win 678, options [nop,nop,TS val 128061398 ecr 1013445], length 1356
09:58:02.596081 IP 10.85.0.1.3128 > 10.85.0.9.45310: Flags [P.], seq 114897:115211, ack 13402, win 678, options [nop,nop,TS val 128061398 ecr 1013445], length 314
09:58:02.596441 IP 10.85.0.1.3128 > 10.85.0.9.45310: Flags [.], seq 115211:116567, ack 13402, win 678, options [nop,nop,TS val 128061398 ecr 1013445], length 1356
09:58:02.596467 IP 10.85.0.1.3128 > 10.85.0.9.45310: Flags [.], seq 116567:117923, ack 13402, win 678, options [nop,nop,TS val 128061398 ecr 1013445], length 1356
09:58:02.596530 IP 10.85.0.1.3128 > 10.85.0.9.45310: Flags [P.], seq 117923:118114, ack 13402, win 678, options [nop,nop,TS val 128061398 ecr 1013445], length 191
09:58:02.596814 IP 10.85.0.1.3128 > 10.85.0.9.45310: Flags [.], seq 118114:119470, ack 13402, win 678, options [nop,nop,TS val 128061398 ecr 1013445], length 1356
09:58:02.596837 IP 10.85.0.1.3128 > 10.85.0.9.45310: Flags [.], seq 119470:120826, ack 13402, win 678, options [nop,nop,TS val 128061398 ecr 1013445], length 1356
09:58:02.596890 IP 10.85.0.1.3128 > 10.85.0.9.45310: Flags [P.], seq 120826:121063, ack 13402, win 678, options [nop,nop,TS val 128061398 ecr 1013445], length 237
09:58:02.611183 IP 10.85.0.9.45310 > 10.85.0.1.3128: Flags [F.], seq 13402, ack 114897, win 1444, options [nop,nop,TS val 1013450 ecr 128061398], length 0
09:58:02.611740 IP 10.85.0.9.45310 > 10.85.0.1.3128: Flags [R], seq 3360258722, win 0, length 0
09:58:02.611821 IP 10.85.0.1.3128 > 10.85.0.9.45310: Flags [F.], seq 121063, ack 13403, win 678, options [nop,nop,TS val 128061402 ecr 1013450], length 0
09:58:02.614315 IP 10.85.0.9.45310 > 10.85.0.1.3128: Flags [R], seq 3360258722, win 0, length 0
09:58:02.617520 IP 10.85.0.9.45310 > 10.85.0.1.3128: Flags [R], seq 3360258722, win 0, length 0
09:58:02.618641 IP 10.85.0.9.45310 > 10.85.0.1.3128: Flags [R], seq 3360258722, win 0, length 0
09:58:02.621415 IP 10.85.0.9.45310 > 10.85.0.1.3128: Flags [R], seq 3360258722, win 0, length 0
09:58:02.624966 IP 10.85.0.9.45310 > 10.85.0.1.3128: Flags [R], seq 3360258722, win 0, length 0
09:58:02.625256 IP 10.85.0.9.45310 > 10.85.0.1.3128: Flags [R], seq 3360258722, win 0, length 0
09:58:02.631926 IP 10.85.0.9.45310 > 10.85.0.1.3128: Flags [R], seq 3360258723, win 0, length 0
Jun 15 09:58:02 ks1 fp=bad_packets:1 IN=tun0 OUT= MAC= SRC=10.85.0.9 DST=10.85.0.1 LEN=40 TOS=00 PREC=0x00 TTL=64 ID=19768 DF PROTO=TCP SPT=45310 DPT=3128 SEQ=3360258722 ACK=0 WINDOW=0 RST URGP=0 MARK=0
Jun 15 09:58:02 ks1 fp=bad_packets:1 IN=tun0 OUT= MAC= SRC=10.85.0.9 DST=10.85.0.1 LEN=40 TOS=00 PREC=0x00 TTL=64 ID=19769 DF PROTO=TCP SPT=45310 DPT=3128 SEQ=3360258722 ACK=0 WINDOW=0 RST URGP=0 MARK=0
Jun 15 09:58:02 ks1 fp=bad_packets:1 IN=tun0 OUT= MAC= SRC=10.85.0.9 DST=10.85.0.1 LEN=40 TOS=00 PREC=0x00 TTL=64 ID=19770 DF PROTO=TCP SPT=45310 DPT=3128 SEQ=3360258722 ACK=0 WINDOW=0 RST URGP=0 MARK=0
Jun 15 09:58:02 ks1 fp=bad_packets:1 IN=tun0 OUT= MAC= SRC=10.85.0.9 DST=10.85.0.1 LEN=40 TOS=00 PREC=0x00 TTL=64 ID=19771 DF PROTO=TCP SPT=45310 DPT=3128 SEQ=3360258722 ACK=0 WINDOW=0 RST URGP=0 MARK=0
Jun 15 09:58:02 ks1 fp=bad_packets:1 IN=tun0 OUT= MAC= SRC=10.85.0.9 DST=10.85.0.1 LEN=40 TOS=00 PREC=0x00 TTL=64 ID=19772 DF PROTO=TCP SPT=45310 DPT=3128 SEQ=3360258722 ACK=0 WINDOW=0 RST URGP=0 MARK=0
Jun 15 09:58:02 ks1 fp=bad_packets:1 IN=tun0 OUT= MAC= SRC=10.85.0.9 DST=10.85.0.1 LEN=40 TOS=00 PREC=0x00 TTL=64 ID=19773 DF PROTO=TCP SPT=45310 DPT=3128 SEQ=3360258722 ACK=0 WINDOW=0 RST URGP=0 MARK=0
编辑2 我已上传一个 .zip 文件,其中包含双方的 tcpdump 捕获信息:
http://expirebox.com/download/80b335fb34fab6824d4e35dd3609f628.html md5sum:ba748e6c6e787e81e765b6ef83b7b2cf
希望这会有所帮助
注意:我会编辑此消息一千次,我认为具有正确的语法...(我是 serverfault.com 的初学者;)
答案1
注意RST
标志处于打开状态。看来您的浏览器向已关闭的代理服务器连接发送了 RST 数据包。从提供的信息很难判断为什么会发生这种情况。如果您设法通过 wireshark/tcpdump 捕获导致这种情况的连接,您或许可以找出原因。
我们从看似正常的数据交换开始,服务器向客户端发送一些数据:
09:58:02.133295 IP 10.85.0.1.3128 > 10.85.0.9.45310: Flags [P.], seq 104724:105019, ack 12580, win 656, options [nop,nop,TS val 128061282 ecr 1013310], length 295
09:58:02.134079 IP 10.85.0.1.3128 > 10.85.0.9.45310: Flags [.], seq 105019:106375, ack 12580, win 656, options [nop,nop,TS val 128061282 ecr 1013310], length 1356
09:58:02.134091 IP 10.85.0.1.3128 > 10.85.0.9.45310: Flags [.], seq 106375:107731, ack 12580, win 656, options [nop,nop,TS val 128061282 ecr 1013310], length 1356
09:58:02.134127 IP 10.85.0.1.3128 > 10.85.0.9.45310: Flags [.], seq 107731:109087, ack 12580, win 656, options [nop,nop,TS val 128061282 ecr 1013310], length 1356
09:58:02.134133 IP 10.85.0.1.3128 > 10.85.0.9.45310: Flags [P.], seq 109087:109115, ack 12580, win 656, options [nop,nop,TS val 128061282 ecr 1013310], length 28
09:58:02.134764 IP 10.85.0.1.3128 > 10.85.0.9.45310: Flags [.], seq 109115:110471, ack 12580, win 656, options [nop,nop,TS val 128061282 ecr 1013310], length 1356
09:58:02.134779 IP 10.85.0.1.3128 > 10.85.0.9.45310: Flags [.], seq 110471:111827, ack 12580, win 656, options [nop,nop,TS val 128061282 ecr 1013310], length 1356
09:58:02.134809 IP 10.85.0.1.3128 > 10.85.0.9.45310: Flags [P.], seq 111827:112081, ack 12580, win 656, options [nop,nop,TS val 128061282 ecr 1013310], length 254
120ms 暂停并且客户端正在确认所有接收到的数据包,仍然看起来很好,尽管客户端离开窗口很短(1444),这可能暗示存在一些拥塞:
09:58:02.258393 IP 10.85.0.9.45310 > 10.85.0.1.3128: Flags [.], ack 106375, win 1444, options [nop,nop,TS val 1013362 ecr 128061282], length 0
09:58:02.264169 IP 10.85.0.9.45310 > 10.85.0.1.3128: Flags [.], ack 109087, win 1444, options [nop,nop,TS val 1013363 ecr 128061282], length 0
09:58:02.268597 IP 10.85.0.9.45310 > 10.85.0.1.3128: Flags [.], ack 110471, win 1444, options [nop,nop,TS val 1013364 ecr 128061282], length 0
09:58:02.273283 IP 10.85.0.9.45310 > 10.85.0.1.3128: Flags [.], ack 112081, win 1444, options [nop,nop,TS val 1013365 ecr 128061282], length 0
暂停 270 毫秒,然后进行另一轮数据交换,现在双向进行,数据均已确认(括号中为 .):
09:58:02.557676 IP 10.85.0.9.45310 > 10.85.0.1.3128: Flags [P.], seq 12580:13402, ack 112081, win 1444, options [nop,nop,TS val 1013436 ecr 128061282], length 822
09:58:02.577739 IP 10.85.0.1.3128 > 10.85.0.9.45310: Flags [P.], seq 112081:112389, ack 13402, win 678, options [nop,nop,TS val 128061393 ecr 1013436], length 308
09:58:02.577964 IP 10.85.0.1.3128 > 10.85.0.9.45310: Flags [P.], seq 112389:113541, ack 13402, win 678, options [nop,nop,TS val 128061393 ecr 1013436], length 1152
09:58:02.593245 IP 10.85.0.9.45310 > 10.85.0.1.3128: Flags [.], ack 113541, win 1444, options [nop,nop,TS val 1013445 ecr 128061393], length 0
现在事情变得棘手了。虽然窗口只有 1444 字节,但从服务器到客户端有大量数据(7522 字节),请注意它有 8 个数据包:
09:58:02.596042 IP 10.85.0.1.3128 > 10.85.0.9.45310: Flags [.], seq 113541:114897, ack 13402, win 678, options [nop,nop,TS val 128061398 ecr 1013445], length 1356
09:58:02.596081 IP 10.85.0.1.3128 > 10.85.0.9.45310: Flags [P.], seq 114897:115211, ack 13402, win 678, options [nop,nop,TS val 128061398 ecr 1013445], length 314
09:58:02.596441 IP 10.85.0.1.3128 > 10.85.0.9.45310: Flags [.], seq 115211:116567, ack 13402, win 678, options [nop,nop,TS val 128061398 ecr 1013445], length 1356
09:58:02.596467 IP 10.85.0.1.3128 > 10.85.0.9.45310: Flags [.], seq 116567:117923, ack 13402, win 678, options [nop,nop,TS val 128061398 ecr 1013445], length 1356
09:58:02.596530 IP 10.85.0.1.3128 > 10.85.0.9.45310: Flags [P.], seq 117923:118114, ack 13402, win 678, options [nop,nop,TS val 128061398 ecr 1013445], length 191
09:58:02.596814 IP 10.85.0.1.3128 > 10.85.0.9.45310: Flags [.], seq 118114:119470, ack 13402, win 678, options [nop,nop,TS val 128061398 ecr 1013445], length 1356
09:58:02.596837 IP 10.85.0.1.3128 > 10.85.0.9.45310: Flags [.], seq 119470:120826, ack 13402, win 678, options [nop,nop,TS val 128061398 ecr 1013445], length 1356
09:58:02.596890 IP 10.85.0.1.3128 > 10.85.0.9.45310: Flags [P.], seq 120826:121063, ack 13402, win 678, options [nop,nop,TS val 128061398 ecr 1013445], length 237
客户端仅确认前 1356 个字节(第一个数据包)并关闭(FIN)连接(括号中的 F)
09:58:02.611183 IP 10.85.0.9.45310 > 10.85.0.1.3128: Flags [F.], seq 13402, ack 114897, win 1444, options [nop,nop,TS val 1013450 ecr 128061398], length 0
现在客户端发送的 RST 序列不一致。说实话,我不知道为什么序列会这么错误。
09:58:02.611740 IP 10.85.0.9.45310 > 10.85.0.1.3128: Flags [R], seq 3360258722, win 0, length 0
服务器确认[.]连接关闭(FIN)[F]。
09:58:02.611821 IP 10.85.0.1.3128 > 10.85.0.9.45310: Flags [F.], seq 121063, ack 13403, win 678, options [nop,nop,TS val 128061402 ecr 1013450], length 0
客户端拒绝发送出窗口的其余七个数据包。这些数据包进入正确关闭的连接(FIN、FIN/ACK),因此它们不符合有效状态(因此被记录为无效)。
09:58:02.614315 IP 10.85.0.9.45310 > 10.85.0.1.3128: Flags [R], seq 3360258722, win 0, length 0
09:58:02.617520 IP 10.85.0.9.45310 > 10.85.0.1.3128: Flags [R], seq 3360258722, win 0, length 0
09:58:02.618641 IP 10.85.0.9.45310 > 10.85.0.1.3128: Flags [R], seq 3360258722, win 0, length 0
09:58:02.621415 IP 10.85.0.9.45310 > 10.85.0.1.3128: Flags [R], seq 3360258722, win 0, length 0
09:58:02.624966 IP 10.85.0.9.45310 > 10.85.0.1.3128: Flags [R], seq 3360258722, win 0, length 0
09:58:02.625256 IP 10.85.0.9.45310 > 10.85.0.1.3128: Flags [R], seq 3360258722, win 0, length 0
09:58:02.631926 IP 10.85.0.9.45310 > 10.85.0.1.3128: Flags [R], seq 3360258723, win 0, length 0
我不是安全专家,但根据RST 上的序列超出范围以及通过窗口发送的数据,您的堆栈似乎出了问题。这可能只是一些调整失控,或者一些错误应用的过滤/混淆规则,但如果没有其他原因,我会在此时检查我的系统是否存在恶意代码。或者可能有一些恶意网络硬件正在路上。
连接客户端的转储也可能提供一些关于正在发生的事情的见解。