wiki:TipAndDoc/VM/network/ping

到達テスト

  • ../ のネットワークを使用
  • <eth0> などとなっているのはデフォルトゲートウェイを示す
  • VMを使ったせいか、おかしな挙動が見られたので注意 => #unexpected
    • 実機で追試が必要?
    • iproute2による設定で対応可能
  • tcpdumpによるパケットキャプチャ
    • sudo tcpdump -p -n icmp -i eth?
    • ex) ubuntu-inner-BB:eth0 => ubuntu-inner-BB上の、「sudo tcpdump -p -n icmp -i eth0」によるパケットキャプチャ

パケットロスするケース

centos-inner -> ubuntu-outer

  • centos-innerのデフォルトゲートウェイの設定により、requestがWANに向かってしまう
    • centos-innerにstatic routeの設定が必要
  • パケット経路
    1. centos-inner:<eth0> -> WAN
  • centos-inner ~]$ ping 10.0.0.10 -c 1
    PING 10.0.0.10 (10.0.0.10) 56(84) bytes of data.
    
    --- 10.0.0.10 ping statistics ---
    1 packets transmitted, 0 received, 100% packet loss, time 0ms
    
    1. centos-inner:eth0
      20:07:51.313947 IP 192.168.50.110 > 10.0.0.10: ICMP echo request, id 44813, seq 1, length 64
      

centos-outer -> centos-inner

  • centos-outerのデフォルトゲートウェイの設定により、requestがWANに向かってしまう
    • centos-outerにstatic routeの設定が必要
  • パケット経路
    1. centos-outer:<eth0> -> WAN
  • centos-outer ~]$ ping 10.1.0.110 -c 1
    PING 10.1.0.110 (10.1.0.110) 56(84) bytes of data.
    
    --- 10.1.0.110 ping statistics ---
    1 packets transmitted, 0 received, 100% packet loss, time 0ms
    
    1. centos-outer:eth0
      20:17:30.551763 IP 192.168.40.20 > 10.1.0.110: ICMP echo request, id 48141, seq 1, length 64
      

inner-BB -> centos-outer

  • centos-outerのデフォルトゲートウェイの設定により、replyがWANに向かってしまう
    • centos-outerにstatic routeの設定が必要
  • パケット経路
    1. inner-BB:<eth0>
    2. router:eth2
    3. router:<eth0>
    4. centos-outer:eth1
    5. centos-outer:<eth0> -> WAN
  • ubuntu-inner-BB:~$ ping 10.0.0.20 -c 1
    PING 10.0.0.20 (10.0.0.20) 56(84) bytes of data.
    
    --- 10.0.0.20 ping statistics ---
    1 packets transmitted, 0 received, 100% packet loss, time 0ms
    
    1. ubuntu-inner-BB:eth0
      18:09:56.550982 IP 10.2.0.10 > 10.0.0.20: ICMP echo request, id 45848, seq 1, length 64
      
    2. ubuntu-router:eth2
      18:09:56.719082 IP 10.2.0.10 > 10.0.0.20: ICMP echo request, id 45848, seq 1, length 64
      
    3. ubuntu-router:eth0
      18:09:56.719179 IP 10.2.0.10 > 10.0.0.20: ICMP echo request, id 45848, seq 1, length 64
      
    4. centos-outer:eth1
      18:09:56.864853 IP 10.2.0.10 > 10.0.0.20: ICMP echo request, id 45848, seq 1, length 64
      
    5. centos-outer:eth0
      18:09:56.865503 IP 10.0.0.20 > 10.2.0.10: ICMP echo reply, id 45848, seq 1, length 64
      

ubuntu-outer -> centos-inner

  • centos-innerのデフォルトゲートウェイの設定により、replyがWANに向かってしまう
    • centos-innerにstatic routeの設定が必要
  • パケット経路
    1. ubuntu-outer:<eth1>
    2. router:<eth0>
    3. router:eth1
    4. centos-inner:eth1
    5. centos-inner:<eth0> -> WAN
  • ubuntu-outer:~$ ping 10.1.0.110 -c 1
    PING 10.1.0.110 (10.1.0.110) 56(84) bytes of data.
    
    --- 10.1.0.110 ping statistics ---
    1 packets transmitted, 0 received, 100% packet loss, time 0ms
    
    1. ubuntu-outer:eth1
      20:29:41.465087 IP 10.0.0.10 > 10.1.0.110: ICMP echo request, id 31255, seq 1, length 64
      
    2. ubuntu-router:eth0
      20:29:41.471692 IP 10.0.0.10 > 10.1.0.110: ICMP echo request, id 31255, seq 1, length 64
      
    3. ubuntu-router:eth1
      20:29:41.481482 IP 10.0.0.10 > 10.1.0.110: ICMP echo request, id 31255, seq 1, length 64
      
    4. centos-inner:eth1
      20:29:41.437276 IP 10.0.0.10 > 10.1.0.110: ICMP echo request, id 31255, seq 1, length 64
      
    5. centos-inner:eth0
      20:29:41.438220 IP 10.1.0.110 > 10.0.0.10: ICMP echo reply, id 31255, seq 1, length 64
      

正常なケース

ubuntu-inner-BB <=(router)=> ubuntu-outer

  • パケット経路
    1. inner-BB:<eth0>
    2. router:eth2
    3. router:<eth0>
    4. ubuntu-outer:<eth1>
    5. ubuntu-outer:<eth1>
    6. router:<eth0>
    7. router:eth2
    8. inner-BB:<eth0>

  • ubuntu-inner-BB:~$ ping 10.0.0.10 -c 1
    PING 10.0.0.10 (10.0.0.10) 56(84) bytes of data.
    64 bytes from 10.0.0.10: icmp_seq=1 ttl=63 time=10.0 ms
    
    --- 10.0.0.10 ping statistics ---
    1 packets transmitted, 1 received, 0% packet loss, time 0ms
    rtt min/avg/max/mdev = 10.017/10.017/10.017/0.000 ms
    
    1. ubuntu-inner-BB:eth0
      18:04:53.003357 IP 10.2.0.10 > 10.0.0.10: ICMP echo request, id 35352, seq 1, length 64
      18:04:53.013360 IP 10.0.0.10 > 10.2.0.10: ICMP echo reply, id 35352, seq 1, length 64
      
    2. ubuntu-router:eth2
      18:04:53.180070 IP 10.2.0.10 > 10.0.0.10: ICMP echo request, id 35352, seq 1, length 64
      18:04:53.180372 IP 10.0.0.10 > 10.2.0.10: ICMP echo reply, id 35352, seq 1, length 64
      
    3. ubuntu-router:eth0
      18:04:53.180105 IP 10.2.0.10 > 10.0.0.10: ICMP echo request, id 35352, seq 1, length 64
      18:04:53.180366 IP 10.0.0.10 > 10.2.0.10: ICMP echo reply, id 35352, seq 1, length 64
      
    4. ubuntu-outer:eth1
      18:04:53.177594 IP 10.2.0.10 > 10.0.0.10: ICMP echo request, id 35352, seq 1, length 64
      18:04:53.177684 IP 10.0.0.10 > 10.2.0.10: ICMP echo reply, id 35352, seq 1, length 64
      

違う経路で帰ってくるケース

ubuntu-outer <=(router)=> ubuntu-inner-AB

  • パケット経路
    1. ubuntu-outer:<eth1>
    2. router:<eth0>
    3. router:eth1
    4. inner-AB:eth0
    5. inner-AB:<eth1>
    6. router:eth2
    7. router:<eth0>
    8. ubuntu-outer:<eth1>

  • ubuntu-outer:~$ ping 10.1.0.30 -c 1
    PING 10.1.0.30 (10.1.0.30) 56(84) bytes of data.
    64 bytes from 10.1.0.30: icmp_seq=1 ttl=63 time=36.8 ms
    
    --- 10.1.0.30 ping statistics ---
    1 packets transmitted, 1 received, 0% packet loss, time 0ms
    rtt min/avg/max/mdev = 36.889/36.889/36.889/0.000 ms
    
    1. ubuntu-outer:eth1
      20:36:54.692467 IP 10.0.0.10 > 10.1.0.30: ICMP echo request, id 45847, seq 1, length 64
      20:36:54.712537 IP 10.1.0.30 > 10.0.0.10: ICMP echo reply, id 45847, seq 1, length 64
      
    2. ubuntu-router:eth0
      20:36:54.699054 IP 10.0.0.10 > 10.1.0.30: ICMP echo request, id 45847, seq 1, length 64
      20:36:54.718482 IP 10.1.0.30 > 10.0.0.10: ICMP echo reply, id 45847, seq 1, length 64
      
    3. ubuntu-router:eth1
      20:36:54.711750 IP 10.0.0.10 > 10.1.0.30: ICMP echo request, id 45847, seq 1, length 64
      
    4. ubuntu-inner-AB:eth0
      20:36:54.703190 IP 10.0.0.10 > 10.1.0.30: ICMP echo request, id 45847, seq 1, length 64
      
    5. ubuntu-inner-AB:eth1
      20:36:54.706993 IP 10.1.0.30 > 10.0.0.10: ICMP echo reply, id 45847, seq 1, length 64
      
    6. ubuntu-router:eth2
      20:36:54.718451 IP 10.1.0.30 > 10.0.0.10: ICMP echo reply, id 45847, seq 1, length 64
      

おかしな挙動

  • 指定したIPがバインドされたNICを通らずに通信されている
  • iproute2による対応 => iproute

ubuntu-outer <=(router)=> inner-AA

  • inner-AA:eth1 = 10.1.0.20 なので、eth1を通るはずなのにeth0を通っている
  • ubuntu-outer:~$ ping 10.1.0.20 -c 1
    PING 10.1.0.20 (10.1.0.20) 56(84) bytes of data.
    64 bytes from 10.1.0.20: icmp_seq=1 ttl=63 time=25.5 ms
    
    --- 10.1.0.20 ping statistics ---
    1 packets transmitted, 1 received, 0% packet loss, time 0ms
    rtt min/avg/max/mdev = 25.532/25.532/25.532/0.000 ms
    
    1. ubuntu-outer:eth1
      20:14:02.893113 IP 10.0.0.10 > 10.1.0.20: ICMP echo request, id 60438, seq 1, length 64
      20:14:02.914912 IP 10.1.0.20 > 10.0.0.10: ICMP echo reply, id 60438, seq 1, length 64
      
    2. ubuntu-router:eth0
      20:14:02.900364 IP 10.0.0.10 > 10.1.0.20: ICMP echo request, id 60438, seq 1, length 64
      20:14:02.920840 IP 10.1.0.20 > 10.0.0.10: ICMP echo reply, id 60438, seq 1, length 64
      
    3. ubuntu-router:eth1
      20:14:02.900768 IP 10.0.0.10 > 10.1.0.20: ICMP echo request, id 60438, seq 1, length 64
      20:14:02.920824 IP 10.1.0.20 > 10.0.0.10: ICMP echo reply, id 60438, seq 1, length 64
      
    4. ubuntu-inner-AA:eth0
      20:14:02.888999 IP 10.0.0.10 > 10.1.0.20: ICMP echo request, id 60438, seq 1, length 64
      20:14:02.906825 IP 10.1.0.20 > 10.0.0.10: ICMP echo reply, id 60438, seq 1, length 64
      

ubuntu-outer <=(router)=> inner-BB

  • inner-BB:eth1 = 10.2.0.20 なので、eth1を通るはずなのにeth0を通っている
  • ubuntu-outer:~$ ping 10.2.0.20 -c 1
    PING 10.2.0.20 (10.2.0.20) 56(84) bytes of data.
    64 bytes from 10.2.0.20: icmp_seq=1 ttl=63 time=26.0 ms
    
    --- 10.2.0.20 ping statistics ---
    1 packets transmitted, 1 received, 0% packet loss, time 0ms
    rtt min/avg/max/mdev = 26.001/26.001/26.001/0.000 ms
    
    1. ubuntu-outer:eth1
      21:46:14.403188 IP 10.0.0.10 > 10.2.0.20: ICMP echo request, id 57113, seq 1, length 64
      21:46:14.419804 IP 10.2.0.20 > 10.0.0.10: ICMP echo reply, id 57113, seq 1, length 64
      
    2. ubuntu-router:eth0
      21:46:14.409977 IP 10.0.0.10 > 10.2.0.20: ICMP echo request, id 57113, seq 1, length 64
      21:46:14.424457 IP 10.2.0.20 > 10.0.0.10: ICMP echo reply, id 57113, seq 1, length 64
      
    3. ubuntu-router:eth2
      21:46:14.423153 IP 10.0.0.10 > 10.2.0.20: ICMP echo request, id 57113, seq 1, length 64
      21:46:14.424369 IP 10.2.0.20 > 10.0.0.10: ICMP echo reply, id 57113, seq 1, length 64
      
    4. ubuntu-inner-BB:eth0
      21:46:14.417399 IP 10.0.0.10 > 10.2.0.20: ICMP echo request, id 57113, seq 1, length 64
      21:46:14.434352 IP 10.2.0.20 > 10.0.0.10: ICMP echo reply, id 57113, seq 1, length 64
      

(仮想NICからケーブルを)物理的に切断してみる

  • VMのNICから(仮想的に)LANケーブルを切断する
  • ubuntu-outer:~$ ping 10.2.0.20
    PING 10.2.0.20 (10.2.0.20) 56(84) bytes of data.
    
    (snip)
    
    64 bytes from 10.2.0.20: icmp_seq=18 ttl=63 time=2.41 ms
    64 bytes from 10.2.0.20: icmp_seq=19 ttl=63 time=4.53 ms
    64 bytes from 10.2.0.20: icmp_seq=20 ttl=63 time=1.42 ms
    64 bytes from 10.2.0.20: icmp_seq=21 ttl=63 time=2.76 ms
    64 bytes from 10.2.0.20: icmp_seq=33 ttl=63 time=1.07 ms
    64 bytes from 10.2.0.20: icmp_seq=34 ttl=63 time=1.21 ms
    
    --- 10.2.0.20 ping statistics ---
    34 packets transmitted, 23 received, 32% packet loss, time 33009ms
    rtt min/avg/max/mdev = 0.635/2.304/4.539/0.935 ms
    
    1. 途中、eth1を切断してもpingは通り続けた
    2. eth0を切断するとpacket lost
    3. ubuntu-inner-BB:eth0
      22:07:09.562788 IP 10.2.0.20 > 10.0.0.10: ICMP echo reply, id 38682, seq 18, length 64
      22:07:10.574025 IP 10.0.0.10 > 10.2.0.20: ICMP echo request, id 38682, seq 19, length 64
      22:07:10.574061 IP 10.2.0.20 > 10.0.0.10: ICMP echo reply, id 38682, seq 19, length 64
      22:07:11.571686 IP 10.0.0.10 > 10.2.0.20: ICMP echo request, id 38682, seq 20, length 64
      22:07:11.571709 IP 10.2.0.20 > 10.0.0.10: ICMP echo reply, id 38682, seq 20, length 64
      22:07:12.572202 IP 10.0.0.10 > 10.2.0.20: ICMP echo request, id 38682, seq 21, length 64
      22:07:12.572225 IP 10.2.0.20 > 10.0.0.10: ICMP echo reply, id 38682, seq 21, length 64
      22:07:24.572056 IP 10.0.0.10 > 10.2.0.20: ICMP echo request, id 38682, seq 33, length 64
      22:07:24.572299 IP 10.2.0.20 > 10.0.0.10: ICMP echo reply, id 38682, seq 33, length 64
      22:07:25.572061 IP 10.0.0.10 > 10.2.0.20: ICMP echo request, id 38682, seq 34, length 64
      22:07:25.572149 IP 10.2.0.20 > 10.0.0.10: ICMP echo reply, id 38682, seq 34, length 64
      
    • eth1をダウンさせても変わらず
      1. ubuntu-inner-BB:eth1
        tcpdump: bind: Network is down
        
      2. ubuntu-inner-BB:~$ ifconfig eth1
        eth1      Link encap:Ethernet  HWaddr 00:0c:29:ZZ:ZZ:ZZ
                  inet addr:10.2.0.20  Bcast:10.2.255.255  Mask:255.255.0.0
        
        • 何故かIPがバインドされたまま
  • VMで同じセグメント(仮想HUB)にNICを繋げているせい?
Last modified 8 years ago Last modified on Sep 17, 2009 2:46:05 PM