[Solved] Static leases in uci-defaults

Hi there,

I like to pre-configure my firmware image with some settings in the uci-defaults (IP-Address, WiFi, static leases for my network clients).

IP-Adress and WiFi is no problem.
But I don't see the entries for my static leases.
Maybe there's a problem in my script, or it is not possible?

This is my script, which I use in the firmware builder frontend.

# Beware! This script will be in /rom/etc/uci-defaults/ as part of the image.
# Uncomment lines to apply:
#
# wlan_name="OpenWrt"
# wlan_password="12345678"
#
#root_password=""
lan_ip_address="192.168.99.1"
#

# log potential errors
exec >/tmp/setup.log 2>&1

if [ -n "$root_password" ]; then
  (echo "$root_password"; sleep 1; echo "$root_password") | passwd > /dev/null
fi

# Configure LAN
# More options: https://openwrt.org/docs/guide-user/base-system/basic-networking
if [ -n "$lan_ip_address" ]; then
  uci set network.lan.ipaddr="$lan_ip_address"
  uci commit network
fi

# Configure WLAN
# More options: https://openwrt.org/docs/guide-user/network/wifi/basic#wi-fi_interfaces
if [ -n "$wlan_name" -a -n "$wlan_password" -a ${#wlan_password} -ge 8 ]; then
  uci set wireless.@wifi-device[0].disabled='0'
  uci set wireless.@wifi-iface[0].encryption='psk2'
  uci set wireless.@wifi-iface[0].ssid="$wlan_name"
  uci set wireless.@wifi-iface[0].key="$wlan_password"
  uci commit wireless
fi

#Static Names
uci add host
uci set dhcp.@host[-1].name='laptop-sony-lan'
uci set dhcp.@host[-1].mac='FF:FF:FF:FF:FF:FF'
uci set dhcp.@host[-1].ip='192.168.99.23'
uci commit dhcp

echo "All done!"

Maybe someone can help me?

Thanks for your help :slight_smile:
Dominik

dhcp host
Fixed with right prefix.

2 Likes

Oh dammit. I missed that :see_no_evil:
Thanks for the fast help :slight_smile:

1 Like

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