从昨天开始,我们的服务器出现了奇怪的流量,导致服务器随着时间的推移耗尽所有内存。模式如下:
time (sec) info
----------------------------------------------------------------------------------------------------------------------------
0 44138 → 443 [SYN] Seq=0 Win=14600 Len=0 MSS=1460 SACK_PERM=1 TSval=1752131598 TSecr=0 WS=128
0.000032400 443 → 44138 [SYN, ACK] Seq=0 Ack=1 Win=8192 Len=0 MSS=1460 WS=256 SACK_PERM=1 TSval=36699323 TSecr=1752131598
0.000223800 44138 → 443 [ACK] Seq=1 Ack=1 Win=14720 Len=0 TSval=1752131599 TSecr=36699323
0.001124900 44138 → 443 [RST, ACK] Seq=1 Ack=1 Win=14720 Len=0 TSval=1752131600 TSecr=36699323
我不知道这是蓄意攻击还是只是某种故障。它来自多个不同的 IP 地址,频率略低于每秒一次。编辑:事实证明这是 IBM 云健康检查。
是否有一些 Linux 工具可以从客户端复制上述模式,以便我可以尝试在开发环境中重现该问题?
答案1
您可以在 Python 中执行以下操作:
import socket
import struct
def client(host, port):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
s.connect((host, port))
l_onoff = 1
l_linger = 0
s.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER,
struct.pack('ii', l_onoff, l_linger))
s.close()
client('192.168.2.1', 80)
当我使用 tcpdump 运行时,得到了相同的模式:
$ sudo tcpdump -ni ens33 -vvv host 192.168.2.1
tcpdump: listening on ens33, link-type EN10MB (Ethernet), capture size 262144 bytes
21:10:57.345980 IP (tos 0x0, ttl 64, id 33312, offset 0, flags [DF], proto TCP (6), length 60)
192.168.37.129.48634 > 192.168.2.1.80: Flags [S], cksum 0xa901 (incorrect -> 0xf62e), seq 3198104236, win 29200, options [mss 1460,sackOK,TS val 4000553187 ecr 0,nop,wscale 7], length 0
21:10:57.348290 IP (tos 0x0, ttl 128, id 36935, offset 0, flags [none], proto TCP (6), length 44)
192.168.2.1.80 > 192.168.37.129.48634: Flags [S.], cksum 0x9744 (correct), seq 1999779396, ack 3198104237, win 64240, options [mss 1460], length 0
21:10:57.348314 IP (tos 0x0, ttl 64, id 33313, offset 0, flags [DF], proto TCP (6), length 40)
192.168.37.129.48634 > 192.168.2.1.80: Flags [.], cksum 0xa8ed (incorrect -> 0x37e2), seq 1, ack 1, win 29200, length 0
21:10:57.348591 IP (tos 0x0, ttl 64, id 33314, offset 0, flags [DF], proto TCP (6), length 40)
192.168.37.129.48634 > 192.168.2.1.80: Flags [R.], cksum 0xa8ed (incorrect -> 0x37de), seq 1, ack 1, win 29200, length 0