What's new

dhcp_staticlist and dhcp_hostnames utility

  • 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!

This is a slight digression, but is what appears as "Client Name" the same as the hostname supplied by the DHCP client?
 
Thanks, not exactly my question. If I haven't entered it as an alias, what populates the field? For example, all three of my computers with ASRock motherboards have this field populated as "ASRock Corporation". One of my Tivo's has "TIVOandtheserialnumber" and the other says "Dish Technologies". Just curious where these come from, since none of them are from me.
 
Thanks, not exactly my question. If I haven't entered it as an alias, what populates the field? For example, all three of my computers with ASRock motherboards have this field populated as "ASRock Corporation". One of my Tivo's has "TIVOandtheserialnumber" and the other says "Dish Technologies". Just curious where these come from, since none of them are from me.
Probably from the Organizational Unique Identifier, OUI Database lookup aka Vendor ID i.e. first 24-bits of MAC address?

Sometimes the retrieved/assigned OUI Client Description can be puzzling
e.g. Hon Hai is one of the public marketing names for the huge manufacturing company FoxConn that also makes the Apple devices such as iPhone and iPad.

Abject apologies :oops::oops::oops: to @Xentrk for the off-topic posts
 
Last edited:
I verified that one can create an dhcp static lease reservation without entering the hostname. The dhcp-host parameter in dnsmasq.conf.add doesn't require a hostname either. I will need to modify the code to accommodate.
 
Probably from the Organizational Unique Identifier, OUI Database lookup aka Vendor ID i.e. first 24-bits of MAC address?
I think perhaps for the "Device" field and what you get for "Manufacturer" when clicking on a mac address, but not the client name field.

Not so OT, perhaps, as @Xentrk triggered the thought by citing the dnsmasq hostname documentation.

To go a bit further, if one looks at the DHCP log, the "Hostname" filed is populated by something entirely different than what this script is outputting or which appears in the DHCP static list.
 
I verified that one can create an dhcp static lease reservation without entering the hostname.

This is indeed the case, otherwise anyone coming from stock firmware would be facing issues.
 
Xentrk,

I used your script to backup dhcplist on my RT-AX88U ... I observed that some of the items do not have IP addresses as shown below. May I know what have I done wrong? Thanks

Screenshot 2019-10-17 at 4.20.38 PM.png
 
Xentrk,

I used your script to backup dhcplist on my RT-AX88U ... I observed that some of the items do not have IP addresses as shown below. May I know what have I done wrong? Thanks

View attachment 19605
Run these commands and let me know if you get different word count values for staticlist and hostnames:

Code:
awk '{print $0}' /jffs/nvram/dhcp_staticlist | sed 's/<//;s/>undefined//;s/>/ /g;s/</ /g' >/tmp/staticlist.txt
awk '{print $0}' /jffs/nvram/dhcp_hostnames | sed 's/<//;s/>undefined//;s/>/ /g;s/</ /g' >/tmp/hostnames.txt
word_count_staticlist=$(head -1 /tmp/staticlist.$$ | wc -w)
echo "Value of staticlist wc is $word_count_staticlist"
word_count_hostnames=$(head -1 /tmp/hostnames.$$ | wc -w)
echo "Value of hostnames wc is $word_count_hostnames"
rm /tmp/staticlist.txt
rm /tmp/hostnames.txt

EDIT: The code has now been patched to fix the issues listed below
There is a known issue. Entering the hostname on the DHCP Static List screen is optional. If you don't have a hostname entry for clents, the word count won't match and will display an error message. When I wrote the code, I added the word count check as a quality checkpoint not realizing some people don't enter the hostnames. I need to remove the checkpoint. But it did identify an issue where some people where seeing the parameter <undefined> for some dhcp entries. I recommend entering a user friendly hostname to make it easier to identify the client device.

What I also discovered is that HND routers store the mac and ip address of clients in both /jffs/nvram/dhcp_staticlist and nvram get dhcp_staticlist. I need to update the code to backup and restore the nvram variable for HND routers. I'll get it done in the next day or two.
 
Last edited:
Run these commands and let me know if you get different word count values for staticlist and hostnames:
Xentrk,

Thank you for your reply, the word count values are the same, 78:

Code:
awk '{print $0}' /jffs/nvram/dhcp_staticlist | sed 's/<//;s/>undefined//;s/>/ /g;s/</ /g' >/tmp/staticlist.txt
awk '{print $0}' /jffs/nvram/dhcp_hostnames | sed 's/<//;s/>undefined//;s/>/ /g;s/</ /g' >/tmp/hostnames.txt
word_count_staticlist=$(head -1 /tmp/staticlist.txt | wc -w)
echo "Value of staticlist wc is $word_count_staticlist"

Value of staticlist wc is 78

word_count_hostnames=$(head -1 /tmp/hostnames.txt | wc -w)
echo "Value of hostnames wc is $word_count_hostnames"

Value of hostnames wc is 78

rm /tmp/staticlist.txt
rm /tmp/hostnames.txt
 
Xentrk,

Thank you for your reply, the word count values are the same, 78:

Code:
awk '{print $0}' /jffs/nvram/dhcp_staticlist | sed 's/<//;s/>undefined//;s/>/ /g;s/</ /g' >/tmp/staticlist.txt
awk '{print $0}' /jffs/nvram/dhcp_hostnames | sed 's/<//;s/>undefined//;s/>/ /g;s/</ /g' >/tmp/hostnames.txt
word_count_staticlist=$(head -1 /tmp/staticlist.txt | wc -w)
echo "Value of staticlist wc is $word_count_staticlist"

Value of staticlist wc is 78

word_count_hostnames=$(head -1 /tmp/hostnames.txt | wc -w)
echo "Value of hostnames wc is $word_count_hostnames"

Value of hostnames wc is 78

rm /tmp/staticlist.txt
rm /tmp/hostnames.txt
Hello @LimJK

Please double check to make sure you have the most recent version of code:
Code:
####################################################################################################
# Script: dhcpstaticlist.sh
# Original Author: Xentrk
# Last Updated Date: 18-Sept-2019
# Compatible with 384.13
# Version 2.0.2

I noticed you are on 384.14 Alpha. I am aware that additional changes are planned on how the firmware handles hostnames and dhcp information. Not sure if it got implemented in 384.14 Alpha though. With the changes to dhcp_staticlist and dhcp_hostnames in 384.13, the code that produces the list in dnsmasq format had to be rewritten. I can't duplicate the issue on an AC86U and my AC88U development router. Can you send me a PM containing the contents of /jffs/nvram/dhcp_staticlist and /jffs/nvram/dhcp_hostnames so I can do some debugging?
 
Last edited:
Can you send me a PM containing the contents of /jffs/nvram/dhcp_staticlist and /jffs/nvram/dhcp_hostnames so I can do some debugging?
Xentrk or others,
Can someone tell me how to PM and send the 2 files to Xentrk? Sorry, thanks.
 
Xentrk or others,
Can someone tell me how to PM and send the 2 files to Xentrk? Sorry, thanks.
Click on the Inbox option and select "Start a new conversation"
upload_2019-10-18_19-0-44.png
 
The utility has been updated to
  1. Process null hostname entries when displaying (Option 3) or saving in dnsmasq format (Option 4)
  2. Restore function for HND routers has been updated to restore dhcp_staticlist to both /jffs/nvram/dhcp_staticlist and the nvram variable dhcp_staticlist
A warning message is displayed if there are null hostnames:
Code:
Warning: dhcp_staticlist and dhcp_hostnames word count do not match
This indicates you have not entered hostnames for some static IP reservations
Best practice is to enter descriptive hostnames

Press enter to continue

dhcp-host=34:97:E8:25:D4:7A,192.168.22.100
dhcp-host=01:61:57:EC:AF:8E,192.168.22.149,AmazonFireTV-2
dhcp-host=39:05:95:29:E2:7D,192.168.22.150,SamsungTV
dhcp-host=B6:BF:F9:9B:EB:66,192.168.22.151,Samsung-Phone
<snip>
Installation
Code:
/usr/sbin/curl --retry 3 "https://raw.githubusercontent.com/Xentrk/Asuswrt-Merlin-Linux-Shell-Scripts/master/dhcpstaticlist.sh" -o "/jffs/scripts/dhcpstaticlist.sh" && chmod 755 /jffs/scripts/dhcpstaticlist.sh && sh /jffs/scripts/dhcpstaticlist.sh
 
Last edited:
Another patch has been applied to account for an issue reported by @LimJK on an AX88U where dhcp_staticlist contains a new field separator format.
 
Another patch has been applied to account for an issue reported by @LimJK on an AX88U where dhcp_staticlist contains a new field separator format.
Xentrk,
Thank you so much ...
  • it is working as intended now:)
  • I am going to move back from 834.13 to 834.14 Alpha 2 and report back if there is any issue
Code:
##################################################################################
# Script: dhcpstaticlist.sh
# Original Author: Xentrk
# Last Updated Date: 19-October-2019
# Compatible with 384.13
# Version 2.0.5
 
Xentrk,
Just want to update that your new version also works with RT-AX88U_384.14_alpha2-gf219c5fe91. Thanks:)
 
Xentrk,

May I suggest that you consider to include another NVRAM item "custom_clientlist" in your utility, I observed that "ASUS Router" ios App uses this information for devices that are listed in the OFFLINE list.

In the past I have been using John's Script (save-mynvram.sh) or the following to save and restore NVRAM items:
Code:
nvram get dhcp_staticlist > /tmp/mnt/ASUS/dhcplist.txt
nvram get custom_clientlist > /tmp/mnt/ASUS/custom_clientlist.txt
nvram get dhcp_hostnames > /tmp/mnt/ASUS/dhcp_hostnames.txt

However, I found out that dhcp_hostnames has been moved to "/jffs/nvram/dhcp_hostnames" for my RT-AX88U, that was why I started to look for an alternative and found this thread:)
 
Last edited:
Xentrk,

May I suggest that you consider to include another NVRAM item "custom_clientlist" in your utility, I observed that "ASUS Router" ios App uses this information for devices that are listed in the OFFLINE list.

In the past I have been using John's Script (save-mynvram.sh) or the following to save and restore NVRAM items:
Code:
nvram get dhcp_staticlist > /tmp/mnt/ASUS/dhcplist.txt
nvram get custom_clientlist > /tmp/mnt/ASUS/custom_clientlist.txt
nvram get dhcp_hostnames > /tmp/mnt/ASUS/dhcp_hostnames.txt

However, I found out that dhcp_hostnames has been moved to "/jffs/nvram/dhcp_hostnames" for my RT-AX88U, that was why I started to look for an alternative and found this thread:)
I can add that feature. I am curious as to how custom_clientlist gets populated though. Do you know? I have one entry in my AC88U development router and a subset of entries that I have listed for static lease reservations on an AC86U.

I may have a more robust solution though. I did a proof of concept for something similar to the nvram backup and restore utility. nvram parms that you want to back up are listed in a file. For example:
Code:
dhcp1_dns1_x
dhcp1_enable_x
dhcp1_end
dhcp1_gateway_x
dhcp1_lease
dhcp1_start
dhcp1_static_x
dhcp1_staticlist
dhcp1_wins_x
dhcp_dns1_x
dhcp_dns2_x
dhcp_enable_x
dhcp_end
dhcp_gateway_x
dhcp_hostnames
<snip>

The script will then read file line by line which contains the names of the nvram parms and save the nvram settings to a backup file. Similarly for a restore, it will read the backup file line by line and restore the settings. It is nothing as robust as the backup and restore utility though but it should work. Also, there will need to be handling for HND routers because of the way it stores some nvram variables to /jffs/nvarm folder.
 
I can add that feature. I am curious as to how custom_clientlist gets populated though. Do you know? I have one entry in my AC88U development router and a subset of entries that I have listed for static lease reservations on an AC86U.
Xentrk,

From the GUI, under LAN -> LAN - DHCP Server -> Click on the device icon under the manually Assigned IP list as shown in the screenshot below and give it a name in the name field; it is saved in as custom_clientlist in NVRAM. I will PM you my full list of custom_clientlist so that you can see the full format. Thanks for considering:).

Over the years I have saved and restored custom_clientlist successfully on AC68U, AC5300, AC86U and recently AX88U. It is nice to have a one stop process to save selected NVRAM items, as well as those that has moved to /jffs/nvram folder. Thanks.

Screenshot 2019-10-20 at 2.37.37 PM.png
 

Latest threads

Sign Up For SNBForums Daily Digest

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