The ISP is giving very short DHCP leases however I'm getting the same ip renewed every time, until I reboot when it seems to forget. The ISP modem had no trouble retaining the same IP address for years. Can I get OpenWRT to remember the existing lease and request the same IP through DHCP on reboot the way it does the rest of the time?
Check that MAC address on the WAN is same as on router label and persists over reboots.
Please connect to your OpenWrt device using ssh and copy the output of the following commands and post it here using the "Preformatted text </>
" button:
Remember to redact passwords, MAC addresses and any public IP addresses you may have:
ubus call system board
ubus call system board
{
"kernel": "5.15.162",
"hostname": "<redacted>",
"system": "ARMv8 Processor rev 4",
"model": "GL.iNet GL-MT6000",
"board_name": "glinet,gl-mt6000",
"rootfs_type": "squashfs",
"release": {
"distribution": "OpenWrt",
"version": "23.05.4",
"revision": "r24012-d8dd03c46f",
"target": "mediatek/filogic",
"description": "OpenWrt 23.05.4 r24012-d8dd03c46f"
}
}
So I was on one IP when I started. I cloned the mac address from the ISP router onto the WAN and save/applied. Then I got a 2nd IP. Then I rebooted and got a third IP.
Check if it is really set in "wan" section of /etc/config/network
The mac address I entered shows up as "macaddr" on the device corresponding to the physical port that is part of my wan interface.
config device
option name 'eth1'
option macaddr '<redacted>'
config interface 'wan'
option device 'eth1'
option proto 'dhcp'
config interface 'wan6'
option device 'eth1'
I don't think the issue is that the ISP remembers and always issues the same ip to the same mac address. I think the old router remembered it's existing lease, where OpenWRT does not. On renewal (at half-expiry without a reboot) I successfully extend the lease on the existing address, but it is not remembering the old lease/address after a reboot. I don't see a technical reason why a reboot should require a new lease inherently or it can't try to renew on the same address as it does the rest of the time. I think OpenWRT just isn't. But I don't know. That is just my theory.
MAC address is main unique identifier, others are hostname and dhcp client version that stay constant unless you do major upgrade or rename host. Those are usually ignored though, just rarely used to set compatibility with very archaic clients.
if so try set static ip for wan interface, use the ip that dhcp assign you.
Unless explicitly recommended by the ISP, that is incorrect and invalid, the ISP's DHCPd won't know about it and assign the IP to others - causing real trouble (and may result in contractual trouble with the ISP).
Actually a nice wislist to maintain old address and send it as -r option on next request. Directed towards netif i think.
To be precise, as a DHCP client, on reboot, I want my router to be in the RENEWING state with regards to it's existing lease: https://www.freesoft.org/CIE/RFC/2131/34.htm
I could have a reboot that happens to fall after the client should enter the rebinding state, but again, this didn't happen for years at a time. It would just be quite a coincidence if my lease expired while I was rebooting. I wouldn't expect that every time.
i see that from op
It was renewing the lease through DHCP on the same address that whole time I expect. If you don't use dhcp and configure a static ip it wouldn't be updating the dhcp server periodically that it's still using the same address, so I suspect the dhcp server would think that address is free to reassign eventually.
That is currently not possible, OpenWrt doesn't retain state beyond reboots.
Probably ISC -> kea migration
I know what you mean, but OpenWRT remembers a lot of state across reboots: just not this piece apparently. Sigh. It could change more often than say the password or the cloned mac address for instance. I was reading that flash media just isn't made to change much (because it'll fail with too much use), so dynamic information such as this it just leaves in memory I guess. But the network the router is hosting has some storage options. It would be nice to be able to point it at a persistent storage for certain convenience things such as this that would tolerate more dynamic writes.
That is interesting. Did you see the database options?
// We need to specify the database used to store leases. As of April
// 2022, three database backends are supported: MySQL, PostgreSQL, and the
// in-memory database, Memfile. We'll use memfile because it doesn't
// require any prior set up.
"lease-database": {
"type": "memfile",
"lfc-interval": 3600
},
I wonder if I could set up a database on the network and point it at it.
Best option is to not store leases and rely on parasitic storage at client. Saves DB disk from wear.
But my real problem is my domain management company doesn't support dynamic dns. Probably easier to just move my domain to one that does and call it good. I just want me and my friends to be able to find the router on the internet without hassle.
Something like tailscale can help