双栈网络配置路由器的ipv6穿透

本教程测试过程基于 Newifi Y2 路由器,系统为 PandoraBox,理论上 OpenWrt 原生同样适用。

1.修改路由器的软件源

1
2
3
4
5
6
7
8
9
10
11
12
dest root /
dest ram /tmp
lists_dir ext /var/opkg-lists
option overlay_root /overlay
src/gz 14.09_base http://downloads.openwrt.org.cn/PandoraBox/ralink/packages/base
src/gz 14.09_telephony http://downloads.openwrt.org/chaos_calmer/15.05/ramips/mt7620/packages/telephony
src/gz 14.09_packages http://downloads.openwrt.org/chaos_calmer/15.05/ramips/mt7620/packages/packages
src/gz 14.09_routing http://downloads.openwrt.org/chaos_calmer/15.05/ramips/mt7620/packages/routing
src/gz 14.09_management http://downloads.openwrt.org/chaos_calmer/15.05/ramips/mt7620/packages/management
arch ralink 1
arch all 2
arch ramips_24kec 3

注:软件源由于硬件配置不同的会有所区别,Newifi 是 MT7620 方案,其他芯片方案的请移步以下两个网址自行匹配:

OpenWrt 中文网址 http://downloads.openwrt.org.cn/
OpenWrt download area https://downloads.openwrt.org/

2.配置 Odhcpd

  • 软件包中更新并安装最新版本的 odhcpd
  • 修改 dhcp 文件(文件路径:/etc/config/dhcp,不熟悉 ssh 的可以使用 winscp 修改)
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
config dnsmasq
option domainneeded '1'
option boguspriv '1'
option filterwin2k '0'
option localise_queries '1'
option rebind_protection '1'
option rebind_localhost '1'
option local '/lan/'
option domain 'lan'
option expandhosts '1'
option nonegcache '0'
option authoritative '1'
option readethers '1'
option leasefile '/tmp/dhcp.leases'
option resolvfile '/tmp/resolv.conf.auto'
option localservice '1'

config dhcp 'lan'
option interface 'lan'
option start '100'
option limit '150'
option leasetime '12h'
option dhcpv6 'hybrid'
option ra 'hybrid'
option ndp 'hybrid'
option ra_management '1'

config dhcp 'wan'
option interface 'wan'
option ignore '1'

config odhcpd 'odhcpd'
option maindhcp '0'
option leasefile '/tmp/hosts/odhcpd'
option leasetrigger '/usr/sbin/odhcpd-update'

config dhcp 'wan6'
option interface 'wan'
option dhcpv6 'hybrid'
option ra 'hybrid'
option ndp 'hybrid'
option master '1'

修改后保存并重启路由器即可。

3.后话

配置后好像 dns 出了一些问题,在访问其他校内以.byr.cn 或.bupt.edu.cn 为后缀的网址显示 dns 错误,如果有大牛解决了这个 DNS 问题,可以分享一下思路。

2018.9.9 更新:后话所述问题已经解决