Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## v1.2.3

### Updated on 2025-Nov-04
### Updated on 2025-Nov-07

## About

Expand Down Expand Up @@ -56,19 +56,19 @@ dhcp-optsfile=/jffs/addons/YazDHCP.d/.optionslist #YazDHCP_optionslist#

## DHCP IP Address Reservations for Guest Network Clients

Starting with YazDHCP 1.2.0 version, a new feature was added to allow assigning DHCP IP address reservations to clients on available Guest Networks whose subnet is separate from the main LAN subnet.
Starting with YazDHCP 1.2.0 version, a new feature was added to allow assigning DHCP IP address reservations to clients on available Guest Networks whose subnet is **separate** from the main LAN subnet.

### DETAILS

1) When YazDHCP is a fresh installation (***not*** a version update), the script automatically checks if there are any DHCP IP address reservations stored in **NVRAM**. If found, it will prompt the user to confirm exporting all the existing reservations from NVRAM to YazDHCP internal files. This export process extracts all the relevant information to create the initial list of network clients from both the Main LAN and the Guest Networks (if any). Also, it allows users to restore the same IP address reservations to their original NVRAM state if you decide to uninstall YazDHCP at a later time.
1) When YazDHCP is a fresh installation (***not*** a version update), the script automatically checks if there are any DHCP IP address reservations stored in **NVRAM**. If found, it will prompt the user to confirm exporting all the existing reservations from NVRAM to YazDHCP internal files. This export process extracts all the relevant information to create the initial list of network clients from both the Main LAN and any suitable Guest Networks. Also, it allows users to restore the same IP address reservations to their original NVRAM state if you decide to uninstall YazDHCP at a later time.

![CLI Install Export](./Images/YazDHCP_Installation_Export.jpg)

2) If a current production version of YazDHCP is already installed, updating to the latest version will add an option '**x**' in the SSH CLI menu to export any existing DHCP IP address reservations stored in NVRAM (if found). If this option is selected, the same export process triggered during a fresh installation will run.

![CLI Menu Export Option](./Images/YazDHCP_CLI_Menu_Export_Option.jpg)

3) After the export of the **NVRAM** DHCP information is completed, any existing IP address reservations from Guest Networks will be shown as **DISABLED** (i.e. red background). Also, by default, if at least one suitable Guest Network is found enabled/active, the new feature is set to **DISABLED**, so the original behavior and functionality continue to run as usual.
3) After the export of the **NVRAM** DHCP information is completed, any existing IP address reservations from suitable Guest Networks will be shown as **DISABLED** (i.e. red background). Also, by default, if at least one suitable Guest Network is found enabled/active, the new feature is set to **DISABLED**, so the original behavior and functionality continue to run as usual.

![WebUI Allow IPs DISABLED](./Images/YazDHCP_WebUI_AllowGN_IPs_DISABLED.jpg)

Expand All @@ -91,7 +91,7 @@ Starting with YazDHCP 1.2.0 version, a new feature was added to allow assigning
9) Whenever the YazDHCP WebUI page is loaded, you will see an 8-to-10 sec. "loading" delay due to the JavaScript call to the shell script requesting a check-and-validation status of each client entry, so the script executes code to validate all the existing client IP address assignments against all the Guest Networks profiles currently found enabled (or possibly disabled), to make sure that the associated virtual interfaces have been identified, and the appropriate dnsmasq directives have been issued to the correct dnsmasq instance associated with each Guest Network.


### IMPORTANT NOTE
### IMPORTANT NOTES

YazDHCP will ***not*** export or transfer any IP address reservations found in user-supplied custom files (e.g. /jffs/configs/dnsmasq*.conf.add) into its own internal files. Only NVRAM-based DHCP settings are checked and transferred.

Expand Down Expand Up @@ -129,6 +129,16 @@ Then manually add your IP address reservations to the CSV file. After you have f

Also, it's very important to make sure you ***remove*** all IP address reservations from your custom files that have been transferred to YazDHCP to prevent dnsmasq from getting duplicate entries/directives, which is bound to cause some issues when restarting the dnsmasq process.

Equally important, make sure to click on the "Apply" button from the YazDHCP webpage whenever any changes occurred, including but not limited to:

- Any Guest Network is enabled or disabled, regardless of the subnet range being separate/different from the Main LAN.
- Any DHCP IP address assignment is manually added, modified, or removed from the list.
- Any CSV file containing IP address assignments is imported, even if the list has not changed.
- Any time a DHCP IP address assignment appears to be ignored or not honored by dnsmasq.

This is to make all changes are synchronized with and reflected on YazDHCP internal files, and dnsmasq is restarted.


## "DHCP Lease" time values

The "DHCP Lease" input field has been enhanced to accept a maximum value of 7776000 seconds (90 days). Values can be entered in seconds (e.g. 86400s), minutes (e.g. 1440m), hours (e.g. 24h), days (e.g. 2d), or weeks (e.g. 2w). A single digit ZERO '0' or an upper-case letter 'I' indicates that an "infinite" lease time value will be applied.
Expand Down
42 changes: 22 additions & 20 deletions YazDHCP.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
## Forked from https://github.com/jackyaz/YazDHCP ##
## ##
##########################################################
# Last Modified: 2025-Nov-04
# Last Modified: 2025-Nov-07
#---------------------------------------------------------

#############################################
Expand All @@ -30,7 +30,7 @@
### Start of script variables ###
readonly SCRIPT_NAME="YazDHCP"
readonly SCRIPT_VERSION="v1.2.3"
readonly SCRIPT_VERSTAG="25110400"
readonly SCRIPT_VERSTAG="25110720"
SCRIPT_BRANCH="develop"
SCRIPT_REPO="https://raw.githubusercontent.com/AMTM-OSR/$SCRIPT_NAME/$SCRIPT_BRANCH"
readonly SCRIPT_DIR="/jffs/addons/$SCRIPT_NAME.d"
Expand Down Expand Up @@ -1750,7 +1750,7 @@ _CleanUp_DNSMasqConfigFiles_()
if [ "$fwInstalledBaseVers" -lt 3006 ]
then return
fi
local gnInfoStr gnListOfIFaces gnIFaceName
local gnInfoStr gnListOfIFaces="" gnIFaceName
local staticAddRegExp optionAddRegExp configAddPrefix
local confAddFBKUP configFName configAddFile

Expand Down Expand Up @@ -1788,12 +1788,9 @@ _CleanUp_DNSMasqConfigFiles_()
done

gnInfoStr="$(_Get_GuestNetwork_SubnetInfo_)"
if [ "${#gnInfoStr}" -eq 0 ]
then return 1
fi
gnListOfIFaces="$(echo "$gnInfoStr" | cut -d'=' -f1 | cut -d'_' -f2)"
if [ -z "$gnListOfIFaces" ]
then return 1
if [ "${#gnInfoStr}" -gt 0 ]
then
gnListOfIFaces="$(echo "$gnInfoStr" | cut -d'=' -f1 | cut -d'_' -f2)"
fi

for configFPATH in $(ls -1 /etc/dnsmasq-*.conf 2>/dev/null)
Expand All @@ -1812,13 +1809,16 @@ _CleanUp_DNSMasqConfigFiles_()
continue
fi
isConfigAddFileOK=false
for gnIFaceName in $gnListOfIFaces
do
if grep -qE "^($staticAddRegExp|$optionAddRegExp)$gnIFaceName #" "$configAddFile"
then
isConfigAddFileOK=true ; break
fi
done
if [ -n "$gnListOfIFaces" ]
then
for gnIFaceName in $gnListOfIFaces
do
if grep -qE "^($staticAddRegExp|$optionAddRegExp)$gnIFaceName #" "$configAddFile"
then
isConfigAddFileOK=true ; break
fi
done
fi
"$isConfigAddFileOK" && continue
## Remove unused YazDHCP custom lines ##
sed -i "\\~^${staticAddRegExp}.*~d" "$configFPATH"
Expand All @@ -1828,7 +1828,7 @@ _CleanUp_DNSMasqConfigFiles_()
}

##----------------------------------------##
## Modified by Martinski W. [2025-Sep-14] ##
## Modified by Martinski W. [2025-Nov-07] ##
##----------------------------------------##
Auto_DNSMASQ()
{
Expand Down Expand Up @@ -1913,15 +1913,19 @@ Auto_DNSMASQ()
return 0
fi

_SetUp_DNSMasqConfigAddFiles_

gnInfoStr="$(_Get_GuestNetwork_SubnetInfo_)"
if [ "${#gnInfoStr}" -eq 0 ]
then
_CleanUp_DNSMasqConfigFiles_
_Restart_DNSMASQ_
return 0
fi
gnListOfIFaces="$(echo "$gnInfoStr" | cut -d'=' -f1 | cut -d'_' -f2)"
if [ -z "$gnListOfIFaces" ]
then
_CleanUp_DNSMasqConfigFiles_
_Restart_DNSMASQ_
return 0
fi
Expand All @@ -1938,8 +1942,6 @@ Auto_DNSMASQ()
#----------------#
# Guest Networks #
#----------------#
_SetUp_DNSMasqConfigAddFiles_

for gnIFaceName in $gnListOfIFaces
do
ADDN_HostsFilePath="$SCRIPT_DIR/.hostnames_$gnIFaceName"
Expand Down Expand Up @@ -4854,7 +4856,7 @@ case "$1" in
if [ "$2" = "restart" ] && [ "$3" = "wireless" ]
then
NTP_Ready
sleepSecs=20
sleepSecs=30
if [ -s /jffs/scripts/YazFi ]
then sleepSecs=60
elif [ "$fwInstalledBaseVers" -lt 3006 ]
Expand Down