200字范文,内容丰富有趣,生活中的好帮手!
200字范文 > 潘多拉固件设置ipv6_Phicomm-k2+pandorabox固件+PPPOE拨号+IPV6

潘多拉固件设置ipv6_Phicomm-k2+pandorabox固件+PPPOE拨号+IPV6

时间:2024-06-27 22:22:58

相关推荐

潘多拉固件设置ipv6_Phicomm-k2+pandorabox固件+PPPOE拨号+IPV6

K2路由器插上网线,WIFI是不支持IPv6的,需要开启nat6功能才能在wifi中使用ipv6。

理论上,原生openwrt(!原生openwrt下面过程不适用,需要修改一下)也可以,但是原生openwrt对K2路由器支持不好,2G信号差,速度慢。于是就用了Pandorabox这个固件。信号贼好,木有发现什么问题。

方法1

Step1:刷Pandorabox固件,下载链接,找到K2的固件。

Step2:使路由器连接上网络,用putty登陆路由器

Step3:在putty里面输入

opkg update && opkg install kmod-ipt-nat6

opkg install iputils-tracepath6

Step4:

uci set network.globals.ula_prefix="$(uci get network.globals.ula_prefix | sed 's/^./d/')"

uci commit network

Step5:

uci set dhcp.lan.ra_default='1'

uci commit dhcp

Step6:

touch /etc/init.d/nat6

vi /etc/init.d/nat6

#!/bin/sh /etc/mon

# 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 "Probing 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 "Probing 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

}

Step7:

chmod +x /etc/init.d/nat6

/etc/init.d/nat6 enable

/etc/init.d/nat6 start

Step8:

vim /etc/sysctl.conf

找到并修改:

net.ipv6.conf.default.forwarding=2

net.ipv6.conf.all.forwarding=2

net.ipv6.conf.default.accept_ra=2

net.ipv6.conf.all.accept_ra=2

Step9:

vim /etc/config/dhcp

找到并修改:

config dhcp lan

option interface lan

option start 100

option limit 150

option leasetime 12h

option dhcpv6 server

option ra server

option ra_management 1

option ra_default 1

Step10:

uci set firewall.@rule["$(uci show firewall | grep 'Allow-ICMPv6-Forward' | cut -d'[' -f2 | cut -d']' -f1)"].enabled='0'

uci commit firewall

Step11:

vim /etc/firewall.user

插入:

ip6tables -t nat -I POSTROUTING -s $(uci get network.globals.ula_prefix) -j MASQUERADE

最后:reboot

方法2

step1:安装nat6模块

opkg update && opkg install kmod-ipt-nat6

step2:网络配置

echo "net.ipv6.conf.default.accept_ra=2" >> /etc/sysctl.conf

echo "net.ipv6.conf.all.accept_ra=2" >> /etc/sysctl.conf

uci set network.globals.ula_prefix="$(uci get network.globals.ula_prefix | sed 's/^./d/')"

uci commit network

uci set dhcp.lan.ra_default='1'

uci commit dhcp

step3:添加nat脚本

touch /etc/init.d/nat6

chmod +x /etc/init.d/nat6

vi /etc/init.d/nat6

脚本内容

#!/bin/sh /etc/mon

START=75

ip6tables -t nat -I POSTROUTING -s `uci get network.globals.ula_prefix` -j MASQUERADE

route -A inet6 add 2000::/3 `route -A inet6 | grep ::/0 | awk 'NR==1{print "gw "$2" dev "$7}'`

step4:应用并重启

/etc/init.d/nat6 enable

reboot

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。