Cant access OpenWrt device after setting up dhcp client mode on lan interface

Hello. I am using SBC called NanoPi NEO with one ethernet port. I've flashed default image to SD. Default static ip on the router is 192.168.1.1. I changed my pc's ip to 192.168.1.2, mask 255.255.255.0 and gateway 192.168.1.1. NanoPi connected to my homerouter as my pc. So i want to use my SBC as IoT device (it should be part of my home network and get ip from homerouter's dhcp). So I've changed default lan interface's ip of nanopi from static to dhcp client mode. After that i've swiched back my pc settings to dhcp. On my homerouter i see, what openwrt get ip from homerouter's dhcp server. But I can't access luci from browser by this ip.

Does your NanoPi get and address on the same subnet as your PC? What does ping and arp show?

1 Like

I am a bit confused. You have only one router, running third-party or stock firmware, which is 192.168.1.1 and it's the DHCP server, and OpenWrt is only on the Pi?

Are you able to directly access the Pi, set static IP and see if you can access it from the PC?

Which one exactly?

1 Like

Can you ping and SSH to that IP? Maybe Luci is not installed or not running.

1 Like

Well, this guy has the same problem. https://superuser.com/questions/1399943/cant-connect-to-openwrt-after-lan-ip-type-changed-from-static-to-dhcp
LuCI is installed, i've changed settings by web interface.
I cant ping to that ip, but than i am trying led on ethernet port of Pi blink once.
The image i am using is https://downloads.openwrt.org/releases/18.06.2/targets/sunxi/cortexa7/openwrt-18.06.2-sunxi-cortexa7-sun8i-h3-nanopi-neo-ext4-sdcard.img.gz

https://openwrt.org/docs/guide-user/troubleshooting/failsafe_and_factory_reset

1 Like

He's using an SD card... just needs to plug it into any Linux computer and change the settings from there.

2 Likes

I have no idea, what settings I need to change. It just happens, then I use dhcp client option to access my openwrt mini board from another computer in my home network. It works, then I use static one. I repeating, I want to connect my openwrt board by its ethernet port to my existing network. And in this network I have dhcp server. I want to get ip adress from this server to make my openwrt board part of home network.

Mount the card, (partition 2, ext4 file system) and edit /etc/config/network. Almost all the files in OpenWrt are owned by root, so make sure to sudo it on your PC.

Also edit /etc/config/dhcp and turn off the DHCP server on the LAN. Under lan, add an 'option ignore 1' line and delete the two IPv6 lines.

If you changed the address with LuCI it may have reverted on you. When you change the LAN IP with LuCI you have to log back in to the router on the new IP within 30 seconds, or it will revert the setting.

With a DHCP LAN you should also specify a hostname. If the local DNS on your main router is properly set up you can then refer to the device by name. OpenWrt does not automatically send the general hostname out with a DHCP request.

4 Likes

Yea, that was the true problem, LuCI restores config. Is there any setting to disable this behaviour? That is really annoying.

This is the only case that reverting config can be annoying (changing the LAN IP). Other than that it is a good feature that prevents you from locking yourself out of the router.

2 Likes

Easiest way around it is to connect to the router via two network adapters (one with IP in the current subnet and the other with an IP in the new subnet), so when the router check if the PC is accessible, it's.

Edit: I realized that using two adapters will not help with this issue (well, thanks @trendy , but it would at least help to have connection to router if DHCP is off without then need to keep changing IPs or add a secondary IP to your main network adapter. It makes it a little bit easier when you are trying different things.

I beleive you only need to make 2 changes.

  1. Change /etc/config/dhcp to put option ignore '1' under lan.
  2. Change /etc/config/network and add option proto dhcp under lan and remove the static values, such as ip, netmask etc.

After this you can reboot the system and let it connect to the home router network.

2 Likes

Or...
You could add another IP under the same interface, then login with the secondary IP, change the primary, login to the new primary and delete the secondary.

2 Likes

This feature doesn't work as expected. LuCI reverted config even if I had enought time to login under new adress. I had to change my computer settings back to access LuCI under it's default 192.168.1.1 ip. And it said something like that https://forum.openwrt.org/uploads/default/original/2X/6/664ec20255bf5217133c3e881ec6437e05fdad75.png (but what the hell, I have logined to LuCI under it's new ip). Then I hitted red button and everything is ok. So it looks like this feature doesn't work for me. Why there is no option to disable it. For me ther is no problem to reflash .img to sd card, if something will go wrong.

Actually it works as expected. If it doesn't hear from the web client within 30 seconds it will consider that the change was wrong and revert changes. Connecting to the new IP address does not use the already established session in Luci which expects to listen from your web browser. So you can wait for the change to be reverted and hit the "Apply unchecked", apart from the other workarounds mentioned here.
But as I mentioned this is the only case that this feature causes this nuisance.
In your case reflashing the image to sd might not be much of a trouble, but for the majority of the routers without sd, locking yourself out can be quite a pain in the ass.

2 Likes

I have never heard about this feature, but previously, then I have used TP-Link 842nd router, I used recovery mode to restore router to defaults, so losing access to LuCI wan't problem. If this feature is useful for someone, than ok, but I think, it would be better if user can decide enable or disable that behavior.
Anyway, this problem is solved to me, but I can't find any button to close this topic and mark it as solved :slight_smile:

1 Like

Here
grafik

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.