找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 462|回复: 1

新三、NEWIFI3\D2:ipv6 nat6折腾日记

[复制链接]
本帖最后由 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到路由器,使用下面的脚本来初始化:

  1. touch /tmp/ini.first.sh
  2. cat > /tmp/ini.first.sh << EOF
  3. #!/bin/sh /etc/rc.common
  4. # 1. system
  5. uci set system.cfg01e48a.hostname='Ubuntu24.04'
  6. uci set system.cfg01e48a.zonename='Asia/Shanghai'
  7. uci set system.cfg01e48a.timezone='CST-8'
  8. uci commit system

  9. # network
  10. uci set network.globals.ula_prefix='fd3d::/48'
  11. uci set network.lan.ipaddr='192.168.90.1'
  12. uci set network.wan.peerdns='0'
  13. uci add_list network.wan.dns='8.8.8.8'
  14. uci add_list network.wan.dns='114.114.114.114'
  15. uci set network.wan6.reqaddress='try'
  16. uci set network.wan6.reqprefix='auto'
  17. uci set network.wan6.peerdns='0'
  18. uci add_list network.wan6.dns='2400:3200::1'
  19. uci add_list network.wan6.dns='2001:4860:4860::8888'
  20. uci set network.wan6.sourcefilter="0"  # Disable IPv6 source filter on the upstream interface.
  21. uci commit network

  22. # wireless 2.4
  23. uci set wireless.radio0.country='CN'
  24. uci set wireless.radio0.channel='6'
  25. uci set wireless.default_radio0.ssid='H3C'
  26. uci set wireless.default_radio0.hidden='1'
  27. uci set wireless.default_radio0.encryption='sae'
  28. uci set wireless.default_radio0.key='mylife88'
  29. # wireless 5.0
  30. uci set wireless.radio1.country='CN'
  31. uci set wireless.radio1.channel='149'
  32. uci set wireless.default_radio1.ssid='H3C'
  33. uci set wireless.default_radio1.hidden='1'
  34. uci set wireless.default_radio1.encryption='sae'
  35. uci set wireless.default_radio1.key='mylife88'
  36. uci commit wireless

  37. # dhcp
  38. uci set dhcp.lan.start=3
  39. uci set dhcp.lan.limit=30
  40. uci set dhcp.cfg01411c.sequential_ip=1
  41. uci set dhcp.lan.ra_default="1"
  42. uci commit dhcp

  43. # firewall zone  001 Enable IPv6 masquerading on the upstream zone.
  44. uci set firewall.@zone[1].masq6="1"  
  45. uci commit firewall

  46. sleep 8

  47. reboot
  48. EOF


  49. # 5. Make the script executable and enable it    #修改权限,并生效
  50. chmod +x /tmp/ini.first.sh
  51. /tmp/ini.first.sh

复制代码
重启之后,就已经设置好了。

主要的设置参考官方就是下面两步:
  1. # Configure firewall
  2. uci set firewall.@zone[1].masq6="1"
  3. uci commit firewall
  4. service firewall restart

  5. # Configure network
  6. uci set network.wan6.sourcefilter="0"
  7. uci commit network
  8. service network restart
复制代码


查了好久的资料,都说是新版Op采用了nftables,搞了很久都没搞明白,最后实在没办法了,还是op官方给力。

参考资料
1. OpenWRT使用nftables实现IPv6 NAT
2. OpenWrt官方NAT66 and IPv6 masquerading
本帖最后由 ca972008 于 2024-4-17 09:28 编辑

我这里比你稍微好一点,有/64的前缀,可以给局域网内支持的设备,都发一个ipv6的公网地址

从18.06.9版本,就支持ipv6了
回复

使用道具 举报

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

本版积分规则

关闭

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

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

GMT+8, 2024-5-15 03:32

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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

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