What's new

Add DHCP static leases from CLI

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

gatorback

Regular Contributor
It is convenient to be able to add a list DHCP reservations from the CLI (Telnet / SSH). The NVRAM variable: dhcp_staticlist stores dhcp static leases:

<MAC_Addresses> LAN_IPs>hostnames<​

for example:
<B8:27:EB:F6:55:55>192.168.8.6>rapsberrypi<

Code:
nvram show dhcp_staticlist

An example for DD-WRT configuration of static leases from the CLI is provided:
DD-WRT has https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=57955

Has anyone had success configuring Asus Merlin static leases from the CLI? Proposed CLI command for two DHCP entries:

Code:
nvram set dhcp_staticlist= <B8:27:EB:F6:55:55>192.168.8.6>rapsberrypi1< <B8:27:EB:F6:55:56>192.168.8.7>rapsberrypi2<

I am seeking response from those who have successfully outfitted dhcp reservations from the CLI: please indicate in your response if you have been successful with your code / command script
 
Last edited:
It is convenient to be able to add a list DHCP reservations from the CLI (Telnet / SSH). The NVRAM variable: dhcp_staticlist stores dhcp static leases:

<MAC_Addresses> LAN_IPs>hostnames<​

for example:
<B8:27:EB:F6:55:55>192.168.8.6>rapsberrypi<

Code:
nvram show dhcp_staticlist

An example for DD-WRT configuration of static leases from the CLI is provided:
DD-WRT has https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=57955

Has anyone had success configuring Asus Merlin static leases from the CLI? Proposed CLI command for two DHCP entries:

Code:
nvram set dhcp_staticlist= <B8:27:EB:F6:55:55>192.168.8.6>rapsberrypi1< <B8:27:EB:F6:55:56>192.168.8.7>rapsberrypi2<

I am seeking response from those who have successfully outfitted dhcp reservations from the CLI: please indicate in your response if you have been successful with your code / command script
I have done this. The less than sign at the end is actually the first character of the next entry.
Code:
<2C:36:F8:4E:00:00>192.168.50.240>SwitchCisco<D8:49:2F:58:00:00>192.168.50.220>PrinterCanon
Do not add spaces anywhere. I do not use a script, just save, edit and update.
Code:
nvram get dhcp_staticlist > dhcp_staticlist
{edit dhcp_staticlist}
nvram set dhcp_staticlist="$(cat dhcp_staticlist)"
The firmware will tamper with your work. For example, it may reorder the entries by reverse IP address. Also, one of the hostnames on mine had been cleared but put back later.

At least on my router, custom_clientlist is used for custom icons and to associate MAC addresses to hostnames that are not in dhcp_staticlist
 
Last edited:
Brilliant! Was the procedure in your code successfully performed on the RT-AX88U Asuswrt-Merlin 384.10_beta1?
 
Brilliant! Was the procedure in your code successfully performed on the RT-AX88U Asuswrt-Merlin 384.10_beta1?
The last time I ran nvram set commands was after I did a factory default restore at Asuswrt-Merlin 384.9
I am now running 384.10_beta1
 
Another way of doing this is to have a file for static leases and have dnsmasq read that. This has the advantage of being in a much more readable format, not being limited by the nvram max length, and you can use some of the DHCP options like settings two macs for a client (the dnsmasq manual gives the example of a wired/wireless laptop but I use it for my PC which has two ethernet ports where I can never remember which one was plugged in). The only downside is that clients are not listed in the WebUIs manually assigned DHCP list, but that's not much of a problem.

/jffs/configs/dnsmasq.conf.add
Code:
dhcp-hostsfile=/jffs/configs/static_leases

/jffs/configs/static_leases
Code:
B8:27:EB:F6:55:55,192.168.8.6,rapsberrypi1
B8:27:EB:F6:55:56,192.168.8.7,rapsberrypi2
 
.....The only downside is that clients are not listed in the WebUIs manually assigned DHCP list, but that's not much of a problem....

I’m glad you mentioned that: personally, I think I’m more comfortable seeing the list in the WebUI.
 

Similar threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top