Set static ip if failed to get dhcp ip using udhcp in OpenWrt GUI

Hi @vgaetera

I have run the command shared by you.

sed -i 's%^exec.*%exec \&>"/root/dhcp-fallback-$(date -Iseconds).log"%' /etc/hotplug.d/iface/95-dhcp-fallback

and my updated 95-dhcp-fallback file is

source /lib/functions/network.sh
INTERFACE="br-lan"
NET_ACTION="ifup"
NET_IFLO="lo"
NET_IF="lan"
NET_DELAY="15"
UCI_IP="192.168.1.1"
UCI_MASK="255.255.255.0"
UCI_PROTO="static"

set -x -v
exec &>"/root/dhcp-fallback-$(date -Iseconds).log"
date

if [ "$ACTION" = "$NET_ACTION" -a "$INTERFACE" = "$NET_IFLO" ]
then
sleep "$NET_DELAY"
network_get_ipaddr NET_IP "$NET_IF"
if [ -z "$NET_IP" ]
then
uci set "network.$NET_IF.ipaddr=$UCI_PROTO"
uci set "network.$NET_IF.ipaddr=$UCI_IP"
uci set "network.$NET_IF.netmask=$UCI_MASK"
/etc/init.d/network restart
fi
fi

after that i have rebooted the board and change the router from static to DHCP and find the below logs using command

head -n -0 /root/dhcp-fallback-*

i have these files

root@root:/# head -n -0 /root/dhcp-fallback-2018-10-17T0
dhcp-fallback-2018-10-17T01:56:42+0000.log
dhcp-fallback-2018-10-17T01:56:49+0000.log
dhcp-fallback-2018-10-17T02:29:17+0000.log
dhcp-fallback-2018-10-17T02:29:18+0000.log
dhcp-fallback-2018-10-17T02:29:25+0000.log
root@root:/#

and the content is these files are given below

root@root:/# head -n -0 /root/dhcp-fallback-2018-10-17T02\:29\:25\+0000.log 
date
+ date
Wed Oct 17 02:29:25 UTC 2018



if [ "$ACTION" = "$NET_ACTION" -a "$INTERFACE" = "$NET_IFLO" ]
then
sleep "$NET_DELAY"
network_get_ipaddr NET_IP "$NET_IF"
if [ -z "$NET_IP" ]
then
uci set "network.$NET_IF.ipaddr=$UCI_PROTO"
uci set "network.$NET_IF.ipaddr=$UCI_IP"
uci set "network.$NET_IF.netmask=$UCI_MASK"
/etc/init.d/network restart
fi
fi
+ [ ifup = ifup -a br-lan = lo ]
root@root:/#

Not getting static IP. Thanks in advance

Regards
Sakshi