|
本帖最后由 xoyoxian 于 2024-4-17 09:17 编辑
这都2024年了,ipv6设置问题大抵已经没有需求了。但是少数情况还是存在不少需求,主要是一些厂区、学校等特殊地方,他们根本没有下发pd前缀,哪怕是ula的前缀也是没有的。我们来看看openwrt官方是怎么说的:
- IPv6 multihoming without BGP.
- Performing stateless 1:1 NAT for migration purposes.
- Your ISP uses a dynamic prefix and you need stable addressing.
- Creating a subnet for when the network doesn't support subnetting.
- Being provided a smaller prefix than a /64 or worse, none at all or a ULA address. (获得比 /64 更小的前缀,或者更糟的是,根本没有前缀或 ULA 地址。)
很不幸的是,我这里的情况就是最后一个,不过我这里是直接/128地址。
首先我这里用的设备是新三,固件是官方的OpenWrt,版本是最新的发行版23.05.3,安装完成之后ssh到路由器,使用下面的脚本来初始化:
- touch /tmp/ini.first.sh
- cat > /tmp/ini.first.sh << EOF
- #!/bin/sh /etc/rc.common
- # 1. system
- uci set system.cfg01e48a.hostname='Ubuntu24.04'
- uci set system.cfg01e48a.zonename='Asia/Shanghai'
- uci set system.cfg01e48a.timezone='CST-8'
- uci commit system
- # network
- uci set network.globals.ula_prefix='fd3d::/48'
- uci set network.lan.ipaddr='192.168.90.1'
- uci set network.wan.peerdns='0'
- uci add_list network.wan.dns='8.8.8.8'
- uci add_list network.wan.dns='114.114.114.114'
- uci set network.wan6.reqaddress='try'
- uci set network.wan6.reqprefix='auto'
- uci set network.wan6.peerdns='0'
- uci add_list network.wan6.dns='2400:3200::1'
- uci add_list network.wan6.dns='2001:4860:4860::8888'
- uci set network.wan6.sourcefilter="0" # Disable IPv6 source filter on the upstream interface.
- uci commit network
- # wireless 2.4
- uci set wireless.radio0.country='CN'
- uci set wireless.radio0.channel='6'
- uci set wireless.default_radio0.ssid='H3C'
- uci set wireless.default_radio0.hidden='1'
- uci set wireless.default_radio0.encryption='sae'
- uci set wireless.default_radio0.key='mylife88'
- # wireless 5.0
- uci set wireless.radio1.country='CN'
- uci set wireless.radio1.channel='149'
- uci set wireless.default_radio1.ssid='H3C'
- uci set wireless.default_radio1.hidden='1'
- uci set wireless.default_radio1.encryption='sae'
- uci set wireless.default_radio1.key='mylife88'
- uci commit wireless
- # dhcp
- uci set dhcp.lan.start=3
- uci set dhcp.lan.limit=30
- uci set dhcp.cfg01411c.sequential_ip=1
- uci set dhcp.lan.ra_default="1"
- uci commit dhcp
- # firewall zone 001 Enable IPv6 masquerading on the upstream zone.
- uci set firewall.@zone[1].masq6="1"
- uci commit firewall
- sleep 8
- reboot
- EOF
- # 5. Make the script executable and enable it #修改权限,并生效
- chmod +x /tmp/ini.first.sh
- /tmp/ini.first.sh
复制代码 重启之后,就已经设置好了。
主要的设置参考官方就是下面两步:
- # Configure firewall
- uci set firewall.@zone[1].masq6="1"
- uci commit firewall
- service firewall restart
- # Configure network
- uci set network.wan6.sourcefilter="0"
- uci commit network
- service network restart
复制代码
查了好久的资料,都说是新版Op采用了nftables,搞了很久都没搞明白,最后实在没办法了,还是op官方给力。
参考资料
1. OpenWRT使用nftables实现IPv6 NAT
2. OpenWrt官方NAT66 and IPv6 masquerading
|
|