Force Wan Interface keep sending DHCP request until answered

My provider has issues sometimes replying to DHCP requests in timely manner.
I have to restart wan interface/renew dhcp request to get an IP assigned
Is there a way to make WAN interface to keep sending requests every 30 seconds until IP is assigned?

Any help is appreciated.
Thanks

Hi,

udhcpc, the program in OpenWRT that handles DHCP requests is hardwired to a set of parameters, however you can change it's retry counts and timeouts from defaults by editing the script responsible for calling it.

These are the commands supported by the udhcpc program:

root@OpenWrt:/# udhcpc --help
BusyBox v1.28.3 () multi-call binary.

Usage: udhcpc [-fbqRB] [-t N] [-T SEC] [-A SEC/-n]
[-i IFACE] [-s PROG] [-p PIDFILE]
[-oC] [-r IP] [-V VENDOR] [-F NAME] [-x OPT:VAL]... [-O OPT]...

-i IFACE Interface to use (default eth0)
-s PROG Run PROG at DHCP events (default /usr/share/udhcpc/default.script)
-p FILE Create pidfile
-B Request broadcast replies
-t N Send up to N discover packets (default 3)
-T SEC Pause between packets (default 3)
-A SEC Wait if lease is not obtained (default 20)
-n Exit if lease is not obtained
-q Exit after obtaining lease
-R Release IP on exit
-f Run in foreground
-b Background if lease is not obtained
-S Log to syslog too
-r IP Request this IP address
-o Don't request any options (unless -O is given)
-O OPT Request option OPT from server (cumulative)
-x OPT:VAL Include option OPT in sent packets (cumulative)
Examples of string, numeric, and hex byte opts:
-x hostname:bbox - option 12
-x lease:3600 - option 51 (lease time)
-x 0x3d:0100BEEFC0FFEE - option 61 (client id)
-F NAME Ask server to update DNS mapping for NAME
-V VENDOR Vendor identifier (default 'udhcp VERSION')
-C Don't send MAC as client identifier

I've tracked down the file responsible for invoking the udhcpc command to:
/lib/netifd/proto/dhcp.sh

You can see the command being invoked and the paramters hardwired by default on lines 65 trough 71:

    proto_run_command "$config" udhcpc \                                    
            -p /var/run/udhcpc-$iface.pid \                                 
            -s /lib/netifd/dhcp.script \                                    
            -f -t 0 -i "$iface" \                                           
            ${ipaddr:+-r $ipaddr} \                                         
            ${hostname:+-x "hostname:$hostname"} \                          
            ${vendorid:+-V "$vendorid"} \                                   
            $clientid $defaultreqopts $broadcast $release $dhcpopts     

You could simply add the appropriate -t -T and -A commands at the end of line 67 before the slash.

P.S.: There might be a way to do this trough UCI, but I've searched extensively and couldn't find the commands to set the additional udhcpc parameters.

LP,
Jure

Thanks for pointing in the right direction.