Linux:外网域名防火墙设置导致下载失败

时间:2024-04-21 16:26:03

问题现象:

通过IE从服务器下载文件时,提示Can't read from connection: Connection reset by peer。

别的现场都是好的,只有该现场有这个问题。所以,一直以为现场的网络或者防火墙设置有问题,导致该问题一直未解决。

今天,想到可能和下载的文件大小有关系,于是在linux服务器上通过wget单个文件下载测试,发现小于0.5M的文件下载正常。

超过0.5M,就提示Connection reset by peer。

下面是测试过程:

Last login: Wed Oct 9 15:40:57 2013 from 202.195.128.18
[root@w5-1 ~]# ping 221.***.212.94
PING 221.***.212.94 (221.***.212.94) 56(84) bytes of data.
64 bytes from 221.***.212.94: icmp_seq=1 ttl=57 time=9.56 ms
64 bytes from 221.***.212.94: icmp_seq=2 ttl=57 time=9.30 ms
64 bytes from 221.***.212.94: icmp_seq=3 ttl=57 time=9.37 ms
64 bytes from 221.***.212.94: icmp_seq=4 ttl=57 time=9.44 ms
64 bytes from 221.***.212.94: icmp_seq=5 ttl=57 time=9.61 ms
64 bytes from 221.***.212.94: icmp_seq=6 ttl=57 time=9.37 ms

[1]+ Stopped ping 221.***.212.94
[root@w5-1 ~]# ping svn.***.com
PING svn.***.com (221.***.212.94) 56(84) bytes of data.
64 bytes from mail.***.com (221.***.212.94): icmp_seq=1 ttl=57 time=9.82 ms
64 bytes from mail.***.com (221.***.212.94): icmp_seq=2 ttl=57 time=9.58 ms
64 bytes from mail.***.com (221.***.212.94): icmp_seq=3 ttl=57 time=9.58 ms
64 bytes from mail.***.com (221.***.212.94): icmp_seq=4 ttl=57 time=10.1 ms

[2]+ Stopped ping svn.***.com
[root@w5-1 ~]# wget
wget:未指定 URL
用法: wget [选项]... [URL]...

请尝试使用“wget --help”查看更多的选项。
[root@w5-1 ~]# wget http://demo.***.cn:10085/5/1.txt
--2013-10-09 16:15:40-- http://demo.***.cn:10085/5/1.txt
正在解析主机 demo.***.cn... 221.***.212.94
Connecting to demo.***.cn|221.***.212.94|:10085... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:1073 (1.0K) [text/plain]
Saving to: `1.txt'

100%[======================================>] 1,073 --.-K/s in 0s

2013-10-09 16:15:40 (146 MB/s) - `1.txt' saved [1073/1073]

[root@w5-1 ~]# wget http://demo.***.cn:10085/5/1.jar
--2013-10-09 16:16:42-- http://demo.***.cn:10085/5/1.jar
正在解析主机 demo.***.cn... 221.***.212.94
Connecting to demo.***.cn|221.***.212.94|:10085... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:18124391 (17M) [text/plain]
Saving to: `1.jar'

0% [ ] 5,547 --.-K/s in 60s

2013-10-09 16:17:42 (92.6 B/s) - Read error at byte 5547/18124391 (Connection reset by peer). 重试中。

--2013-10-09 16:17:43-- (尝试次数: 2) http://demo.***.cn:10085/5/1.jar
Connecting to demo.***.cn|221.***.212.94|:10085... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:18124391 (17M) [text/plain]
Saving to: `1.jar'

2% [ ] 399,403 87.0K/s eta 2m 37s
[3]+ Stopped wget http://demo.***.cn:10085/5/1.jar

[root@w5-1 ~]# wget http://demo.***.cn:10085/5/1.log
--2013-10-09 16:24:04-- http://demo.***.cn:10085/5/1.log
正在解析主机 demo.***.cn... 221.***.212.94
Connecting to demo.***.cn|221.***.212.94|:10085... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:4916089 (4.7M) [text/plain]
Saving to: `1.log'

7% [=============> ] 366,100 --.-K/s in 61s

2013-10-09 16:25:05 (5.89 KB/s) - Read error at byte 366100/4916089 (Connection reset by peer). 重试中。

--2013-10-09 16:25:06-- (尝试次数: 2) http://demo.***.cn:10085/5/1.log
Connecting to demo.***.cn|221.***.212.94|:10085... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:4916089 (4.7M) [text/plain]
Saving to: `1.log'

13% [=============> ] 717,964 --.-K/s in 62s

2013-10-09 16:26:08 (11.4 KB/s) - Read error at byte 717964/4916089 (Connection reset by peer). 重试中。

--2013-10-09 16:26:10-- (尝试次数: 3) http://demo.***.cn:10085/5/1.log
Connecting to demo.***.cn|221.***.212.94|:10085... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:4916089 (4.7M) [text/plain]
Saving to: `1.log'

16% [================> ] 920,684 192K/s eta 19s
[4]+ Stopped wget http://demo.***.cn:10085/5/1.log
[root@w5-1 ~]# wget -r -np -nd http://demo.***.cn:10085/5/1/
--2013-10-09 16:28:56-- http://demo.***.cn:10085/5/1/
正在解析主机 demo.***.cn... 221.***.212.94
Connecting to demo.***.cn|221.***.212.94|:10085... 已连接。
已发出 HTTP 请求,正在等待回应... 404 Not Found
2013-10-09 16:28:56 错误 404:Not Found。

[root@w5-1 ~]# wget -r -np -nd http://demo.***.cn:10085/5/1/
--2013-10-09 16:29:06-- http://demo.***.cn:10085/5/1/
正在解析主机 demo.***.cn... 221.***.212.94
Connecting to demo.***.cn|221.***.212.94|:10085... 已连接。
已发出 HTTP 请求,正在等待回应... 404 Not Found
2013-10-09 16:29:06 错误 404:Not Found。

[root@w5-1 ~]# wget -r -np -nd http://demo.***.cn:10085/5/images/
--2013-10-09 16:29:37-- http://demo.***.cn:10085/5/images/
正在解析主机 demo.***.cn... 221.***.212.94
Connecting to demo.***.cn|221.***.212.94|:10085... 已连接。
已发出 HTTP 请求,正在等待回应... 404 Not Found
2013-10-09 16:29:37 错误 404:Not Found。

[root@w5-1 ~]# wget -r -np -nd http://demo.***.cn:10085/5/2.jar
--2013-10-09 16:32:04-- http://demo.***.cn:10085/5/2.jar
正在解析主机 demo.***.cn... 221.***.212.94
Connecting to demo.***.cn|221.***.212.94|:10085... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:1070477 (1.0M) [text/plain]
Saving to: `2.jar'

7% [===========================> ] 77,120 --.-K/s in 60s

2013-10-09 16:33:04 (1.26 KB/s) - Read error at byte 77120/1070477 (Connection reset by peer). 重试中。

--2013-10-09 16:33:05-- (尝试次数: 2) http://demo.***.cn:10085/5/2.jar
Connecting to demo.***.cn|221.***.212.94|:10085... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:1070477 (1.0M) [text/plain]
Saving to: `2.jar'

0% [> ] 11,340 --.-K/s eta 85m 50s
[5]+ Stopped wget -r -np -nd http://demo.***.cn:10085/5/2.jar

[root@w5-1 ~]# wget -r -np -nd http://demo.***.cn:10085/5/1.txt
--2013-10-09 16:34:02-- http://demo.***.cn:10085/5/1.txt
正在解析主机 demo.***.cn... 221.***.212.94
Connecting to demo.***.cn|221.***.212.94|:10085... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:1073 (1.0K) [text/plain]
Saving to: `1.txt.1'

100%[===================================>] 1,073 --.-K/s in 0s

2013-10-09 16:34:02 (102 MB/s) - `1.txt.1' saved [1073/1073]

FINISHED --2013-10-09 16:34:02--
Downloaded: 1 files, 1.0K in 0s (102 MB/s)

[root@w5-1 ~]# wget -r -np -nd http://demo.***.cn:10085/5/3.jar
--2013-10-09 16:34:39-- http://demo.***.cn:10085/5/3.jar
正在解析主机 demo.***.cn... 221.***.212.94
Connecting to demo.***.cn|221.***.212.94|:10085... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:579511 (566K) [text/plain]
Saving to: `3.jar'

100%[=====================================>] 579,511 545K/s in 1.0s

2013-10-09 16:34:40 (545 KB/s) - `3.jar' saved [579511/579511]

FINISHED --2013-10-09 16:34:40--
Downloaded: 1 files, 566K in 1.0s (545 KB/s)

[root@w5-1 ~]# wget -r -np -nd http://demo.***.cn:10085/5/4.jar
--2013-10-09 16:35:34-- http://demo.***.cn:10085/5/4.jar
正在解析主机 demo.***.cn... 221.***.212.94
Connecting to demo.***.cn|221.***.212.94|:10085... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:840550 (821K) [text/plain]
Saving to: `4.jar'

17% [================> ] 143,109 --.-K/s in 60s

2013-10-09 16:36:35 (2.32 KB/s) - Read error at byte 143109/840550 (Connection reset by peer). 重试中。

--2013-10-09 16:36:36-- (尝试次数: 2) http://demo.***.cn:10085/5/4.jar
Connecting to demo.***.cn|221.***.212.94|:10085... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:840550 (821K) [text/plain]
Saving to: `4.jar'

6% [=====> ] 62,021 --.-K/s eta 8m 45s

[6]+ Stopped wget -r -np -nd http://demo.***.cn:10085/5/4.jar
[root@w5-1 ~]# wget -r -np -nd http://demo.***.cn:10085/5/5.jar
--2013-10-09 16:37:17-- http://demo.***.cn:10085/5/5.jar
正在解析主机 demo.***.cn... 221.***.212.94
Connecting to demo.***.cn|221.***.212.94|:10085... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:571259 (558K) [text/plain]
Saving to: `5.jar'

49% [========================================> ] 282,117 --.-K/s in 61s

2013-10-09 16:38:18 (4.54 KB/s) - Read error at byte 282117/571259 (Connection reset by peer). 重试中。

--2013-10-09 16:38:19-- (尝试次数: 2) http://demo.***.cn:10085/5/5.jar
Connecting to demo.***.cn|221.***.212.94|:10085... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:571259 (558K) [text/plain]
Saving to: `5.jar'

8% [========> ] 76,501 --.-K/s
[7]+ Stopped wget -r -np -nd http://demo.***.cn:10085/5/5.jar

[root@w5-1 ~]# wget -r -np -nd http://demo.***.cn:10085/5/3.jar
--2013-10-09 16:38:55-- http://demo.***.cn:10085/5/3.jar
正在解析主机 demo.***.cn... 221.***.212.94
Connecting to demo.***.cn|221.***.212.94|:10085... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:579511 (566K) [text/plain]
Saving to: `3.jar.1'

100%[======================================>] 579,511 391K/s in 1.4s

2013-10-09 16:38:56 (391 KB/s) - `3.jar.1' saved [579511/579511]

FINISHED --2013-10-09 16:38:56--
Downloaded: 1 files, 566K in 1.4s (391 KB/s)
[root@w5-1 ~]#

问题分析:

    根据上面现象,象是现场网络或者防火墙设置有问题。于是通过tcpdump抓包看看。

>tcpdump -w 1.cap -----在这一刻,继续wget

根据对cap文件的分析,发现是下载链接http://demo.***.cn:10085所在的服务器主动Connection reset ,进而导致下载失败。

Linux:外网域名防火墙设置导致下载失败

这就说明,是demo.***.cn:10085域名所在的防火墙设置有问题。经过了解,该防火墙本身就存在问题。

问题解决:

对demo.***.cn:10085域名在一个新防火墙上重新设置,经过测试,问题解决。