在端口21上debugging连接被拒绝的响应

我和我的同事无法访问Heart Internet的FTP服务器。

我们正在运行Mac和PC的混合系统,我们在办公室也有一个Linux系统。 我们的机器都不能连接。

当从我的IP地址运行nmap时,端口21不会出现。

使用像FileZilla这样的软件只会返回“连接超时”,就像Linux上的ftp

使用Wireshark我可以看到“ICMP目标不可达(端口不可达)”对TCP SYN数据包的响应。

我可以访问其他端口上的相同服务器,我可以ping服务器,我可以跟踪到服务器。

从我的IP:

 $ telnet ftp20.extendcp.co.uk 21 Trying 79.170.44.20... telnet: Unable to connect to remote host: Connection refused 

从远程服务器:

 $ telnet ftp20.extendcp.co.uk 21 Trying 79.170.44.20... Connected to ftp20.extendcp.co.uk. Escape character is '^]'. 220 FTP server ready 

Telneting到不同的服务器工作正常:

 $ telnet ftp.mirrorservice.org 21 Trying 212.219.56.184... Connected to ftp.mirrorservice.org. Escape character is '^]'. 220----------------------------------------------------------------------------- 220-Welcome to the University of Kent's UK Mirror Service. 220- 220-More information can be found at our web site: http://www.mirrorservice.org/ 220-Please send comments or questions to [email protected]. 220----------------------------------------------------------------------------- 220 

路由跟踪:

 $ traceroute ftp20.extendcp.co.uk traceroute to ftp20.extendcp.co.uk (79.170.44.20), 30 hops max, 60 byte packets 1 home.gateway.home.gateway (192.168.2.254) 0.608 ms 0.904 ms 2.152 ms 2 88.215.57.252 (88.215.57.252) 20.283 ms 21.010 ms 21.254 ms 3 88.215.62.78 (88.215.62.78) 20.983 ms 20.973 ms 21.014 ms 4 88.215.62.230 (88.215.62.230) 27.175 ms 27.348 ms 27.509 ms 5 88.215.62.218 (88.215.62.218) 50.552 ms 49.958 ms 50.975 ms 6 * * * 7 mx02-xe0.0.1-lon.gs.nodefour.net (83.166.164.85) 24.098 ms 26.726 ms 22.204 ms 8 mx01-xe2.0.0-lon.gs.nodefour.net (83.166.164.34) 22.147 ms 22.165 ms 24.208 ms 9 mx02-xe1.2.0-dry.dc2.nodefour.net (83.166.164.38) 35.475 ms 35.532 ms 35.879 ms 10 83.166.164.54 (83.166.164.54) 25.316 ms 34.015 ms 34.401 ms 11 ftp20.extendcp.co.uk (79.170.44.20) 25.529 ms 28.205 ms 26.298 ms 

平:

 $ ping ftp20.extendcp.co.uk PING ftp20.extendcp.co.uk (79.170.44.20) 56(84) bytes of data. 64 bytes from ftp20.extendcp.co.uk (79.170.44.20): icmp_req=1 ttl=53 time=24.3 ms 64 bytes from ftp20.extendcp.co.uk (79.170.44.20): icmp_req=2 ttl=53 time=21.3 ms 64 bytes from ftp20.extendcp.co.uk (79.170.44.20): icmp_req=3 ttl=53 time=24.7 ms 64 bytes from ftp20.extendcp.co.uk (79.170.44.20): icmp_req=4 ttl=53 time=21.5 ms 64 bytes from ftp20.extendcp.co.uk (79.170.44.20): icmp_req=5 ttl=53 time=25.1 ms 

Telnet到不同的端口:

 $ telnet ftp20.extendcp.co.uk 22 Trying 79.170.44.20... Connected to ftp20.extendcp.co.uk. Escape character is '^]'. SSH-2.0-OpenSSH_5.3 

telnet 79.170.44.20 21 TCP转储79.170.44.20 telnet 79.170.44.20 21

 $ sudo tcpdump -n -n -v -i eth0 host 79.170.44.20 tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes 14:30:27.194966 IP (tos 0x10, ttl 64, id 1237, offset 0, flags [DF], proto TCP (6), length 60) 192.168.2.10.58366 > 79.170.44.20.21: Flags [S], cksum 0x3e9f (incorrect -> 0x00e5), seq 530375445, win 14600, options [mss 1460,sackOK,TS val 18737088 ecr 0,nop,wscale 6], length 0 14:30:27.216103 IP (tos 0xc0, ttl 53, id 12906, offset 0, flags [none], proto ICMP (1), length 88) 79.170.44.20 > 192.168.2.10: ICMP 79.170.44.20 tcp port 21 unreachable, length 68 IP (tos 0x0, ttl 54, id 1237, offset 0, flags [DF], proto TCP (6), length 60) 192.168.2.10.58366 > 79.170.44.20.21: Flags [S], cksum 0x0e94 (incorrect -> 0x00ed), seq 530375445, win 14600, options [mss 1452,sackOK,TS val 18737088 ecr 0,nop,wscale 6], length 0 

telnet 79.170.44.20 23 79.170.44.20的TCP dump从上面继续

 14:31:23.250970 IP (tos 0x10, ttl 64, id 15043, offset 0, flags [DF], proto TCP (6), length 60) 192.168.2.10.58533 > 79.170.44.20.23: Flags [S], cksum 0x3e9f (incorrect -> 0x4da7), seq 1506485437, win 14600, options [mss 1460,sackOK,TS val 18751102 ecr 0,nop,wscale 6], length 0 14:31:23.273111 IP (tos 0x0, ttl 53, id 0, offset 0, flags [DF], proto TCP (6), length 40) 79.170.44.20.23 > 192.168.2.10.58533: Flags [R.], cksum 0x0e1a (correct), seq 0, ack 1506485438, win 0, length 0 

我的互联网服务提供商和心连心都没有报告可见的问

我可以使用哪些工具来确定问题所在?

是否有可能发现沿着networking路由到服务器连接被拒绝? (也就是说,如果是我的路由器或他们的防火墙,是否有可能发现拒绝连接?)

我们已经排除了从您的networking到FTP服务器的传出连接的一个通用块,这是很好的。 下一步可能是traceroute; 您的networking可能在访问目标服务器所在的networking块时遇到问题。 幸运的是,他们允许traceroute ,所以你的下一步可能是traceroute到目的地,并看看事情下跌。 我粘贴了我的traceroute输出进行比较。

 [me@risby]$ traceroute ftp20.extendcp.co.uk traceroute to ftp20.extendcp.co.uk (79.170.44.20), 30 hops max, 60 byte packets 1 192.168.3.1 (192.168.3.1) 0.200 ms 0.113 ms 0.102 ms 2 lns18.inx.dsl.enta.net (188.39.1.30) 23.466 ms 23.318 ms 24.988 ms 3 gi1-8.inx.dist.dsl.enta.net (188.39.1.29) 23.782 ms 24.622 ms 25.546 ms 4 te2-2.interxion.dsl.enta.net (78.33.141.89) 26.186 ms 26.963 ms 26.802 ms 5 te2-3.interxion.core.enta.net (87.127.236.209) 27.554 ms 28.360 ms 29.085 ms 6 te4-2.telehouse-east.core.enta.net (87.127.236.137) 28.818 ms 28.512 ms 28.349 ms 7 * * * 8 mx01-xe2.3.0-lon.gs.nodefour.net (83.166.164.85) 28.397 ms 29.967 ms 30.681 ms 9 mx01-xe2.2.0-lon.gs.nodefour.net (83.166.164.34) 31.404 ms 31.112 ms 32.733 ms 10 mx02-xe1.2.0-dry.dc2.nodefour.net (83.166.164.38) 32.465 ms 33.060 ms 33.776 ms 11 83.166.164.54 (83.166.164.54) 33.529 ms 34.628 ms 34.356 ms 12 ftp20.extendcp.co.uk (79.170.44.20) 34.043 ms 30.541 ms 30.543 ms 

看看你是否可以访问目的地的其他东西也是有用的; 你可以粘贴输出的ping ftp20.extendcp.co.uk

编辑 :现在我们已经确定您在桌面上使用Linux,您可以高效地使用tcpdump来查看拒绝来自多远。 这是我的输出从tcpdump -n -n -v -i p1p1 host 79.170.44.20 ,当我做一个telnet ftp20.extendcp.co.uk 22 (连接),然后一个telnet ftp20.extendcp.co.uk 23得到一个Connection refusedConnection refused ,因为它应该):

 14:20:40.047720 IP (tos 0x10, ttl 64, id 57773, offset 0, flags [DF], proto TCP (6), length 60) 192.168.3.11.57105 > 79.170.44.20.22: Flags [S], cksum 0x5a67 (correct), seq 2606771394, win 14600, options [mss 1460,sackOK,TS val 6671727 ecr 0,nop,wscale 7], length 0 14:20:40.078615 IP (tos 0x0, ttl 47, id 0, offset 0, flags [DF], proto TCP (6), length 60) 79.170.44.20.22 > 192.168.3.11.57105: Flags [S.], cksum 0xc8ec (correct), seq 28398605, ack 2606771395, win 14480, options [mss 1412,sackOK,TS val 609884153 ecr 6671727,nop,wscale 7], length 0 [packets deleted] 14:20:48.193195 IP (tos 0x10, ttl 64, id 34283, offset 0, flags [DF], proto TCP (6), length 60) 192.168.3.11.57462 > 79.170.44.20.23: Flags [S], cksum 0x1fa0 (correct), seq 2030528683, win 14600, options [mss 1460,sackOK,TS val 6679872 ecr 0,nop,wscale 7], length 0 14:20:48.222609 IP (tos 0x0, ttl 47, id 0, offset 0, flags [DF], proto TCP (6), length 40) 79.170.44.20.23 > 192.168.3.11.57462: Flags [R.], cksum 0xae1d (correct), seq 0, ack 2030528684, win 0, length 0 

请注意,在第一种情况下,从服务器返回的第一个数据包中的ttl字段是如何为47 。 请注意第二种情况下复位数据包中的ttl字段( flags [R.] )是否也是 47,这对于来自目标服务器的复位是正确合适的。 如果你看到更高的TTL,它强烈暗示拒绝来自更近的地方。

编辑2 :鉴于你所说的TTL在你的情况下,它确实看起来好像该服务器已经决定不接受你的连接。 有可能是路由器伪造TCP端口无法访问,但是要做到这一点很困难,而且大多数防火墙工具都不用担心(iirc,即使中国的伟大防火墙也没有正确设置TTL的拒绝服务)。

至于为什么远程服务器决定这样做(自动,也许通过fail2ban?手册,因为过度下载?),谁能说? 除非你可以联系服务器pipe理员,否则你可能不知道为什么。 如果您与ftp20.extendcp.co.uk有业务关系,请通过这些路由升级。 否则,我会耸耸肩,并使用代理服务器,如果有一些文件,我迫切需要去或从服务器。

“ICMP目的不可达(端口不可达)”回复的源IP是什么? 如果是ftp服务器的IP,它强烈build议(虽然奇怪)目标服务器确实拒绝连接到端口21。 由于99.9%的防火墙只是丢弃阻止的数据包,从不打扰任何回复。 这样的ICMP错误通常意味着你已经成功地到达了ftp服务器,但是在这个端口上没有监听套接字。 鉴于ftp服务器启动,仍然认为他们的FTP服务器软件拒绝接受您的IP连接的一些奇怪的原因。 另外,你有select改变你的IP(只是为了testing)?