IPV6 Ubuntu

Posted by Hux Blog on February 23, 2017

网络分析工具

ifconfig

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
xbk-f104@xbkf104-System-Product-Name  ~  ifconfig
eth0      Link encap:Ethernet  HWaddr 54:a0:50:53:f0:c2
          inet addr:219.223.174.228  Bcast:219.223.175.255  Mask:255.255.252.0
          inet6 addr: fe80::56a0:50ff:fe53:f0c2/64 Scope:Link
          inet6 addr: 2001:250:3c02:101:3212:be19:d20c:59cd/128 Scope:Global
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4417839 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2619615 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:6278670962 (6.2 GB)  TX bytes:232055925 (232.0 MB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:23434 errors:0 dropped:0 overruns:0 frame:0
          TX packets:23434 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:4357721 (4.3 MB)  TX bytes:4357721 (4.3 MB)

注意连通IPV6时会有Global的IPV6地址,同时注意IPV6地址的Link和Global的差异。

ping6

1
2
3
4
5
6
xbk-f104@xbkf104-System-Product-Name  ~  ping6 bt.byr.cn
PING bt.byr.cn(2001:da8:215:4078:250:56ff:fe97:654d) 56 data bytes
64 bytes from 2001:da8:215:4078:250:56ff:fe97:654d: icmp_seq=1 ttl=51 time=39.2 ms
64 bytes from 2001:da8:215:4078:250:56ff:fe97:654d: icmp_seq=2 ttl=51 time=39.3 ms
64 bytes from 2001:da8:215:4078:250:56ff:fe97:654d: icmp_seq=3 ttl=51 time=39.6 ms
64 bytes from 2001:da8:215:4078:250:56ff:fe97:654d: icmp_seq=4 ttl=51 time=39.3 ms

traceroute

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
xbk-f104@xbkf104-System-Product-Name  ~  traceroute bt.byr.cn
traceroute to bt.byr.cn (2001:da8:215:4078:250:56ff:fe97:654d), 30 hops max, 80 byte packets
1  cernet.edu.cn (2001:250:3c02:101::1)  0.483 ms  0.588 ms  0.581 ms
2  cernet.edu.cn (2001:250:3c02::10:80)  2.480 ms  1.288 ms  3.578 ms
3  cernet2.net (2001:da8:a2:4400::1101)  5.772 ms  7.696 ms  9.228 ms
4  2001:da8:1:203::1 (2001:da8:1:203::1)  4.379 ms  4.484 ms  4.635 ms
5  wh-gz-v6.cernet2.net (2001:da8:1:2::1)  20.680 ms  20.836 ms  20.677 ms
6  bj-wh-v6.cernet2.net (2001:da8:1:1::1)  39.188 ms  39.147 ms  39.203 ms
7  2001:da8:1:1c::2 (2001:da8:1:1c::2)  39.080 ms  39.167 ms  39.377 ms
8  2001:da8:1:50e::2 (2001:da8:1:50e::2)  39.981 ms  39.904 ms  40.100 ms
9  cernet2.net (2001:da8:ad:1000::2)  44.277 ms  42.464 ms  41.669 ms
10  cernet2.net (2001:da8:ad:3001::2)  39.887 ms  39.670 ms  40.025 ms
11  2001:da8:215:0:10:0:3:2 (2001:da8:215:0:10:0:3:2)  39.770 ms  40.071 ms  40.057 ms
12  2001:da8:215:0:10:0:4:32 (2001:da8:215:0:10:0:4:32)  40.035 ms  40.036 ms  40.638 ms
13  2001:da8:215:4078:250:56ff:fe97:654d (2001:da8:215:4078:250:56ff:fe97:654d)  39.373 ms  39.368 ms  39.362 ms

ip -6

1
2
3
4
5
xbk-f104@xbkf104-System-Product-Name  ~  ip -6 route show
2001:250:3c02:101:3212:be19:d20c:59cd dev eth0  proto kernel  metric 256
fe80::/64 dev eth0  proto kernel  metric 256
default via fe80::6687:880f:fc6a:802 dev eth0  proto static  metric 1
default via fe80::6687:880f:fc6a:802 dev eth0  proto ra  metric 1024  expires 1756sec hoplimit 64

一般显示 expires 1756sec 类似的语句才有可能连通ipv6。

route

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
xbk-f104@xbkf104-System-Product-Name  ~  route -6
Kernel IPv6 routing table
Destination                    Next Hop                   Flag Met Ref Use If
2001:250:3c02:101:3212:be19:d20c:59cd/128 ::                         U    256 0     0 eth0
fe80::/64                      ::                         U    256 0     0 eth0
::/0                           fe80::6687:880f:fc6a:802   UG   1   2     0 eth0
::/0                           fe80::6687:880f:fc6a:802   UGDAe 1024 0     0 eth0
::/0                           fe80::6687:880f:fc6a:800   UGDAe 1024 0     0 eth0
::/0                           fe80::6687:880f:fc6a:804   UGDAe 1024 0     0 eth0
::/0                           fe80::6687:880f:fc6a:803   UGDAe 1024 0     0 eth0
::/0                           ::                         !n   -1  1 23560 lo
::1/128                        ::                         Un   0   3    84 lo
2001:250:3c02:101:3212:be19:d20c:59cd/128 ::                         Un   0   2  7882 lo
fe80::/128                     ::                         Un   0   1     0 lo
fe80::56a0:50ff:fe53:f0c2/128  ::                         Un   0   1   111 lo
ff00::/8                       ::                         U    256 17     0 eth0
::/0                           ::                         !n   -1  1 23560 lo

Flag中G代表GATEWAY,即网关。可以看到网关地址fe80::6687:880f:fc6a:803。当ipv6无法连通时,不会显示网关地址。

ipv6地址查询

http://geoip.neu6.edu.cn

Ubuntu 清华深研院校园网常见问题

  • ping6 ipv6地址 显示 network is unreachable
  • 没有Global的V6地址
  • 一会能连通,一会无法连接,即网关有时间限制。

解决方法

  • 使用有线连接(wifi暂时未成功)
  • 在有线连接ipv6设置中,选择”Automatic, address only”,也可以尝试”automatic”和”automatic, dhcp only”。目前来看,”Automatic, address only”成功概率大一些。更改设置,记得重启网络。
  • /etc/sysctl.conf,注释去掉 #net.ipv6.conf.all.forwarding=1;同时添加 net.ipv6.conf.eth0.accept_ra=2
  • /etc/sysctl.d/10-ipv6-privacy.conf中,设置为:net.ipv6.conf.all.use_tempaddr = 2 net.ipv6.conf.default.use_tempaddr = 0。 目的是禁止使用临时ipv6地址。