GL-iNET router not automatically updating network configuration using DHCP

Hello,

I have recently used the imagebuilder and SDK to install OpenWRT on my GL-iNET device and have been transporting it between home, work, etc. Basically am running into an issue when I plug the device in, I would have to SSH into the device (or worse, serial in), to manually restart the network service for it to retrieve new DHCP information and allow it to connect to the outside world.

I do not use a GUI, and I know that running this command fixes it, but I really need this automated so I don't have to mess with SSHing into the thing, running some random command each time I plug an ethernet wire into one of the ethernet ports (whether I have it connected to LAN or WAN doesn't make a difference - the underlying OS doesn't detect/accept network changes without me interfering)

Has anyone else had this issue / was able to script / fix this effectively? I'm basically looking to somehow script or install a package that fixes this issue. (I can't find anything in the image builder that would help with this)

Thanks in advance,

1 Like

This should be completely automatic, with no “script” needed. Would you post the output of logread next time it happens?

It is strange issue. Please, check behavior on another router running stock OpenWRT without additional packages.

This description suggests to me the possibility that the router is remaining powered up as you move around. If so, the issue described may not be surprising if the DHCP lease held for the previous connection is still valid (i.e. the timeout has not yet expired) despite the physical disconnection.

I suppose that would have been pretty critically important to note but yes I do use mobile power for this so it stays on pretty much constantly. That's basically the whole issue I'm having - if i were to power it off and restart it plugged into the desired network it works fine and gets the lease fine. OR if I restart the network service it'll get a new lease. The thing is the device is detecting the link change whenever i plug in an ethernet cord so I feel like there should be a way to automate this. (More on that below)

Good point - I'll give that a shot too. Thanks!

This is the weird thing, its detecting the link change but just naturally assuming it's on the same network segment as before so nothing really changes? Here's kind of how the logs read right now

link changed to 0x00 (unplugged from ethernet at home)
link changed to 0x02 (plugged into new network segment)
-- manually running IFConfig here to see if new IP changes worked - didn't work, still same IP segment as at home --
link changed to 0x00 (unplugged)
link changed to 0x02 (plugged back in)
-- IFConfig shows IP is still the same --
-- manually execute 'service network restart'
-- IFConfig shows new IP (DHCP lease updated)

So basically I just need the thing to automatically get that new lease whenever link changes are detected. I'm wondering - am I missing a package maybe? Again I didn't see anything in the image builder that looked like it'd make a difference but I could just be blind - i'm using a pretty stripped down image. I'll definitely give the stock OpenWRT and report back. Thanks all

1 Like

The use case of the link changing is a bit unusual. The “trick” will likely be to trigger a DHCP refresh when the link comes up, even if it hasn’t timed out yet.

Which device?

I'm not a networking specialist but everything I've experienced and read about DHCP suggests this is the normal behaviour: a link disconnection doesn't automatically cause lease invalidation, and while the lease remains valid the DHCP client isn't going to take any action other than attempting to renew it when that time falls due. You would see the exact same behaviour with a PC moved between wired DHCP networks without power cycling (WiFi works differently).

The fact that your device satisfactorily gets a new lease when power cycled or the network is restarted indicates that the device (and OpenWrt) is working normally, even if that isn't what you expect. Is maintaining the router powered as you move between networks that important?

mt300n-v2 - Agreed, I've started looking into hotplug to script the desired functionality: https://openwrt.org/docs/guide-user/base-system/hotplug

Definitely makes sense, but I tested with a fresh mt300n (GL iNet) (as per ulmwind's post) firmware install and it functioned as I would want (automatically detects new network when I swap it to a new network segment). I'm sure it's something trivial that I'm missing because I stripped the build down to the bare bones when i built the image.

I'd like if possible to keep it powered on - agree that it works fine and as intended on power up but it's important to the use of the device to keep it up and running as much as possible.

1 Like

What packages have you removed in ImageBuilder? Please, give part of log corresponding to network change.
Run command
logread -f > /tmp/log_net.txt
reconnect router, stop logread, and give log_net.txt