树莓派IPv6设置

偶然发现电信物联卡可以获取原生ipv6地址(240e::),树莓派可以通过ppp拨号获取ipv6地址

PPP设置

首先需要设置正常的拨号上网, 可以参考树莓派3g模块上网,需要添加ppp对ipv6的支持

修改/etc/ppp/options追加+ipv6ipv6cp-use-ipaddr两行

1
2
3
4
5
6
7
8
9
10
11
12
13
pi@raspberrypi:~ $ sudo cat /etc/ppp/options | grep -v ^# |grep -v ^$

+ipv6
ipv6cp-use-ipaddr
asyncmap 0
auth
crtscts
lock
hide-password
modem
lcp-echo-interval 30
lcp-echo-failure 4
noipx

正常拨号测试

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
pi@raspberrypi:~ $ sudo pppd call evdo-dailer

timeout set to 15 seconds
abort on (NO CARRIER)
abort on (ERROR)
abort on (NO DIALTONE)
abort on (BUSY)
abort on (NO ANSWER)
send (AT^M)
expect (OK)
AT^M^M
OK
-- got it

send (ATDT#777^M)
expect (CONNECT)
^M
ATDT#777^M^M
CONNECT
-- got it

Script /usr/sbin/chat -s -v -f /etc/ppp/chat/evdo-connect-chat finished (pid 10948), status = 0x0
Serial connection established.
using channel 1
Using interface ppp0
Connect: ppp0 <--> /dev/ttyUSB3
sent [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0x508c88c3> <pcomp> <accomp>]
rcvd [LCP ConfReq id=0x0 <asyncmap 0x0> <auth chap MD5> <magic 0x9b30189> <pcomp> <accomp>]
sent [LCP ConfAck id=0x0 <asyncmap 0x0> <auth chap MD5> <magic 0x9b30189> <pcomp> <accomp>]
rcvd [LCP ConfAck id=0x1 <asyncmap 0x0> <magic 0x508c88c3> <pcomp> <accomp>]
sent [LCP EchoReq id=0x0 magic=0x508c88c3]
rcvd [LCP DiscReq id=0x1 magic=0x9b30189]
rcvd [CHAP Challenge id=0x1 <b69b4e34c1b1f439a93e02f6af22e993>, name = "UMTS_CHAP_SRVR"]
sent [CHAP Response id=0x1 <a9cb78af69c529bec7cce110844d7f46>, name = "ctnet@mycdma.cn"]
rcvd [LCP EchoRep id=0x0 magic=0x9b30189 50 8c 88 c3]
rcvd [CHAP Success id=0x1 ""]
CHAP authentication succeeded
CHAP authentication succeeded
sent [IPCP ConfReq id=0x1 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns2 0.0.0.0>]
sent [IPV6CP ConfReq id=0x1 <addr fe80::2cd9:5c01:ee90:5356>]
rcvd [IPCP ConfReq id=0x0]
sent [IPCP ConfNak id=0x0 <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0x1 <addr 10.177.188.2> <ms-dns1 218.4.4.4> <ms-dns2 218.2.2.2>]
sent [IPCP ConfReq id=0x2 <addr 10.177.188.2> <ms-dns1 218.4.4.4> <ms-dns2 218.2.2.2>]
rcvd [IPCP ConfReq id=0x1]
sent [IPCP ConfAck id=0x1]
rcvd [IPCP ConfAck id=0x2 <addr 10.177.188.2> <ms-dns1 218.4.4.4> <ms-dns2 218.2.2.2>]
Could not determine remote IP address: defaulting to 10.64.64.64
not replacing default route to wlan0 [192.168.0.1]
local IP address 10.177.188.2
remote IP address 10.64.64.64
primary DNS address 218.4.4.4
secondary DNS address 218.2.2.2
Script /etc/ppp/ip-up started (pid 10961)
Script /etc/ppp/ip-up finished (pid 10961), status = 0x0
sent [IPV6CP ConfReq id=0x1 <addr fe80::2cd9:5c01:ee90:5356>]
rcvd [IPV6CP ConfReq id=0x0 <addr fe80::0000:0000:0000:0000>]
sent [IPV6CP ConfNak id=0x0 <addr fe80::a825:1956:0e8a:071a>]
rcvd [IPV6CP ConfAck id=0x1 <addr fe80::2cd9:5c01:ee90:5356>]
rcvd [IPV6CP ConfReq id=0x1 <addr fe80::a825:1956:0e8a:071a>]
sent [IPV6CP ConfAck id=0x1 <addr fe80::a825:1956:0e8a:071a>]
local LL address fe80::2cd9:5c01:ee90:5356
remote LL address fe80::a825:1956:0e8a:071a
Script /etc/ppp/ipv6-up started (pid 11010)
Script /etc/ppp/ipv6-up finished (pid 11010), status = 0x0

ppp0网卡信息可以看到获取的原生ipv6地址

获取外网ipv6地址

1
2
pi@raspberrypi:~ $ curl http://v6.ipv6-test.com/api/myip.php
240e:e8:f1fa:32fd:2cd9:5c01:ee90:5356

ping测试清华镜像站ipv6地址

外网SSH连接测试

这里我使用的是教育网6to4地址(2002:3b44:247::1)测试ipv6的连通性

参考文档

分享到: