How to get IPv6 on second router

Let me explain my network configuration. First is cable modem Arris SB6183 that works as dumb device that pretty much just transfer signal from cable to ethernet. Next is my main router based on TP-Link Archer C7. It has OpenWrt instead of stock firmware and it works great. Effectively cable modem plugged into WAN port of that router and my router does all heavy lifting. Main router is also Wi-Fi access point. But because I have relatively big house and connection cabinet is in one of its corners, I cannot provide stable Wi-Fi connectivity to opposite corner. As result I have second router based on TP-Link TL-WDR4310. It also running OpenWrt. Second routers to connected to main router by ethernet cable and plugged into LAN ports on both routers.

Initially I configured second router very simple. I went to Network|Interfaces, click Edit on LAN and selected Static Address as protocol. Then disable DHCP. Because it is connected via LAN port to main router, it automatically forwards everything to main router and no other setup is required. Second router also works as Wi-Fi access point and cover second half of my house.

This configuration works great for some time. And then I decided to install some package on secondary router. And I got error that package manager cannot connect package repository. Then I did realize that while this router provides internet to all connected devices, it does not have internet by itself. Sounds like cruel joke. Anyway, I found that I didn’t provide default gateway in static IP configuration. I fixed that and I was able to install packaged etc.

Everything works fine, but I was not satisfied. I want IPv6 on my router. I want future of internet to work. Initially I thought that I will change protocol to DHCPv6 client and that’s it. But I was wrong. Doing this will provide only IPv6 address and not IPv4. And if I use DHCP client as protocol then I got only IPv4. And I started researching this topic. At the beginning I found that I have to create another interface and call it for example lan6 and use DHCPv6 client on it. I did but it never able to get IPv6 address and always stayed at disconnected state.

After few hours of searching I found that I was doing it wrong. Lan interface should use DHCP client and then you have to edit file /etc/config/network and add following lines:

config interface 'lan6'
        option proto 'dhcpv6'
        option ifname '@lan'
        option reqprefix 'no'

then restart network, or just restart whole router. I got this from this page: https://openwrt.org/docs/guide-user/network/wifi/dumbap

Now lan6 interface is kind of DHCPv6 alias for lan interface. Now my router got IPv4 and IPv6 addresses automatically and I did learn something today.

I hope it helps someone.