[SOLVED] 99-custom did not assign the custom IP

Linksys WRT1900ACS, custom image (imagebuilder) 23.05.5; using the following /files/etc/uci_defaults/99-custom switched on as 192.168.1.1 static instead of 192.168.1.22:

uci -q batch << EOI
set network.lan.ipaddr='192.168.1.22'
commit network
set wireless.@wifi-device[0].disabled='0'
set wireless.@wifi-iface[0].ssid='MyWiFi'
set wireless.@wifi-device[1].disabled='0'
set wireless.@wifi-iface[1].ssid='MyWiFi'
commit wireless
EOI

This 99-custom worked fine with 23.05.3 and all the previous custom images I built (see Image Builder set a static ip? - #7 by WildCarrot): am I missing something?

Also tried a new custom image with the following:

uci -q batch << EOI
set network.lan.ipaddr='192.168.1.22'
set network.lan='interface'
set network.lan.device='br-lan'
set network.lan.proto='dhcp'
set network.lan.force_link='1'
commit network
set wireless.@wifi-device[0].disabled='0'
set wireless.@wifi-iface[0].ssid='MyWiFi'
set wireless.@wifi-device[1].disabled='0'
set wireless.@wifi-iface[1].ssid='MyWiFi'
commit wireless
EOI

The device started again as 192.168.1.1 and static instead of 192.168.1.22 and dhcp: are the above uci commands wrong?

Thanks in advance.

If you want to specify the ip address, the proto must be static. Further, you should specify the subnet mask.

Thanks for your reply; does it apply to the other 99-custom as well? If so, it means something has been changed.

Set the protocol explicitly in any script and you can then guarantee that it will be as you want.

That said, this should typically not be set on each startup. It should be either a firstboot script or set once and saved. Why are you setting it in the normal boot sequence?

My goal was and still is to create an image with imagebuilder in which the IP assigned at the very first boot is .22 because this device is an AP (no dhcp) and .1 is the router (with dhcp); after that, at every following reboot, the device receives .22 from the router.

Is there another way, maybe better, to reach the goal with imagebuilder?

So what you really want on the first boot script is to set the lan interface to proto dhcp if you want the main router to assign the ip address.

Yes it is.

So in that case, delete the ip address and subnet mask, and then change the proto to dhcp.

This way?

uci -q batch << EOI
delete network.lan.ipaddr
delete network.lan.netmask
set network.lan.proto='dhcp'
commit network
[...]
EOI

Yes. That should work.

1 Like

Thank you so much!

By the way, focusing on the actual goal (also thanks for that) and surfing the forum I landed rather quickly here Uci-defaults not applying all changes and got inspired... just a few seconds before you confirmed that.

I'll try next time, but quite sure it works.

1 Like

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