openwrt之校园网IPV6无线配置

  • 下载openwrt18.06固件

    自从openwrt与lede分支合并后,openwrt最新版18.06本支持了ipv6,固件链接,这里使用widora出品的NEO路由器开发板测试

  • 修改配置文件

    /etc/config/network,其实这个配置就是widora官方固件的默认配置

    config interface 'loopback'
    	option ifname 'lo'
    	option proto 'static'
    	option ipaddr '127.0.0.1'
    	option netmask '255.0.0.0'
    
    config globals 'globals'
    
    config interface 'lan'
    	option type 'bridge'
    	option ifname 'eth0.1'
    	option force_link '1'
    	option macaddr '0c:ef:af:d0:46:d3'
    	option proto 'static'
    	option ipaddr '192.168.8.1'
    	option netmask '255.255.255.0'
    	option ip6assign '60'
    
    config interface 'wan'
    	option ifname 'eth0.2'
    	option force_link '1'
    	option macaddr '0c:ef:ad:d0:46:dd'
    	option proto 'static'
    	option ipaddr 'x.x.x.x'
    	option netmask '255.255.255.0'
    	option gateway 'x.x.x.x'
    	option dns 'x.x.x.x'
    
    config interface 'wan6'
    	option ifname 'eth0.2'
    	option proto 'dhcpv6'
    
    config switch
    	option name 'switch0'
    	option reset '1'
    	option enable_vlan '1'
    
    config switch_vlan
    	option device 'switch0'
    	option vlan '1'
    	option ports '1 2 3 4 6t'
    
    config switch_vlan
    	option device 'switch0'
    	option vlan '2'
    	option ports '0 6t'
    

    /etc/config/dhcp配置,这里使用relay模式

    config dnsmasq
    	option domainneeded '1'
    	option boguspriv '1'
    	option filterwin2k '0'
    	option localise_queries '1'
    	option rebind_protection '1'
    	option rebind_localhost '1'
    	option local '/lan/'
    	option domain 'lan'
    	option expandhosts '1'
    	option nonegcache '0'
    	option authoritative '1'
    	option readethers '1'
    	option leasefile '/tmp/dhcp.leases'
    	option resolvfile '/tmp/resolv.conf.auto'
    	option nonwildcard '1'
    	option localservice '1'
    
    config dhcp 'lan'
    	option interface 'lan'
    	option start '100'
    	option limit '150'
    	option leasetime '12h'
    	option dhcpv6 'relay'
    	option ra 'relay'
    	option ndp 'relay'
    	option ra_management '1'
    
    config dhcp 'wan'
    	option interface 'wan'
    	option ignore '1'
    
    config dhcp 'wan6'
    	option interface 'wan'
    	option ra 'relay'
    	option ndp 'relay'
    	option dhcpv6 'relay'
    	option master '1'
    
    config odhcpd 'odhcpd'
    	option maindhcp '0'
    	option leasefile '/tmp/hosts/odhcpd'
    	option leasetrigger '/usr/sbin/odhcpd-update'
    	option loglevel '4'
    

    /etc/config/wireless配置

    config wifi-device 'radio0'
            option type 'mac80211'
            option channel '11'
            option hwmode '11g'
            option path 'platform/10300000.wmac'
            option htmode 'HT20'
            option disabled '0'
    
    config wifi-iface 'default_radio0'
            option device 'radio0'
            option network 'lan'
            option mode 'ap'
            option ssid 'xxx'
            option encryption 'psk'
            option key 'xxxx'
    
  • reboot重启,ifconfig查看wan6是否获取到ipv6地址

    eth0.2    Link encap:Ethernet  HWaddr 0C:EF:AD:D0:46:DD  
              inet addr:x.x.x.x  Bcast:x.x.x.x  Mask:255.255.255.0
              inet6 addr: 2001:da8:214:1093:eef:adff:fed0:46dd/64 Scope:Global
              inet6 addr: fe80::eef:adff:fed0:46dd/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:27519 errors:0 dropped:37 overruns:0 frame:0
              TX packets:16387 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:39824008 (37.9 MiB)  TX bytes:1664117 (1.5 MiB)
    

    以2001开头即表示获取到了ipv6地址ok,最后就可以使用无线终端连上ipv6,游走各大高校bt站了!科学上网也是可以的!如果没有获取到ipv6地址,查看是否删除了ipv6前缀!

  • 备注

    实际测试了lede17.04版本固件,也能使用ipv6,但是该固件应该存在bug,软件reboot时会卡死,必须硬件重启

  • 参考链接
    OpenWrt/LEDE 内网转发 IPv6

猜你喜欢

转载自blog.csdn.net/robothj/article/details/84499401