找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 4703|回复: 24

【求助】IPV6设置

[复制链接]
各位大佬,路由器状态中显示了IPV6地址,可是测试的结果提示:IPv6 连接正常,但通过域名建立的连接并没有使用 IPv6。由于某种原因,你的浏览器或操作系统不会进行 IPv6 的 AAAA DNS 查询
请教一下,路由器中应该怎么设置才可以正常连接到IPV6。
是这个http://www.test-ipv6.com/  网站的嘛 ?    拨号路由里有IPV6地址和DNS  照理填上去就好了,   
我禁用了  因为IPV6的DNS解析反而导致变慢  没这个需求
回复

使用道具 举报

用这个试试  http://testipv6.cn/  
回复

使用道具 举报

 楼主| | 显示全部楼层
本帖最后由 别了小酒桌 于 2020-6-1 20:54 编辑


测试的结果是这样的,不知道应该咋设置,最初以为是浏览器的问题,我用手机测试也是这个结果。之前刷过老毛子,测试直接通过了。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
回复

使用道具 举报

别了小酒桌 发表于 2020-6-1 20:53
测试的结果是这样的,不知道应该咋设置,最初以为是浏览器的问题,我用手机测试也是这个结果。之前刷过 ...

ipv6的DNS有问题,手动设置下DNS吧
回复

使用道具 举报

 楼主| | 显示全部楼层
acooler15 发表于 2020-6-2 12:47
ipv6的DNS有问题,手动设置下DNS吧

我试试。设置宽带的DNS就行吗?
回复

使用道具 举报

#!/bin/sh
# -------------------------------------------------------------------
#        OpenWrt IPv6 自动配置脚本
#
#        可在LEDE等基于OpenWrt的环境下配置IPv6支持。
#
#        制作:AnClark
#        致谢:zqp19950813
# -------------------------------------------------------------------


# 1. Install the package kmod-ipt-nat6    # 安装kmod-ipt-nat6
opkg update
opkg install kmod-ipt-nat6


# 2. Change the first letter of the "IPv6 ULA Prefix" from f to d
uci set network.globals.ula_prefix="$(uci get network.globals.ula_prefix | sed 's/^./d/')"
uci commit network


# 3. Set the DHCP server to "Always announce default router"
uci set dhcp.lan.ra_default='1'
uci commit dhcp


# 4. Add an init script for NAT6 by creating a new file /etc/init.d/nat6 and paste the code from the section Init Script into it    #生成nat6脚本
touch /etc/init.d/nat6
cat > /etc/init.d/nat6 << EOF
#!/bin/sh /etc/rc.common
# NAT6 init script for OpenWrt // Depends on package: kmod-ipt-nat6

START=55

# Options
# -------

# Use temporary addresses (IPv6 privacy extensions) for outgoing connections? Yes: 1 / No: 0
PRIVACY=1

# Maximum number of attempts before this script will stop in case no IPv6 route is available
# This limits the execution time of the IPv6 route lookup to (MAX_TRIES+1)*(MAX_TRIES/2) seconds. The default (15) equals 120 seconds.
MAX_TRIES=15

# An initial delay (in seconds) helps to avoid looking for the IPv6 network too early. Ideally, the first probe is successful.
# This would be the case if the time passed between the system log messages "robing IPv6 route" and "Setting up NAT6" is 1 second.
DELAY=5

# Logical interface name of outbound IPv6 connection
# There should be no need to modify this, unless you changed the default network interface names
# Edit by Vincent: I never changed my default network interface names, but still I have to change the WAN6_NAME to "wan" instead of "wan6"
WAN6_NAME="wan6"

# ---------------------------------------------------
# Options end here - no need to change anything below

boot() {
        [ $DELAY -gt 0 ] && sleep $DELAY
        logger -t NAT6 "robing IPv6 route"
        PROBE=0
        COUNT=1
        while [ $PROBE -eq 0 ]
        do
                if [ $COUNT -gt $MAX_TRIES ]
                then
                        logger -t NAT6 "Fatal error: No IPv6 route found (reached retry limit)" && exit 1
                fi
                sleep $COUNT
                COUNT=$((COUNT+1))
                PROBE=$(route -A inet6 | grep -c '::/0')
        done

        logger -t NAT6 "Setting up NAT6"

        WAN6_INTERFACE=$(uci get "network.$WAN6_NAME.ifname")
        if [ -z "$WAN6_INTERFACE" ] || [ ! -e "/sys/class/net/$WAN6_INTERFACE/" ] ; then
                logger -t NAT6 "Fatal error: Lookup of $WAN6_NAME interface failed. Were the default interface names changed?" && exit 1
        fi
        WAN6_GATEWAY=$(route -A inet6 -e | grep "$WAN6_INTERFACE" | awk '/::\/0/{print $2; exit}')
        if [ -z "$WAN6_GATEWAY" ] ; then
                logger -t NAT6 "Fatal error: No IPv6 gateway for $WAN6_INTERFACE found" && exit 1
        fi
        LAN_ULA_PREFIX=$(uci get network.globals.ula_prefix)
        if [ $(echo "$LAN_ULA_PREFIX" | grep -c -E "^([0-9a-fA-F]{4})[0-9a-fA-F]{0,4}):") -ne 1 ] ; then
                logger -t NAT6 "Fatal error: IPv6 ULA prefix $LAN_ULA_PREFIX seems invalid. Please verify that a prefix is set and valid." && exit 1
        fi

        ip6tables -t nat -I POSTROUTING -s "$LAN_ULA_PREFIX" -o "$WAN6_INTERFACE" -j MASQUERADE
        if [ $? -eq 0 ] ; then
                logger -t NAT6 "Added IPv6 masquerading rule to the firewall (Src: $LAN_ULA_PREFIX - Dst: $WAN6_INTERFACE)"
        else
                logger -t NAT6 "Fatal error: Failed to add IPv6 masquerading rule to the firewall (Src: $LAN_ULA_PREFIX - Dst: $WAN6_INTERFACE)" && exit 1
        fi

        route -A inet6 add 2000::/3 gw "$WAN6_GATEWAY" dev "$WAN6_INTERFACE"
        if [ $? -eq 0 ] ; then
                logger -t NAT6 "Added $WAN6_GATEWAY to routing table as gateway on $WAN6_INTERFACE for outgoing connections"
        else
                logger -t NAT6 "Error: Failed to add $WAN6_GATEWAY to routing table as gateway on $WAN6_INTERFACE for outgoing connections"
        fi

        if [ $PRIVACY -eq 1 ] ; then
                echo 2 > "/proc/sys/net/ipv6/conf/$WAN6_INTERFACE/accept_ra"
                if [ $? -eq 0 ] ; then
                        logger -t NAT6 "Accepting router advertisements on $WAN6_INTERFACE even if forwarding is enabled (required for temporary addresses)"
                else
                        logger -t NAT6 "Error: Failed to change router advertisements accept policy on $WAN6_INTERFACE (required for temporary addresses)"
                fi
                echo 2 > "/proc/sys/net/ipv6/conf/$WAN6_INTERFACE/use_tempaddr"
                if [ $? -eq 0 ] ; then
                        logger -t NAT6 "Using temporary addresses for outgoing connections on interface $WAN6_INTERFACE"
                else
                        logger -t NAT6 "Error: Failed to enable temporary addresses for outgoing connections on interface $WAN6_INTERFACE"
                fi
        fi

        exit 0
}
EOF


# 5. Make the script executable and enable it    #修改权限,并生效
chmod +x /etc/init.d/nat6
/etc/init.d/nat6 enable


# 6. In addition, you may now disable the default firewall rule "Allow-ICMPv6-Forward" since it's not needed when masquerading is enabled
uci set firewall.@rule["$(uci show firewall | grep 'Allow-ICMPv6-Forward' | cut -d'[' -f2 | cut -d']' -f1)"].enabled='0'
uci commit firewall


# 7. Modify /etc/sysctl.conf. If entries not exist, add them.
# It's about to receive broadcasts and enable IPv6 transfer.
# NOTICE: The newest 18.06.1 doesn't have net.ipv6.conf.default.forwarding and net.ipv6.conf.all.forwarding,
#         so I have to attach them.
#
# 7.修改/etc/sysctl.conf,把文件中相关内容改为以下内容,没有的话就添加,大概说接收广播并开启ipv6转发
# 注意:最新的18.06.1中没有net.ipv6.conf.default.forwarding和net.ipv6.conf.all.forwarding,需在文件末尾额外添加之
touch /etc/sysctl.conf

a=$(sed -n '/net.ipv6.conf.default.forwarding/=' /etc/sysctl.conf)
if [ ! "$a" ]; then
        echo "net.ipv6.conf.default.forwarding=2" >> /etc/sysctl.conf
else
        sed -i "${a}d; $((a-1))a net.ipv6.conf.default.forwarding=2" /etc/sysctl.conf
fi

a=$(sed -n '/net.ipv6.conf.all.forwarding/=' /etc/sysctl.conf)
if [ ! "$a" ]; then
        echo "net.ipv6.conf.all.forwarding=2" >> /etc/sysctl.conf
else
        sed -i "${a}d; $((a-1))a net.ipv6.conf.all.forwarding=2" /etc/sysctl.conf
fi

a=$(sed -n '/net.ipv6.conf.default.accept_ra/=' /etc/sysctl.conf)
if [ ! "$a" ]; then
        a=$(sed -n '/net.ipv6.conf.all.forwarding/=' /etc/sysctl.conf)
        sed -i "${a}a net.ipv6.conf.default.accept_ra=2" /etc/sysctl.conf
else
        sed -i "${a}d; $((a-1))a net.ipv6.conf.default.accept_ra=2" /etc/sysctl.conf
fi

a=$(sed -n '/net.ipv6.conf.all.accept_ra/=' /etc/sysctl.conf)
if [ ! "$a" ]; then
        a=$(sed -n '/net.ipv6.conf.default.accept_ra/=' /etc/sysctl.conf)
        sed -i "${a}a net.ipv6.conf.all.accept_ra=2" /etc/sysctl.conf
else
        sed -i "${a}d; $((a-1))a net.ipv6.conf.all.accept_ra=2" /etc/sysctl.conf
fi


# 8. Add transfer rules to firewall.
# 8. 加入转发规则,编辑/etc/firewall.user,或路由器界面防火墙规则里加上
echo "ip6tables -t nat -I POSTROUTING -s $(uci get network.globals.ula_prefix) -j MASQUERADE" >> /etc/firewall.user
/etc/init.d/firewall restart


复制上述代码保存为IPV6.sh 并上传到/usr/bin/下,然后chmod +x  /usr/bin/IPV6.sh  ,然后运行 /usr/bin/IPV6.sh


回复

使用道具 举报

 楼主| | 显示全部楼层
hzl88688 发表于 2020-6-2 16:13
#!/bin/sh
# -------------------------------------------------------------------
#        OpenWrt IPv6 自 ...

大神,看到这么多代码直接就懵圈了
回复

使用道具 举报


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
回复

使用道具 举报

 楼主| | 显示全部楼层
回复

使用道具 举报


成功了 谢谢大佬
回复

使用道具 举报


大佬啊,成功了,谢谢啊
回复

使用道具 举报


成功了,谢谢大佬!
回复

使用道具 举报


谢谢大佬,不过我是关了这个就可以了!
回复

使用道具 举报

hzl88688 发表于 2020-6-2 16:13
#!/bin/sh
# -------------------------------------------------------------------
#        OpenWrt IPv6 自动 ...

论坛自动变表情了...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

欢迎大家光临恩山无线论坛上一条 /1 下一条

有疑问请添加管理员QQ86788181|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )

GMT+8, 2024-5-15 00:26

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

| 江苏省互联网有害信息举报中心 举报信箱:js12377 | @jischina.com.cn 举报电话:025-88802724 本站不良内容举报信箱:68610888@qq.com 举报电话:0519-86695797

快速回复 返回顶部 返回列表