diff --git a/README.md b/README.md index aceb422..a4e2e66 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ## v1.2.3 -### Updated on 2025-Nov-04 +### Updated on 2025-Nov-07 ## About @@ -56,11 +56,11 @@ 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) @@ -68,7 +68,7 @@ Starting with YazDHCP 1.2.0 version, a new feature was added to allow assigning ![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) @@ -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. @@ -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. diff --git a/YazDHCP.sh b/YazDHCP.sh index 0a2f46d..0194240 100644 --- a/YazDHCP.sh +++ b/YazDHCP.sh @@ -13,7 +13,7 @@ ## Forked from https://github.com/jackyaz/YazDHCP ## ## ## ########################################################## -# Last Modified: 2025-Nov-04 +# Last Modified: 2025-Nov-07 #--------------------------------------------------------- ############################################# @@ -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" @@ -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 @@ -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) @@ -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" @@ -1828,7 +1828,7 @@ _CleanUp_DNSMasqConfigFiles_() } ##----------------------------------------## -## Modified by Martinski W. [2025-Sep-14] ## +## Modified by Martinski W. [2025-Nov-07] ## ##----------------------------------------## Auto_DNSMASQ() { @@ -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 @@ -1938,8 +1942,6 @@ Auto_DNSMASQ() #----------------# # Guest Networks # #----------------# - _SetUp_DNSMasqConfigAddFiles_ - for gnIFaceName in $gnListOfIFaces do ADDN_HostsFilePath="$SCRIPT_DIR/.hostnames_$gnIFaceName" @@ -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 ]