IPv6简单配置:Ubnt ER-X DHCPv6-PD SLAAC与OpenWRT NDP

目前国内很多小区已经支持IPv6,同时配置了DHCPv6-PD,采用Ubnt路由器的话可以通过很简单的方式启用,方便家里面的设备连接。

进入Config Tree

  • interfaces / ethernet / eth0 / pppoe / 0 / dhcpv6-pd / pd
  • add:0
  • 更新
  • interfaces / ethernet / eth0 / pppoe / 0 / dhcpv6-pd / pd / 0
  • prefix-length :/60
  • interfaces / ethernet / eth0 / pppoe / 0 / dhcpv6-pd / pd / 0 / interface
  • interface switch0
  • 更新列表
  • interfaces / ethernet / eth0 / pppoe / 0 / dhcpv6-pd / pd / 0 / interface / switch0
  • host-address  ::1
  • prefix-id :1
  • service dhcpv6-stateless
  • interfaces / ethernet / eth0 / pppoe / 0 / ipv6 / address,点+
  • interfaces / ethernet / eth0 / pppoe / 0 / ipv6 / enable,点+

以上设置完成后Preview即可生效,另外根据实际使用中,发现我这里移动商分发的IPv6 DNS服务器经常抽风,导致打开网页最开始会很卡。可以在IPv6里面启用no-dns选项即可。

如果你的运营商给你的地址已经是/64,没有DHCPv6-PD,那么可以通过IPv6 NDP解决,我之前在OpenWRT实现过,我这里外网网卡是eth0,内网是br-lan,先安装ndppd

opkg update && opkg install ndppd

看一下我的Global IPv6地址:

	root@OpenWrt:/etc# ifconfig eth0
	eth0      Link encap:Ethernet  HWaddr 8C:21:0A:A6:94:B3  
          inet addr:121.48.171.138  Bcast:121.48.171.255  Mask:255.255.255.128
          inet6 addr: 2001:250:2000:7520:8e21:aff:fea6:94b3/64 Scope:Global
          inet6 addr: fe80::8e21:aff:fea6:94b3/64 Scope:Link
          UP BROADCAST RUNNING ALLMULTI MULTICAST  MTU:1500  Metric:1
          RX packets:517397 errors:0 dropped:450 overruns:0 frame:0
          TX packets:777032 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:177017984 (168.8 MiB)  TX bytes:688621714 (656.7 MiB)
          Interrupt:4 

是2001:250:2000:7520:8e21:aff:fea6:94b3/64,因为是/64,所以无法继续划分子网,就要使用刚才说的邻居发现协议。

然后给内网网卡br-lan设置与eth0的地址前64位相同,后64位不同的IPv6地址,设置时前缀长度要大于64:

ip -6 addr add 2001:250:2000:7520:1::1/80 dev br-lan

修改/etc/ndppd.conf

	proxy eth0{
		router yes
		timeout 500
		ttl 30000


		rule 2001:250:2000:7520:1::/80 {
	  	  auto
		}
	}

然后运行ndppd:/etc/init.d/ndppd start,这样就配置好了。但是这个时候还不能客户端自动获得IP,radvd配置只能前缀为64,所以还需要dhcpv6 server:

	opkg install radvd
	opkg install wide-dhcpv6-server

配置/etc/config/radvd:

	config interface
           option interface        'lan'
           option AdvSendAdvert    1
           option AdvManagedFlag   1
           option AdvOtherConfigFlag 1
           list client             ''

	config prefix
           option interface        'lan'
           # If not specified, a non-link-local prefix of the interface is used
           list prefix             ''
           option AdvOnLink        1
           option AdvAutonomous    1
           option AdvRouterAddr    0

配置/etc/config/dhcp6s,enabled设置为1

配置/etc/dhcp6s.conf

	interface br-lan {
		address-pool pool1 86400;
	};
	pool pool1 {
		range 2001:250:2000:7520:1::200 to 2001:250:2000:7520:1::300 ;
	};

启动radvd和dhcpv6 server:

	/etc/init.d/radvd start
	/etc/init.d/dhcp6s start

注意顺序,如果遇到错误,可以:

	/etc/init.d/radvd restart
	/etc/init.d/ndppd restart

这样我们就配置好了IPv6的邻居发现协议和IP地址的分配,这个时候连上路由器的客户端已经可以自动获得IPv4和IPv6的地址并无障碍访问IPv4和IPv6的网络了:

本地Ping Google IPv6:

	MartiandeMacBook-Pro:~ MartianZ$ ping6 ipv6.google.com
	PING6(56=40+8+8 bytes) 2001:250:2000:7520:1::100 --> 2404:6800:4008:c01::68
	16 bytes from 2404:6800:4008:c01::68, icmp_seq=0 hlim=46 time=110.295 ms
	16 bytes from 2404:6800:4008:c01::68, icmp_seq=1 hlim=46 time=113.267 ms
	16 bytes from 2404:6800:4008:c01::68, icmp_seq=3 hlim=46 time=109.890 ms
	^C
	--- ipv6.l.google.com ping6 statistics ---
	4 packets transmitted, 3 packets received, 25.0% packet loss
	round-trip min/avg/max/std-dev = 109.890/111.151/113.267/1.506 ms

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注