2021-01-21

ddwrt ipv6 支持设置

作者 admin

走了不少弯路。

固件: DD-WRT v3.0-r31205M kongac (02/03/17 v24sp2 应该是这个版本。

网络联通 有公网ip

首先去ddwrt官网看配置。

先决条件

  • DD-WRT兼容的路由器
  • 关于Command Line的知识
  • 关于ip command的知识
  • DD-WRT version 22 prefinal 5 minimum with distribution voip or standard only
    • IPv6不是在所有的DD-WRT v24上都能工作。 24v sp1已经正式可以在IPv6下工作。
  • 通过图形界面 IPv6 Administration/Management/Router Management/Ipv6 启用IPv6
  • 启用jffs 将有所帮助 (可选)

[edit]局域网上的IPv6

[edit]概述

如果你已经有一个工作的IPv6路由器,或者对讲IPv6通信传出局域网不感兴趣,那么你主要关心的是如何将无线客户数据传给有线客户。

如果你的DD-WRT路由器是你的IPv6路由,查看下面的其他6到4隧道解决方案。

[edit]开启IPv6支持

在 Administration>Management 页面,启用 IPv6 和 radvd

[edit]配置Radvd (如果 DD-WRT 不是你的IPv6路由器)

Radvd与DHCP服务器类似。它将你的IPv6前缀通知给本地网络,以便新的客户机可以生成它自己的IP地址。下面的配置告诉radvd从有线端获取一个IPv6地址,然后适当地播报给LAN (br0).

将下面的代码拷贝到radvd设置框:

interface br0 {
   AdvSendAdvert on;
   prefix 0:0:0:1::/64 {
    AdvOnLink on;
    AdvAutonomous on;
   };
};

[edit]6to4 Setup

[edit]Overview

6to4 is a mechanism which assigns a large block of IPv6 addresses to every IPv4 address on the Internet. You can use 6to4 with DD-WRT to give every computer on your network a globally-accessible IPv6 address without the need to configure explicit tunneling. This should be the simplest method to add IPv6 to your entire network.

Important Reminders 重要事项:

  • In order to use ipv6, you need the Standard or VoIP version of DD-WRT, as these are currently the only ones which support both IPv6 and radvd. 要使用ipv6,你必须使用Standard 或 VoIP版本的DD-WRT,它们是同时具有IPv6和radvd的版本。
  • The detailled configuration steps are targeted toward users with a basic DHCP connection for the WAN part. So, if using PPPoE will require replacing vlan1 with ppp0 in each instance. Other connection types will vary. 具体的配置步骤是针对某一个WAN接口以及其下的局域网而言的。因此拥有一个以上WAN接口的路由器,需要针对自己使用PPPoE拨号的具体情况来替换脚本中的vlan1参数。
  • When using DD-WRT standard on a router with 4MB Flash, there is no space available for jffs. 如果你的路由器使用standard版的DD-WRT或Flash空间只有4MB,将没有足够的空间分配给jffs。
  • This guide only relies on nvram variables, so that jffs is not needed. 本指南仅依赖于NVRAM,不需要jffs
  • The configuration shown below has been verified to work properly on v24 sp1 stable (standard) 下面的配置在v24 sp1(standard版)已可稳定运行

[edit]Enabling IPv6 Support

On the Administration>Management page, enable IPv6 and radvd.

[edit]Configuring Radvd

Radvd is similar to a DHCP server. It advertises your IPv6 prefix to the local network, so that a new client can generate its own IP address. This config tells radvd to get a 6to4 prefix from the WAN side (vlan1) and announce it to the LAN (br0). Radvd类似于一个DHCP服务器。它公布你的IPv6前缀到本地网络,使新的客户端可以生成自己的IP地址。这个配置告诉radvd获得来自WAN端(VLAN1)6to4前缀,并予以公告到LAN(br0)

Copy the following into your radvd settings box:

interface br0 {
   MinRtrAdvInterval 3;
   MaxRtrAdvInterval 10;
   AdvLinkMTU 1280;
   AdvSendAdvert on;
   prefix 0:0:0:1::/64 {
    AdvOnLink on;
    AdvAutonomous on;
    AdvValidLifetime 86400;
    AdvPreferredLifetime 86400;
    Base6to4Interface vlan1;
    AdvRouterAddr on;
   };
};

[edit]Startup Script

This startup script acquires your current IPv4 address and uses it to calculate a 6to4 IPv6 address. It then creates the tunnel interface, configures a route, and assigns the address. Afterwards, it sends radvd a SIGHUP so that it will become aware that the prefix has changed. 该启动脚本获取当前的IPv4地址,并用它来计算的6to4 IPv6地址。然后它创建的隧道接口,配置路由,并分配地址。接着,它发送一个SIGHUP radvd使其意识到,前缀已改变。

Go to Administration>Diagnostics or Administration>Commands in v24 sp1, copy the following into the big box, and hit "Save Startup".

insmod /lib/modules/`uname -r`/ipv6.o
sleep 5
radvd -C /tmp/radvd.conf start
sleep 5
WANIP=$(ip -4 addr show dev vlan1 | awk '/inet / {print $2}' | cut -d/ -f1)
if [ -n "$WANIP" ]
then
 V6PREFIX=$(printf '2002:%02x%02x:%02x%02x' $(echo $WANIP | tr . ' '))
 ip tunnel add tun6to4 mode sit ttl 255 remote any local $WANIP
 ip link set tun6to4 mtu 1280
 ip link set tun6to4 up
 ip addr add $V6PREFIX:0::1/16 dev tun6to4
 ip addr add $V6PREFIX:1::1/64 dev br0
 ip -6 route add 2000::/3 via ::192.88.99.1 dev tun6to4
 kill -HUP $(cat /var/run/radvd.pid)
fi

[edit]6to4 on current builds (after v24 sp1)当前版本的6to4(v24 sp1以后的版本)

Pandora-Box got a script that works on current builds of v24. This has been successfully implemented on Eko 13309 big (which does not come with ipv6, so you must use "ipkg install kmod-ipv6" to get it to work). Pandora-Box有个脚本可在v24版本上运行。这个脚本在Eko 13309 big{某路由器的型号}上使用成功(其中ipv6不能启动,因此必须使用"ipkg install kmod-ipv6"让ipv6运行){貌似是Eko 13309 big才会碰到的情况}

The scripts are as follows:

in Administration, under IPv6/RaDVD config:

 interface br0 { 
 MinRtrAdvInterval 3; 
 MaxRtrAdvInterval 10; 
 AdvLinkMTU 1280; 
 AdvSendAdvert on; 
 prefix 0:0:0:1::/64 { 
 AdvOnLink on; 
 AdvAutonomous on; 
 AdvValidLifetime 86400; 
 AdvPreferredLifetime 86400; 
 Base6to4Interface vlan1; 
 }; 
 }; 


in Adminstration > Commands, Startup Script:

 insmod /lib/modules/`uname -r`/ipv6.o
 sleep 5 
 radvd -C /tmp/radvd.conf start 
 sleep 5 
 WANIP=$(ip -4 addr show dev vlan1 | grep 'inet ' | awk '{print $2}' | cut -d/ -f1) 
 if [ -n "$WANIP" ] 
 then 
 V6PREFIX=$(printf '2002:%02x%02x:%02x%02x' $(echo $WANIP | tr . ' ')) 
 ip tunnel add tun6to4 mode sit ttl 255 remote any local $WANIP 
 ip link set tun6to4 mtu 1280 
 ip link set tun6to4 up 
 ip addr add $V6PREFIX:0::1/16 dev tun6to4 
 ip addr add $V6PREFIX:1::1/64 dev br0 
 ip -6 route add 2000::/3 via ::192.88.99.1 dev tun6to4 
 kill -HUP $(cat /var/run/radvd.pid) 
 fi 
 radvd -C /tmp/radvd.conf start

以上方法可以看到ipv6的地址也获取了。但是只有路由器获取。

不过也可能是win7的这个服务没有打开。

google 发现台湾有的人这么设置 很简单 ddwrt ipv6

设置上面的完了还是不行。

路由没问题。ipconfig看到也有ipv6的地址就是链接不上。

查win7配置ipv6的问题 百度。http://www.360doc.com/content/11/0903/18/7506362_145530484.shtml

发现这篇文章。前面也是cmd命令行。最后发现有个服务没有启动 也启发了我。我看看我的服务启动了没有。发现没有。

services.msc 运行这个。

然后ip helper 启动服务自动。

十多次测试。终于成功了。最后用这个网站测试。http://test-ipv6.com/index.html.zh_CNhttp://test-ipv6.com/index.html.zh_CN

终于成功

ipv6 是万物互联的基础。我就是为了电脑能连接 padavan 的openvpn 上面文章设置好了。就只有ipv6 可以外网访问。然后我用ipv4的win7系统 无法连接。只好折腾成ipv6 还好成功了。

这个讨论ipv4 和ipv6 文章 实用型。可以看看。

都2020年了,关闭IPV4之后,还是寸步难行

https://www.chiphell.com/forum.php?mod=viewthread&tid=2259903&fromguid=hot&mobile=2