Does changing LAN work?

The default private IP is in the

I need to change this to 172.16.x.x.

I edited this file: /etc/config/network and removed the to 172.16.x.x

I can no longer ssh into the router. I tried the new IP and get "permission denied".

I can connect to wifi and go online. The wifi gives 192.168.2.x.

I connected a LAN cable to the router and it gives the IP address range I changed to earlier. But I cannot connect to LUCI with it, or SSH.

Any help to get back ssh; any help on how to do this properly, would be deeply appreciated.

Where did you configure 192.168.2.x?

You could try configuring a static address, 172.16.x.x or 192.168.1.x, (not conflicting with the router obviously).

If it doesn't work then you probably need to use failsafe mode, since you may have applied a broken configuration.

In the future it's probably a good idea to avoid editing the config file directly, since it's easier to revert the configuration before it has been permanently applied to the config files.


I edited /etc/config/network
I don't think setting up static is necessary as the computer picks up the changes from the router. I simply cannot ssh into the router or use LUCI
I've tried failsafe but that did not work. It will be a pain to reset, as I've spent hours configuring this router.
What's the right way to do this, BTW?

this is the guide I followed:

Can someone please confirm whether it's possible to change the lan ip on openwrt? Seems like a very simple task that I can't get done, two days now.

I've tried the UCI commands. And I'm locked out after.
I'm trying the LUCI option and get these:

Can someone please help.
My router:
OpenWrt 19.07.7 r11306-c4a6851c72 / LuCI openwrt-19.07 branch git-21.044.30835-34e0d65
Thanks a lot.

1 Like

edit the file /et/config/network
/etc/init.d/network restart
reload the ip on the machine that you are ssh in from

1 Like
uci set network.lan.ipaddr='172.16.x.x’
uci commit network
/etc/init.d/network reload

When changing interface IP address I would recommend rebooting the whole network because everything needs to get new addresses from the DHCP server and a total network reboot is the quickest way to do it.
If using luci you need to set the ip address by force because you will loose the connection so it can’t verify the change and it will be reverted.

Before running init.d and after the commit command you can check the network config to check the ip address is actually right by running:

uci show network

or with nicer layout

uci export network

@flygarn12 thanks a lot.
Here are the commands, I ran, in this exact order:
uci set network.lan.ipaddr='’
uci commit network
uci show network
/etc/init.d/network reload
Here is the result:

Then I restarted the router. Turned of the LAN on my laptop, unplugged the Ethernet cable, plugged it back in. And here is the result:
Screen Shot 2021-05-26 at 02.02.00
No. IP this time.
There must be something particular to this router that only a genius can help me with. I have done this oh, so many times. And your help I just used, was used after a brand new re-flash. I only put a very simple password for root. That's all.
The router in question:
D-Link DHP-1565 rev. A1. OpenWrt 19.07.7 r11306-c4a6851c72 / LuCI openwrt-19.07 branch git-21.044.30835-34e0d65
Thanks a lot.

This, I've done. Again, and again, and again. Same results as posted earlier. Thanks!

I now wonder if this is a bug that somehow escaped developers. It sure has put a hold on everything around here. Thanks a lot, if you can help!

Works fine here, master though, why the ? on ipaddr on the network dump.


Something is going wrong your screenshot clearly shows a question mark in the network config IP address setting.


That typo would kill your whole lan network-- lan won't have an IP address assigned, and then there is no way to log in. Windows self-assigns a 169.254 when it can't find a DHCP server.

When configuring via CLI I prefer to edit the /etc/config files directly rather than use uci commands. This way you can see the whole configuration in the context of what is being changed.


If you have the equipment you could try connecting with serial and check what ip address you have in the network config.

But maybe the fault is in the DHCP server?

Have you some other non standard packages installed, have you build it with imagebuilder?

You could try two things.
Factory reset of OpenWRT to really start all over
maybe the firmware is corrupt so you could try to download a new copy and reinstall, check the sha256 so it is correct when installing.

@flygarn12 thanks a lot.
No, I do not have a way to check with serial.
No, I did not build the firmware with Imagebuilder.
No, there is nothing installed.
Just before you started helping, I downloaded a new firmware and re-flashed.
I have done factory reset so many times on this problem, I can do it with my eyes closed.
I think if that's all, then we have a bug.
But did you notice that the IP that I changed, changed after running the command to: If you look at the pictures I posted with the uci export network command, you will see this. Does anyone know why this should happen. Of course, I tried reaching LUCI with that new IP and got now where, because the router will not issue a DHCP address to my machine.
Thanks a lot.

1 Like

@mk24 I have done both; edit the etc/config/network file and used the uci command. Both give the exact same result. The problem is with changing the IP, not the method.
Thanks a lot, Mike.

@dlakelan Hi Daniel, yes, something is wrong. That's what we're trying to figure out, such as why that question mark should show up, when I did not put it there. Until now, infact, I'd thought it was a "7". After looking for a "question mark" in the picture, I noticed that it's not a "7" but a question mark. So, your contribution is wonderful. Thanks a lot for it. Now we have something to ask: why that "?" shows up?

@mk24 Now I know what typo you're talking about; the "?". I did not put it there. I issued:
uci set network.lan.ipaddr='’
Thanks a lot.

@mk24 as it turned out, Mike's astute detective work solved the problem. Indeed, how that "?" got in there I do not know. But if you look even closely, you will notice that the character at the front of that IP is different from the one at the end. So, common-sense was put to play; since the "?" showed up at the end, where it should not be, I simply copied the character at the front and paste it at the end, replacing the one that was there. Then I redid the entire process, using uci commands and Presto! I did not even need to reboot the router. Thanks to all. This has been quite frustrating.

Nice, I overlooked it in the small smartphone screen as “11” instead of “1?”.

This is actually interesting because it is wery similar to a fault I had in my config scripts in the beginning of my unix life. Strange configs was written with uci code that was correct.

The problem turned out that I was writing the config code in windows notepad and windows line ends has the invisible code LFCL but unix only have LF for new lines in a text document.

I found a Windows app called Notepad++ that I could specify the linefeed code. So after starting to write unix text with only LF line ends I never have had a failed config setting like this again.

Did you use copy-paste or script or wrote the text manually in the ssh terminal?