1)現象描述
今天有同僚通路,他在用vmware workstation做測試的時候,使用nat模式,在家裡能夠ping通www.baidu.com,但是在公司怎麼ping都不通,但是通路内網和網關都正常。并且測試機的selinux和iptables都是已經關閉。
2)處理過程
a、測試到内網其它主機
<code>[root@mysql-master ~]</code><code># ping -c 5 10.10.10.1</code>
<code>PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data.</code>
<code>64 bytes from 10.10.10.1: icmp_seq=1 ttl=64 </code><code>time</code><code>=0.440 ms</code>
<code>64 bytes from 10.10.10.1: icmp_seq=2 ttl=64 </code><code>time</code><code>=0.968 ms</code>
<code>64 bytes from 10.10.10.1: icmp_seq=3 ttl=64 </code><code>time</code><code>=3.39 ms</code>
<code>64 bytes from 10.10.10.1: icmp_seq=4 ttl=64 </code><code>time</code><code>=4.77 ms</code>
<code>64 bytes from 10.10.10.1: icmp_seq=5 ttl=64 </code><code>time</code><code>=1.55 ms</code>
<code>--- 10.10.10.1 </code><code>ping</code> <code>statistics ---</code>
<code>5 packets transmitted, 5 received, 0% packet loss, </code><code>time</code> <code>4005ms</code>
<code>rtt min</code><code>/avg/max/mdev</code> <code>= 0.440</code><code>/2</code><code>.226</code><code>/4</code><code>.777</code><code>/1</code><code>.618 ms</code>
<code>說明:到内網其它主機,正常</code>
b、測試到網關
<code>[root@mysql-master ~]</code><code># ping -c 5 10.10.10.2</code>
<code>PING 10.10.10.2 (10.10.10.2) 56(84) bytes of data.</code>
<code>64 bytes from 10.10.10.2: icmp_seq=1 ttl=128 </code><code>time</code><code>=1.15 ms</code>
<code>64 bytes from 10.10.10.2: icmp_seq=2 ttl=128 </code><code>time</code><code>=2.21 ms</code>
<code>64 bytes from 10.10.10.2: icmp_seq=3 ttl=128 </code><code>time</code><code>=0.252 ms</code>
<code>64 bytes from 10.10.10.2: icmp_seq=4 ttl=128 </code><code>time</code><code>=0.209 ms</code>
<code>64 bytes from 10.10.10.2: icmp_seq=5 ttl=12</code>
<code>說明:到網關正常</code>
c、測試到baidu.com的連通性
<code>[root@mysql-master ~]</code><code># ping -c 5 www.baidu.com</code>
<code>PING www.a.shifen.com (61.135.169.121) 56(84) bytes of data.</code>
<code>--- www.a.shifen.com </code><code>ping</code> <code>statistics ---</code>
<code>5 packets transmitted, 0 received, 100% packet loss, </code><code>time</code> <code>13999ms</code>
<code>說明:發現包完全丢失,但是dns能夠解析到ip位址,對網絡是不是有限制産生了懷疑?</code>
d、檢測dns的解析
<code>[root@mysql-master ~]</code><code># nslookup www.baidu.com</code>
<code>Server:10.10.10.2</code>
<code>Address:10.10.10.2</code><code>#53</code>
<code>Non-authoritative answer:</code>
<code>www.baidu.comcanonical name = www.a.shifen.com.</code>
<code>Name:www.a.shifen.com</code>
<code>Address: 61.135.169.125</code>
<code>Address: 61.135.169.121</code>
<code>說明:DNS解析正常</code>
e、測試網絡是否真的連通(wget以及nmap)
<code>[root@mysql-master ~]</code><code># mkdir -p /packet</code>
<code>[root@mysql-master ~]</code><code># cd /packet/</code>
<code>[root@mysql-master packet]</code><code># wget www.baidu.com</code>
<code>--2016-10-19 06:01:48-- http:</code><code>//www</code><code>.baidu.com/</code>
<code>正在解析主機 www.baidu.com... 61.135.169.125, 61.135.169.121</code>
<code>正在連接配接 www.baidu.com|61.135.169.125|:80... 已連接配接。</code>
<code>已發出 HTTP 請求,正在等待回應... 200 OK</code>
<code>長度:2381 (2.3K) [text</code><code>/html</code><code>]</code>
<code>正在儲存至: “index.html”</code>
<code>100%[==================================================================================>] 2,381 --.-K</code><code>/s</code> <code>in</code> <code>0s </code>
<code>2016-10-19 06:01:48 (128 MB</code><code>/s</code><code>) - 已儲存 “index.html” [2381</code><code>/2381</code><code>])</code>
<code>[root@mysql-master packet]</code><code># echo $?</code>
<code>0</code>
<code>測試表明wget是正常的,能夠正常下載下傳</code>
<code>[root@mysql-master packet]</code><code># nmap www.baidu.com</code>
<code>Starting Nmap 5.51 ( http:</code><code>//nmap</code><code>.org ) at 2016-10-19 06:02 CST</code>
<code>Nmap scan report </code><code>for</code> <code>www.baidu.com (61.135.169.125)</code>
<code>Host is up (0.036s latency).</code>
<code>Other addresses </code><code>for</code> <code>www.baidu.com (not scanned): 61.135.169.121</code>
<code>Not shown: 998 filtered ports</code>
<code>PORT STATE SERVICE</code>
<code>80</code><code>/tcp</code> <code>open</code> <code>http</code>
<code>443</code><code>/tcp</code> <code>open</code> <code>https</code>
<code>Nmap </code><code>done</code><code>: 1 IP address (1 host up) scanned </code><code>in</code> <code>56.33 seconds</code>
<code>說明:能夠使用nmap檢測到端口開放的情況</code>
f、利用tcpdump進行抓包分析
<code>64 bytes from 10.10.10.2: icmp_seq=1 ttl=128 </code><code>time</code><code>=0.287 ms</code>
<code>64 bytes from 10.10.10.2: icmp_seq=2 ttl=128 </code><code>time</code><code>=0.626 ms</code>
<code>64 bytes from 10.10.10.2: icmp_seq=3 ttl=128 </code><code>time</code><code>=0.370 ms</code>
<code>64 bytes from 10.10.10.2: icmp_seq=4 ttl=128 </code><code>time</code><code>=0.412 ms</code>
<code>64 bytes from 10.10.10.2: icmp_seq=5 ttl=128 </code><code>time</code><code>=0.248 ms</code>
<code>--- 10.10.10.2 </code><code>ping</code> <code>statistics ---</code>
<code>5 packets transmitted, 5 received, 0% packet loss, </code><code>time</code> <code>4003ms</code>
<code>rtt min</code><code>/avg/max/mdev</code> <code>= 0.248</code><code>/0</code><code>.388</code><code>/0</code><code>.626</code><code>/0</code><code>.133 ms</code>
<code>[root@mysql-master ~]</code><code># tcpdump -i eth0 icmp</code>
<code>tcpdump: verbose output suppressed, use -</code><code>v</code> <code>or -vv </code><code>for</code> <code>full protocol decode</code>
<code>listening on eth0, link-</code><code>type</code> <code>EN10MB (Ethernet), capture size 65535 bytes</code>
<code>05:48:57.350869 IP mysql-master > localhost: ICMP </code><code>echo</code> <code>request, </code><code>id</code> <code>10786, </code><code>seq</code> <code>1, length 64</code>
<code>05:48:57.351123 IP localhost > mysql-master: ICMP </code><code>echo</code> <code>reply, </code><code>id</code> <code>10786, </code><code>seq</code> <code>1, length 64</code>
<code>05:48:58.352296 IP mysql-master > localhost: ICMP </code><code>echo</code> <code>request, </code><code>id</code> <code>10786, </code><code>seq</code> <code>2, length 64</code>
<code>05:48:58.352889 IP localhost > mysql-master: ICMP </code><code>echo</code> <code>reply, </code><code>id</code> <code>10786, </code><code>seq</code> <code>2, length 64</code>
<code>05:48:59.352281 IP mysql-master > localhost: ICMP </code><code>echo</code> <code>request, </code><code>id</code> <code>10786, </code><code>seq</code> <code>3, length 64</code>
<code>05:48:59.352590 IP localhost > mysql-master: ICMP </code><code>echo</code> <code>reply, </code><code>id</code> <code>10786, </code><code>seq</code> <code>3, length 64</code>
<code>05:49:00.353060 IP mysql-master > localhost: ICMP </code><code>echo</code> <code>request, </code><code>id</code> <code>10786, </code><code>seq</code> <code>4, length 64</code>
<code>05:49:00.353433 IP localhost > mysql-master: ICMP </code><code>echo</code> <code>reply, </code><code>id</code> <code>10786, </code><code>seq</code> <code>4, length 64</code>
<code>05:49:01.353288 IP mysql-master > localhost: ICMP </code><code>echo</code> <code>request, </code><code>id</code> <code>10786, </code><code>seq</code> <code>5, length 64</code>
<code>05:49:01.353503 IP localhost > mysql-master: ICMP </code><code>echo</code> <code>reply, </code><code>id</code> <code>10786, </code><code>seq</code> <code>5, length 64</code>
說明:有正常的request包和reply,說明本機到10.10.10.2正常(request包),并且10.10.10.2到本機有回應(reply包)
<code>PING www.a.shifen.com (61.135.169.125) 56(84) bytes of data.</code>
<code>5 packets transmitted, 0 received, 100% packet loss, </code><code>time</code> <code>14003ms</code>
<code>05:53:27.820920 IP mysql-master > 61.135.169.125: ICMP </code><code>echo</code> <code>request, </code><code>id</code> <code>14370, </code><code>seq</code> <code>1, length 64</code>
<code>05:53:28.822483 IP mysql-master > 61.135.169.125: ICMP </code><code>echo</code> <code>request, </code><code>id</code> <code>14370, </code><code>seq</code> <code>2, length 64</code>
<code>05:53:29.823843 IP mysql-master > 61.135.169.125: ICMP </code><code>echo</code> <code>request, </code><code>id</code> <code>14370, </code><code>seq</code> <code>3, length 64</code>
<code>05:53:30.823290 IP mysql-master > 61.135.169.125: ICMP </code><code>echo</code> <code>request, </code><code>id</code> <code>14370, </code><code>seq</code> <code>4, length 64</code>
<code>05:53:31.823680 IP mysql-master > 61.135.169.125: ICMP </code><code>echo</code> <code>request, </code><code>id</code> <code>14370, </code><code>seq</code> <code>5, length 64</code>
<code>說明:發現有request包,表明本機到baidu的包,baidu是接收到的,可能是百度沒響應(可能性不大)或者被公司防火牆阻斷了</code>
使用手機熱點,共享給測試機使用
<code>PING www.a.shifen.com (183.232.231.173) 56(84) bytes of data.</code>
<code>64 bytes from 183.232.231.173: icmp_seq=1 ttl=128 </code><code>time</code><code>=74.4 ms</code>
<code>64 bytes from 183.232.231.173: icmp_seq=2 ttl=128 </code><code>time</code><code>=74.7 ms</code>
<code>64 bytes from 183.232.231.173: icmp_seq=3 ttl=128 </code><code>time</code><code>=64.4 ms</code>
<code>64 bytes from 183.232.231.173: icmp_seq=4 ttl=128 </code><code>time</code><code>=57.0 ms</code>
<code>64 bytes from 183.232.231.173: icmp_seq=5 ttl=128 </code><code>time</code><code>=60.5 ms</code>
<code>5 packets transmitted, 5 received, 0% packet loss, </code><code>time</code> <code>4065ms</code>
<code>rtt min</code><code>/avg/max/mdev</code> <code>= 57.081</code><code>/66</code><code>.263</code><code>/74</code><code>.772</code><code>/7</code><code>.216 ms</code>
<code>05:58:31.031646 IP mysql-master > 183.232.231.173: ICMP </code><code>echo</code> <code>request, </code><code>id</code> <code>40226, </code><code>seq</code> <code>1, length 64</code>
<code>05:58:31.106104 IP 183.232.231.173 > mysql-master: ICMP </code><code>echo</code> <code>reply, </code><code>id</code> <code>40226, </code><code>seq</code> <code>1, length 64</code>
<code>05:58:32.032448 IP mysql-master > 183.232.231.173: ICMP </code><code>echo</code> <code>request, </code><code>id</code> <code>40226, </code><code>seq</code> <code>2, length 64</code>
<code>05:58:32.107194 IP 183.232.231.173 > mysql-master: ICMP </code><code>echo</code> <code>reply, </code><code>id</code> <code>40226, </code><code>seq</code> <code>2, length 64</code>
<code>05:58:33.034464 IP mysql-master > 183.232.231.173: ICMP </code><code>echo</code> <code>request, </code><code>id</code> <code>40226, </code><code>seq</code> <code>3, length 64</code>
<code>05:58:33.098846 IP 183.232.231.173 > mysql-master: ICMP </code><code>echo</code> <code>reply, </code><code>id</code> <code>40226, </code><code>seq</code> <code>3, length 64</code>
<code>05:58:34.035272 IP mysql-master > 183.232.231.173: ICMP </code><code>echo</code> <code>request, </code><code>id</code> <code>40226, </code><code>seq</code> <code>4, length 64</code>
<code>05:58:34.092322 IP 183.232.231.173 > mysql-master: ICMP </code><code>echo</code> <code>reply, </code><code>id</code> <code>40226, </code><code>seq</code> <code>4, length 64</code>
<code>05:58:35.036289 IP mysql-master > 183.232.231.173: ICMP </code><code>echo</code> <code>request, </code><code>id</code> <code>40226, </code><code>seq</code> <code>5, length 64</code>
<code>05:58:35.096837 IP 183.232.231.173 > mysql-master: ICMP </code><code>echo</code> <code>reply, </code><code>id</code> <code>40226, </code><code>seq</code> <code>5, length 64</code>
<code>說明:到baidu是有request和reply包,進出的包都是正常的</code>
綜合分析:應該是公司内部網絡時對回來的網絡包做了些限制,随後與網絡工程師核對了下,的确在防火牆上做了些限制。
本文轉自 冰凍vs西瓜 51CTO部落格,原文連結:http://blog.51cto.com/molewan/1865812,如需轉載請自行聯系原作者