Quantcast
Channel: Hardware – Benjr.tw
Viewing all articles
Browse latest Browse all 145

Linux command – ping6

$
0
0

在 Linux 下面要 ping IP V6 的 IP 須使用工具 #ping6 ,#ping 指令只適用於 IP V4 時候使用 (Ping 是走 ICMPv4,而 Pingv6 是走 ICMPv6,).首先我們要透過 ifconfig 來查詢 IPv6 address .

# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:1A:64:22:04:83  
          inet addr:192.8.1.192  Bcast:192.8.1.255  Mask:255.255.255.0
          inet6 addr: 3ffe:501:ffff:100:21a:64ff:fe22:483/64 Scope:Global
          inet6 addr: fe80::21a:64ff:fe22:483/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:81 errors:0 dropped:0 overruns:0 frame:0
          TX packets:86 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:11835 (11.5 KiB)  TX bytes:11119 (10.8 KiB)
          Interrupt:17 

奇怪怎麼有兩組 IPv6 的 IP,因為 IPv6 的位址有 Link Local 以及自動指派 (address auto-configuration),

如果是網路上的伺服器可以透過 host 指令.

# host -t AAAA www.google.com
www.google.com has IPv6 address 2404:6800:4008:c06::68

Link Local

第一組 IPv6 (fe80::21a:64ff:fe22:483/64 ) 在網卡啟動時就會指派一組 IPV6 link-local address,而這 link-local address 是唯一的而且是依據網卡的 MAC Address 而有所變動,詳細步驟請參考 http://benjr.tw/17341

如果是要 ping Link Local address 時需要在 ping6 IPv6 後面的參數加上 network_device_name 如下:

# ping6 fe80::21a:64ff:fe22:483%eth0
PING fe80::20c:29ff:fef6:4d73%eth0(fe80::20c:29ff:fef6:4d73) 56 data bytes
64 bytes from fe80::20c:29ff:fef6:4d73: icmp_seq=1 ttl=64 time=0.205 ms
64 bytes from fe80::20c:29ff:fef6:4d73: icmp_seq=2 ttl=64 time=0.196 ms
64 bytes from fe80::20c:29ff:fef6:4d73: icmp_seq=3 ttl=64 time=0.193 ms

--- fe80::20c:29ff:fef6:4d73%eth0 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2990ms
rtt min/avg/max/mdev = 0.193/0.198/0.205/0.005 ms

自動指派 (address auto-configuration)

自動指派 (address auto-configuration) 主要可以區分為下列幾種

  • Stateless auto-configuration
  • Stateful auto-configuration using Router Advertisement(RA) Daemon (radvd)
  • Dynamic Host Configuration Protocol v6 (DHCPv6)

IPv6 (3ffe:501:ffff:100:21a:64ff:fe22:483/64) 類似於 IPv4 的 DHCP ,客戶端主要使用 UDP port 546 而服務器端使用 UDP port 547 .雖類似於 DHCPv4 但不同的是 IPv6 已經不使用 Brocast 的方式.

# ping6 3ffe:501:ffff:100:21a:64ff:fe22:483
PING 3ffe:501:ffff:100::1(3ffe:501:ffff:100::1) 56 data bytes
64 bytes from 3ffe:501:ffff:100::1: icmp_seq=1 ttl=64 time=1.11 ms
64 bytes from 3ffe:501:ffff:100::1: icmp_seq=2 ttl=64 time=0.192 ms
64 bytes from 3ffe:501:ffff:100::1: icmp_seq=3 ttl=64 time=0.213 ms
64 bytes from 3ffe:501:ffff:100::1: icmp_seq=4 ttl=64 time=0.195 ms
64 bytes from 3ffe:501:ffff:100::1: icmp_seq=5 ttl=64 time=0.194 ms

--- 3ffe:501:ffff:100::1 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4590ms
rtt min/avg/max/mdev = 0.192/0.381/1.113/0.366 ms

Viewing all articles
Browse latest Browse all 145

Trending Articles