F2-210手动增加IPv6支持

IPv4/v6、端口、VPN、代理连接、SSH、远程访问
主题已锁定
头像
xiaodong
帖子: 19
注册时间: 2020年 7月 7日 星期二 11:22 pm
China

F2-210手动增加IPv6支持

帖子 xiaodong »

看样子官方应该是不会维护F2-210了,IPv6也不用指望了,只好自己处理了。
有需要的朋友可以按照我的方法开启IPv6支持,但是一定要看好系统版本并且做好备份,本教程仅供有一定基础的朋友参考,本人不对任何系统崩溃及数据丢失、损坏负责
设备:F2-210
版本:4.2.08-2101111540-P1.04 (4.2.08+P1.04补丁),本人系统经过大量修改,如果原生系统不兼容可以留言
网络:路由器PPPOE拨号,开启DHCPv6,NAS自动获取IP、IPv6

主要用到以下三个文件:
/etc/network/interfaces 记得增加执行权限(chmod +x)
/lib/netifd/proto/dhcpv6.sh 记得增加执行权限(chmod +x)
/usr/share/udhcpc/default6.script
修改完后 service network restart
查看ip使用 ip addr 出现公网IPv6地址即可

开始修改:
/etc/network/interfaces
(以下为增加的内容)

代码: 全选

config interface 'lan6'
        option ifname 'eth0'
        option proto 'dhcpv6'
        option ip6ifaceid 'random'
/lib/netifd/proto/dhcpv6.sh

代码: 全选

#!/bin/sh

. /lib/functions.sh
. ../netifd-proto.sh
init_proto "$@"

proto_dhcpv6_init_config() {
        renew_handler=1

        proto_config_add_string 'reqaddress:or("try","force","none")'
        proto_config_add_string 'reqprefix:or("auto","no",range(0, 64))'
        proto_config_add_string clientid
        proto_config_add_string 'reqopts:list(uinteger)'
        proto_config_add_string 'defaultreqopts:bool'
        proto_config_add_string 'noslaaconly:bool'
        proto_config_add_string 'forceprefix:bool'
        proto_config_add_string 'extendprefix:bool'
        proto_config_add_string 'norelease:bool'
        proto_config_add_string 'noserverunicast:bool'
        proto_config_add_string 'noclientfqdn:bool'
        proto_config_add_string 'noacceptreconfig:bool'
        proto_config_add_array 'ip6prefix:list(ip6addr)'
        proto_config_add_string iface_dslite
        proto_config_add_string zone_dslite
        proto_config_add_string encaplimit_dslite
        proto_config_add_string iface_map
        proto_config_add_string zone_map
        proto_config_add_string encaplimit_map
        proto_config_add_string iface_464xlat
        proto_config_add_string zone_464xlat
        proto_config_add_string zone
        proto_config_add_string 'ifaceid:ip6addr'
        proto_config_add_string "userclass"
        proto_config_add_string "vendorclass"
        proto_config_add_array "sendopts:list(string)"
        proto_config_add_boolean delegate
        proto_config_add_int "soltimeout"
        proto_config_add_boolean fakeroutes
        proto_config_add_boolean sourcefilter
        proto_config_add_boolean keep_ra_dnslifetime
        proto_config_add_int "ra_holdoff"
}

proto_dhcpv6_add_prefix() {
        append "$3" "$1"
}

proto_dhcpv6_add_sendopts() {
        [ -n "$1" ] && append "$3" "-x$1"
}

proto_dhcpv6_setup() {
        local config="$1"
        local iface="$2"

        local reqaddress reqprefix clientid reqopts defaultreqopts noslaaconly forceprefix extendprefix norelease noserverunicast noclientfqdn noacceptreconfig ip6prefix ip6prefixes iface_dslite iface_map iface_464xlat ifaceid userclass vendorclass sendopts delegate zone_dslite zone_map zone_464xlat zone encaplimit_dslite encaplimit_map soltimeout fakeroutes sourcefilter keep_ra_dnslifetime ra_holdoff
        json_get_vars reqaddress reqprefix clientid reqopts defaultreqopts noslaaconly forceprefix extendprefix norelease noserverunicast noclientfqdn noacceptreconfig iface_dslite iface_map iface_464xlat ifaceid userclass vendorclass delegate zone_dslite zone_map zone_464xlat zone encaplimit_dslite encaplimit_map soltimeout fakeroutes sourcefilter keep_ra_dnslifetime ra_holdoff
        json_for_each_item proto_dhcpv6_add_prefix ip6prefix ip6prefixes

        # Configure
        local opts=""
        [ -n "$reqaddress" ] && append opts "-N$reqaddress"

        [ -z "$reqprefix" -o "$reqprefix" = "auto" ] && reqprefix=0
        [ "$reqprefix" != "no" ] && append opts "-P$reqprefix"

        [ -n "$clientid" ] && append opts "-c$clientid"

        [ "$defaultreqopts" = "0" ] && append opts "-R"

        [ "$noslaaconly" = "1" ] && append opts "-S"

        [ "$forceprefix" = "1" ] && append opts "-F"

        [ "$norelease" = "1" ] && append opts "-k"

        [ "$noserverunicast" = "1" ] && append opts "-U"

        [ "$noclientfqdn" = "1" ] && append opts "-f"

        [ "$noacceptreconfig" = "1" ] && append opts "-a"

        [ -n "$ifaceid" ] && append opts "-i$ifaceid"

        [ -n "$vendorclass" ] && append opts "-V$vendorclass"

        [ -n "$userclass" ] && append opts "-u$userclass"

        [ "$keep_ra_dnslifetime" = "1" ] && append opts "-L"

        [ -n "$ra_holdoff" ] && append opts "-m$ra_holdoff"

        local opt
        for opt in $reqopts; do
                append opts "-r$opt"
        done

        json_for_each_item proto_dhcpv6_add_sendopts sendopts opts

        append opts "-t${soltimeout:-120}"

        [ -n "$ip6prefixes" ] && proto_export "USERPREFIX=$ip6prefixes"
        [ -n "$iface_dslite" ] && proto_export "IFACE_DSLITE=$iface_dslite"
        [ -n "$iface_map" ] && proto_export "IFACE_MAP=$iface_map"
        [ -n "$iface_464xlat" ] && proto_export "IFACE_464XLAT=$iface_464xlat"
        [ "$delegate" = "0" ] && proto_export "IFACE_DSLITE_DELEGATE=0"
        [ "$delegate" = "0" ] && proto_export "IFACE_MAP_DELEGATE=0"
        [ -n "$zone_dslite" ] && proto_export "ZONE_DSLITE=$zone_dslite"
        [ -n "$zone_map" ] && proto_export "ZONE_MAP=$zone_map"
        [ -n "$zone_464xlat" ] && proto_export "ZONE_464XLAT=$zone_464xlat"
        [ -n "$zone" ] && proto_export "ZONE=$zone"
        [ -n "$encaplimit_dslite" ] && proto_export "ENCAPLIMIT_DSLITE=$encaplimit_dslite"
        [ -n "$encaplimit_map" ] && proto_export "ENCAPLIMIT_MAP=$encaplimit_map"
        [ "$fakeroutes" != "0" ] && proto_export "FAKE_ROUTES=1"
        [ "$sourcefilter" = "0" ] && proto_export "NOSOURCEFILTER=1"
        [ "$extendprefix" = "1" ] && proto_export "EXTENDPREFIX=1"

        proto_export "INTERFACE=$config"
        proto_run_command "$config" udhcpc6 \
                -s /usr/share/udhcpc/default6.script \
                -p /var/run/udhcpc6-$iface.pid \
                -f -i $iface
}

proto_dhcpv6_renew() {
        local interface="$1"
        # SIGUSR1 forces odhcp6c to renew its lease
        local sigusr1="$(kill -l SIGUSR1)"
        [ -n "$sigusr1" ] && proto_kill_command "$interface" $sigusr1
}

proto_dhcpv6_teardown() {
        local interface="$1"
        proto_kill_command "$interface"
}

add_protocol dhcpv6
/usr/share/udhcpc/default6.script

代码: 全选

#!/bin/sh
# udhcpc6 script edited by Tim Riker <Tim@Rikers.org>

RESOLV_CONF="/etc/resolv.conf"

[ -n "$1" ] || { echo "udhcpc6: should be called from udhcpc"; exit 1; }

case "$1" in
        deconfig)
                echo "udhcpc6: setting IP address 0.0.0.0 on $interface"
                ;;

        renew|bound)
                echo "udhcpc6: setting IP address $ipv6 on $interface"
                /bin/ip addr add dev $interface $ipv6/64
                /bin/ip -6 route add dev $interface via $dns 

                echo "udhcpc: recreating $RESOLV_CONF"
                tmpfile="$RESOLV_CONF-$$"
                > "$tmpfile"

                for i in $dns ; do
                        echo "udhcpc: adding DNS server $i"
                        echo "nameserver $i" >> "$tmpfile"
                done
                mv "$tmpfile" "$RESOLV_CONF"
                ;;
esac

exit 0
主题已锁定

回到 “网络与远程访问”