From 566f5e0f39cbb5bb196a691c4b12f0f1e85a6ab1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Nov 2025 20:24:51 +0000 Subject: [PATCH 1/6] Bump softprops/action-gh-release in the all-actions group Bumps the all-actions group with 1 update: [softprops/action-gh-release](https://github.com/softprops/action-gh-release). Updates `softprops/action-gh-release` from 2.4.1 to 2.4.2 - [Release notes](https://github.com/softprops/action-gh-release/releases) - [Changelog](https://github.com/softprops/action-gh-release/blob/master/CHANGELOG.md) - [Commits](https://github.com/softprops/action-gh-release/compare/v2.4.1...v2.4.2) --- updated-dependencies: - dependency-name: softprops/action-gh-release dependency-version: 2.4.2 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: all-actions ... Signed-off-by: dependabot[bot] --- .github/workflows/Create-NewReleases.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Create-NewReleases.yml b/.github/workflows/Create-NewReleases.yml index d6d2575..09bf9e3 100644 --- a/.github/workflows/Create-NewReleases.yml +++ b/.github/workflows/Create-NewReleases.yml @@ -97,7 +97,7 @@ jobs: # 7--- Publish a GitHub Release with auto-generated notes - name: Create Release with Automated Release Notes - uses: softprops/action-gh-release@v2.4.1 + uses: softprops/action-gh-release@v2.4.2 with: token: ${{ secrets.GITHUB_TOKEN }} tag_name: ${{ steps.nextver.outputs.tag }} From 4c45c9f2527dd8f8cf2ec451c646cc74bf731d81 Mon Sep 17 00:00:00 2001 From: Martinski4GitHub <119833648+Martinski4GitHub@users.noreply.github.com> Date: Fri, 14 Nov 2025 01:22:35 -0800 Subject: [PATCH 2/6] Re-enabled the "Hostnames" file Modified code to re-enable the creation and handling of the "Hostnames" file. --- README.md | 4 +- YazDHCP.sh | 173 ++++++++++++++++++++++++++++++++++++----------------- 2 files changed, 119 insertions(+), 58 deletions(-) diff --git a/README.md b/README.md index a4e2e66..c53e217 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # YazDHCP -## v1.2.3 +## v1.2.4 -### Updated on 2025-Nov-07 +### Updated on 2025-Nov-14 ## About diff --git a/YazDHCP.sh b/YazDHCP.sh index 0194240..5f78a6b 100644 --- a/YazDHCP.sh +++ b/YazDHCP.sh @@ -13,7 +13,7 @@ ## Forked from https://github.com/jackyaz/YazDHCP ## ## ## ########################################################## -# Last Modified: 2025-Nov-07 +# Last Modified: 2025-Nov-14 #--------------------------------------------------------- ############################################# @@ -29,8 +29,8 @@ ### Start of script variables ### readonly SCRIPT_NAME="YazDHCP" -readonly SCRIPT_VERSION="v1.2.3" -readonly SCRIPT_VERSTAG="25110720" +readonly SCRIPT_VERSION="v1.2.4" +readonly SCRIPT_VERSTAG="25111400" SCRIPT_BRANCH="develop" SCRIPT_REPO="https://raw.githubusercontent.com/AMTM-OSR/$SCRIPT_NAME/$SCRIPT_BRANCH" readonly SCRIPT_DIR="/jffs/addons/$SCRIPT_NAME.d" @@ -109,7 +109,7 @@ readonly NVRAM_3004_DHCPvar_RegExp="dhcp_staticlist=[<]?${MACaddr_RegEx}>.+" readonly NVRAM_3006_DHCPvar_RegExp0="dhcpres[1-9][0-9]?_rl=" readonly NVRAM_3006_DHCPvar_RegExp1="${NVRAM_3006_DHCPvar_RegExp0}<${MACaddr_RegEx}>.+" -readonly addnDHCP_HostNames=false +readonly addnDHCP_HostNames=true readonly guestNetInfoJSfileName="GuestNetworkSubnetInfo.js" readonly guestNetInfoJSfilePath="${SCRIPT_DIR}/$guestNetInfoJSfileName" readonly dhcpGuestNetAllowVarKey="allowGuestNet_IPaddr_Reservations" @@ -1751,10 +1751,11 @@ _CleanUp_DNSMasqConfigFiles_() then return fi local gnInfoStr gnListOfIFaces="" gnIFaceName - local staticAddRegExp optionAddRegExp configAddPrefix - local confAddFBKUP configFName configAddFile + local staticAddRegExp optionAddRegExp hostsnAddRegExp + local confAddFBKUP configFName configAddFile configAddPrefix configAddPrefix="${JFFS_Configs_Dir}/dnsmasq-" + hostsnAddRegExp="addn-hosts=${SCRIPT_DIR}/.hostnames_" staticAddRegExp="dhcp-hostsfile=${SCRIPT_DIR}/.staticlist_" optionAddRegExp="dhcp-optsfile=${SCRIPT_DIR}/.optionslist_" @@ -1775,12 +1776,13 @@ _CleanUp_DNSMasqConfigFiles_() then continue fi configAddFile="$(echo "$confAddFBKUP" | grep -oE "${configAddPrefix}.*.conf.add")" - if ! grep -qE "^($staticAddRegExp|$optionAddRegExp).*" "$confAddFBKUP" + if ! grep -qE "^($staticAddRegExp|$optionAddRegExp|$hostsnAddRegExp).*" "$confAddFBKUP" then _MoveOrDeleteFile_ "$confAddFBKUP" continue fi ## Remove unused YazDHCP custom lines ## + sed -i "\\~^${hostsnAddRegExp}.*~d" "$confAddFBKUP" sed -i "\\~^${staticAddRegExp}.*~d" "$confAddFBKUP" sed -i "\\~^${optionAddRegExp}.*~d" "$confAddFBKUP" _MoveOrDeleteFile_ "$confAddFBKUP" @@ -1801,9 +1803,10 @@ _CleanUp_DNSMasqConfigFiles_() fi configAddFile="${JFFS_Configs_Dir}/${configFName}.add" if [ ! -s "$configAddFile" ] || \ - ! grep -qE "^($staticAddRegExp|$optionAddRegExp).*" "$configAddFile" + ! grep -qE "^($staticAddRegExp|$optionAddRegExp|$hostsnAddRegExp).*" "$configAddFile" then ## Remove unused YazDHCP custom lines ## + sed -i "\\~^${hostsnAddRegExp}.*~d" "$configFPATH" sed -i "\\~^${staticAddRegExp}.*~d" "$configFPATH" sed -i "\\~^${optionAddRegExp}.*~d" "$configFPATH" continue @@ -1813,7 +1816,7 @@ _CleanUp_DNSMasqConfigFiles_() then for gnIFaceName in $gnListOfIFaces do - if grep -qE "^($staticAddRegExp|$optionAddRegExp)$gnIFaceName #" "$configAddFile" + if grep -qE "^($staticAddRegExp|$optionAddRegExp|$hostsnAddRegExp)$gnIFaceName #" "$configAddFile" then isConfigAddFileOK=true ; break fi @@ -1821,6 +1824,7 @@ _CleanUp_DNSMasqConfigFiles_() fi "$isConfigAddFileOK" && continue ## Remove unused YazDHCP custom lines ## + sed -i "\\~^${hostsnAddRegExp}.*~d" "$configFPATH" sed -i "\\~^${staticAddRegExp}.*~d" "$configFPATH" sed -i "\\~^${optionAddRegExp}.*~d" "$configFPATH" dnsmasqConfigCHANGED=true @@ -1879,7 +1883,7 @@ Auto_DNSMASQ() ADDN_HostsFilePath="$SCRIPT_DIR/.hostnames" ADDN_HostsComntTag="${SCRIPT_NAME}_hostnames" ADDN_HostsDirctive="addn-hosts=$ADDN_HostsFilePath #${ADDN_HostsComntTag}#" - if ! "$addnDHCP_HostNames" || "$doIFaceDel" + if "$doIFaceDel" then rm -f "$ADDN_HostsFilePath" fi #-----------------------------------------# @@ -1964,7 +1968,7 @@ Auto_DNSMASQ() #----------------# ADDN_HostsComntTag="${SCRIPT_NAME}_hostnames_$gnIFaceName" ADDN_HostsDirctive="addn-hosts=$ADDN_HostsFilePath #${ADDN_HostsComntTag}#" - if ! "$addnDHCP_HostNames" || "$doIFaceDel" + if "$doIFaceDel" then rm -f "$ADDN_HostsFilePath" fi #-----------------------------------------# @@ -3488,23 +3492,34 @@ _CIDR_IPaddrBlockContainsIPaddr_() } ##----------------------------------------## -## Modified by Martinski W. [2025-Sep-05] ## +## Modified by Martinski W. [2025-Oct-19] ## ##----------------------------------------## Update_Hostnames_MainLAN() { - local theMACaddr theIPaddr4 theHostName theDNSaddr theIPaddr3 + local theMACaddr theIPaddr4 theHostName theDNSaddr + local theMACaddrTag theIPaddr3 local LAN_IPaddr3="$(echo "$mainLAN_IPaddr" | cut -d'.' -f1-3)" while IFS=',' read -r theMACaddr theIPaddr4 theHostName theDNSaddr do - if [ "$theMACaddr" = "MAC" ] || \ - [ -z "$theHostName" ] || [ -z "$theIPaddr4" ] + if [ "$theMACaddr" = "MAC" ] || [ -z "$theHostName" ] || \ + [ -z "$theMACaddr" ] || [ -z "$theIPaddr4" ] || \ + ! echo "$theMACaddr" | grep -qE "^${MACaddr_RegEx}$" || \ + ! echo "$theIPaddr4" | grep -qE "^${IPv4privtx_RegEx}$" then continue fi + theMACaddrTag="#${theMACaddr}#" + + if [ -s "$hostNamesFilePATH" ] && \ + grep -q "$theMACaddrTag" "$hostNamesFilePATH" + then continue #Prevent Duplicates# + fi + theIPaddr3="$(echo "$theIPaddr4" | cut -d'.' -f1-3)" - if [ "$theIPaddr3" = "$LAN_IPaddr3" ] + if [ "$theIPaddr3" = "$LAN_IPaddr3" ] || \ + _CIDR_IPaddrBlockContainsIPaddr_ "$mainNET_CIDR" "$theIPaddr4" then - echo "$theIPaddr4 $theHostName" >> "$hostNamesFilePATH" + echo "$theIPaddr4 $theHostName $theMACaddrTag" >> "$hostNamesFilePATH" fi done < "$SCRIPT_CONF" } @@ -3515,24 +3530,27 @@ Update_Hostnames_MainLAN() Update_Hostnames_GuestNet() { local gnExistingMD5 gnUpdatedMD5 theIPaddr3 - local gnInfoStr gnListOfIFaces gnIFaceVarStr - local gnIFaceName gnStartIPaddr4 gnStartIPaddr3 - local theMACaddr theIPaddr4 theHostName theDNSaddr - local hostNamesFileGNET hostNamesFileBKUP gnIFaceDelEntry + local gnInfoStr gnIFaceVarStr gnListOfIFaces="" + local gnIFaceName gnStartIPaddr4 gnStartIPaddr3 gnSubnet_CIDR + local theMACaddr theIPaddr4 theHostName theDNSaddr gnIFaceDelEntry + local hostNamesFileGNET hostNamesFileBKUP theMACaddrTag retCode gnInfoStr="$(_Get_GuestNetwork_SubnetInfo_)" - if [ "${#gnInfoStr}" -eq 0 ] - then return 1 + if [ "${#gnInfoStr}" -gt 0 ] + then + gnListOfIFaces="$(echo "$gnInfoStr" | cut -d'=' -f1 | cut -d'_' -f2)" fi - gnListOfIFaces="$(echo "$gnInfoStr" | cut -d'=' -f1 | cut -d'_' -f2)" if [ -z "$gnListOfIFaces" ] - then return 1 + then + CleanUp_Hostnames_GuestNet + return 1 fi if ! "$(_AllowGuestNetwork_IP_Reservations_ check)" then gnIFaceDelEntry=true else gnIFaceDelEntry=false fi + retCode=1 for gnIFaceName in $gnListOfIFaces do @@ -3544,6 +3562,7 @@ Update_Hostnames_GuestNet() then if [ -s "$hostNamesFileGNET" ] then + retCode=0 Print_Output true "DHCP hostname list for Guest Network [$gnIFaceName] was removed" "$WARN" oneline if [ "$fwInstalledBaseVers" -ge 3006 ] then RESTART_DNSMASQ=true @@ -3562,26 +3581,39 @@ Update_Hostnames_GuestNet() gnIFaceVarStr="GNIFACE_${gnIFaceName}=" gnStartIPaddr4="$(echo "$gnInfoStr" | grep -E "^${gnIFaceVarStr}.*" | cut -d'=' -f2 | cut -d',' -f1)" gnStartIPaddr3="$(echo "$gnStartIPaddr4" | cut -d'.' -f1-3)" + gnSubnet_CIDR="$(echo "$gnInfoStr" | grep -E "^${gnIFaceVarStr}.*" | cut -d'=' -f2 | cut -d',' -f3)" while IFS=',' read -r theMACaddr theIPaddr4 theHostName theDNSaddr do - if [ "$theMACaddr" = "MAC" ] || \ - [ -z "$theHostName" ] || [ -z "$theIPaddr4" ] + if [ "$theMACaddr" = "MAC" ] || [ -z "$theHostName" ] || \ + [ -z "$theMACaddr" ] || [ -z "$theIPaddr4" ] || \ + ! echo "$theMACaddr" | grep -qE "^${MACaddr_RegEx}$" || \ + ! echo "$theIPaddr4" | grep -qE "^${IPv4privtx_RegEx}$" then continue fi + theMACaddrTag="#${theMACaddr}#" + + if [ -s "$hostNamesFilePATH" ] && \ + [ "$fwInstalledBaseVers" -lt 3006 ] && \ + grep -q "$theMACaddrTag" "$hostNamesFilePATH" + then continue #Prevent Duplicates# + fi + theIPaddr3="$(echo "$theIPaddr4" | cut -d'.' -f1-3)" - if [ "$theIPaddr3" = "$gnStartIPaddr3" ] + if [ "$theIPaddr3" = "$gnStartIPaddr3" ] || \ + _CIDR_IPaddrBlockContainsIPaddr_ "$gnSubnet_CIDR" "$theIPaddr4" then - echo "$theIPaddr4 $theHostName" >> "$hostNamesFileGNET" + echo "$theIPaddr4 $theHostName $theMACaddrTag" >> "$hostNamesFileGNET" fi done < "$SCRIPT_CONF" - if [ -s "$hostNamesFileGNET" ] + if [ "$(_GetFileSizeBytes_ "$hostNamesFileGNET")" -ge 3 ] then gnUpdatedMD5="$(md5sum "$hostNamesFileGNET" | awk '{print $1}')" fi if [ -n "$gnUpdatedMD5" ] && [ "$gnExistingMD5" != "$gnUpdatedMD5" ] then + retCode=0 Print_Output true "DHCP hostname list for Guest Network [$gnIFaceName] updated successfully" "$PASS" oneline if [ "$fwInstalledBaseVers" -ge 3006 ] then RESTART_DNSMASQ=true @@ -3590,6 +3622,7 @@ Update_Hostnames_GuestNet() then if [ -s "$hostNamesFileBKUP" ] then + retCode=0 Print_Output true "DHCP hostname list for Guest Network [$gnIFaceName] was removed." "$WARN" oneline if [ "$fwInstalledBaseVers" -ge 3006 ] then RESTART_DNSMASQ=true @@ -3601,11 +3634,44 @@ Update_Hostnames_GuestNet() fi Print_Output true "DHCP hostname list for Guest Network [$gnIFaceName] remains unchanged" "$PASS" oneline fi - if [ "$fwInstalledBaseVers" -lt 3006 ] && [ -s "$hostNamesFileGNET" ] + if [ -s "$hostNamesFileGNET" ] && \ + [ "$fwInstalledBaseVers" -lt 3006 ] then cat "$hostNamesFileGNET" >> "$hostNamesFilePATH" fi "$delBkupCopy" && rm -f "$hostNamesFileBKUP" + if [ "$(_GetFileSizeBytes_ "$hostNamesFileGNET")" -lt 3 ] + then rm -f "$hostNamesFileGNET" + fi + done + + CleanUp_Hostnames_GuestNet + return "$retCode" +} + +##-------------------------------------## +## Added by Martinski W. [2025-Sep-13] ## +##-------------------------------------## +CleanUp_Hostnames_GuestNet() +{ + local gnInfoStr gnIFaceName gnListOfIFaces="" + local hostNamesRegExp hostNamesFPath + + gnInfoStr="$(_Get_GuestNetwork_SubnetInfo_)" + if [ "${#gnInfoStr}" -gt 0 ] + then + gnListOfIFaces="$(echo "$gnInfoStr" | cut -d'=' -f1 | cut -d'_' -f2)" + fi + + hostNamesRegExp="${SCRIPT_DIR}/.hostnames_*" + for hostNamesFPath in $(ls -1 $hostNamesRegExp 2>/dev/null) + do + gnIFaceName="$(basename "$hostNamesFPath" | cut -d'_' -f2)" + if ! echo "$gnIFaceName" | grep -qE "^${guestNetIFaces0RegExp}$" || \ + echo "${gnListOfIFaces:=NONE}" | grep -qw "$gnIFaceName" + then continue + fi + rm -f "$hostNamesFPath" done } @@ -3763,7 +3829,8 @@ Update_StaticList_GuestNet() fi Print_Output true "DHCP IP address reservation list for Guest Network [$gnIFaceName] remains unchanged" "$PASS" oneline fi - if [ "$fwInstalledBaseVers" -lt 3006 ] && [ -s "$staticListFileGNET" ] + if [ -s "$staticListFileGNET" ] && \ + [ "$fwInstalledBaseVers" -lt 3006 ] then cat "$staticListFileGNET" >> "$staticListFilePATH" fi @@ -3949,7 +4016,8 @@ Update_OptionsList_GuestNet() fi Print_Output true "DHCP options list for Guest Network [$gnIFaceName] remains unchanged" "$PASS" oneline fi - if [ "$fwInstalledBaseVers" -lt 3006 ] && [ -s "$optionsListFileGNET" ] + if [ -s "$optionsListFileGNET" ] && \ + [ "$fwInstalledBaseVers" -lt 3006 ] then cat "$optionsListFileGNET" >> "$optionsListFilePATH" fi @@ -3990,56 +4058,49 @@ CleanUp_OptionsList_GuestNet() } ##----------------------------------------## -## Modified by Martinski W. [2025-Sep-05] ## +## Modified by Martinski W. [2025-Nov-14] ## ##----------------------------------------## Update_Hostnames() { local lanExistingMD5="" lanUpdatedMD5="" msgTagStr="" local hostNamesFilePATH="$SCRIPT_DIR/.hostnames" - local hostNamesFileORIG="${hostNamesFilePATH}.BKUP" + local hostNamesFileBKUP="${hostNamesFilePATH}.BKUP" - #----------------------------------------------------------------- - # The Hostnames file is no longer needed because the information - # is now included/embedded in the "staticlist" file. - #----------------------------------------------------------------- - if ! "$addnDHCP_HostNames" - then - rm -f "$hostNamesFilePATH" "$hostNamesFileORIG" - return 0 - fi + ##OFF## ! "$addnDHCP_HostNames" && return 0 ##OFF## if [ -s "$hostNamesFilePATH" ] then lanExistingMD5="$(md5sum "$hostNamesFilePATH" | awk '{print $1}')" - mv -f "$hostNamesFilePATH" "$hostNamesFileORIG" + mv -f "$hostNamesFilePATH" "$hostNamesFileBKUP" fi printf "" > "$hostNamesFilePATH" Update_Hostnames_MainLAN - ##OFF## Update_Hostnames_GuestNet ##OFF## + Update_Hostnames_GuestNet + if [ $? -eq 0 ] || "$(_AllowGuestNetwork_IP_Reservations_ check)" + then msgTagStr="for main LAN [$mainLAN_IFname] " + fi - if [ -s "$hostNamesFilePATH" ] + if [ "$(_GetFileSizeBytes_ "$hostNamesFilePATH")" -ge 3 ] then lanUpdatedMD5="$(md5sum "$hostNamesFilePATH" | awk '{print $1}')" fi - - if "$(_AllowGuestNetwork_IP_Reservations_ check)" - then msgTagStr="for main LAN [$mainLAN_IFname] " - fi - if [ -n "$lanUpdatedMD5" ] && [ "$lanExistingMD5" != "$lanUpdatedMD5" ] then Print_Output true "DHCP hostname list ${msgTagStr}updated successfully" "$PASS" oneline RESTART_DNSMASQ=true - elif [ -n "$lanUpdatedMD5" ] + elif [ -n "$lanUpdatedMD5" ] #NO Change# then - if [ -s "$hostNamesFileORIG" ] - then cp -fp "$hostNamesFileORIG" "$hostNamesFilePATH" + if [ "$(_GetFileSizeBytes_ "$hostNamesFileBKUP")" -ge 3 ] + then cp -fp "$hostNamesFileBKUP" "$hostNamesFilePATH" fi "$verboseMode" && \ Print_Output true "DHCP hostname list ${msgTagStr}remains unchanged" "$PASS" oneline fi - "$delBkupCopy" && rm -f "$hostNamesFileORIG" + "$delBkupCopy" && rm -f "$hostNamesFileBKUP" + if [ "$(_GetFileSizeBytes_ "$hostNamesFilePATH")" -lt 3 ] + then rm -f "$hostNamesFilePATH" + fi } ##----------------------------------------## From feb3f677944e9af3dd84b1d5054cf974b09f617e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Nov 2025 20:29:56 +0000 Subject: [PATCH 3/6] Bump actions/checkout from 5.0.0 to 5.0.1 in the all-actions group Bumps the all-actions group with 1 update: [actions/checkout](https://github.com/actions/checkout). Updates `actions/checkout` from 5.0.0 to 5.0.1 - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v5.0.0...v5.0.1) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: 5.0.1 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: all-actions ... Signed-off-by: dependabot[bot] --- .github/workflows/Create-NewReleases.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Create-NewReleases.yml b/.github/workflows/Create-NewReleases.yml index 09bf9e3..bec8c79 100644 --- a/.github/workflows/Create-NewReleases.yml +++ b/.github/workflows/Create-NewReleases.yml @@ -19,7 +19,7 @@ jobs: steps: # 1--- Check out master so we tag the exact merge commit - name: Checkout source code - uses: actions/checkout@v5.0.0 + uses: actions/checkout@v5.0.1 with: fetch-depth: 0 ref: 'master' From 241984e8b1d856b90d783ee8162314524dd2ada7 Mon Sep 17 00:00:00 2001 From: Martinski4GitHub <119833648+Martinski4GitHub@users.noreply.github.com> Date: Thu, 20 Nov 2025 00:29:54 -0800 Subject: [PATCH 4/6] Code Improvements Some code improvements and fine-tuning. --- README.md | 2 +- YazDHCP.sh | 59 ++++++++++++++++++++++++++++++++++++------------------ 2 files changed, 41 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index c53e217..175a38c 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ## v1.2.4 -### Updated on 2025-Nov-14 +### Updated on 2025-Nov-20 ## About diff --git a/YazDHCP.sh b/YazDHCP.sh index 5f78a6b..25b17d1 100644 --- a/YazDHCP.sh +++ b/YazDHCP.sh @@ -13,7 +13,7 @@ ## Forked from https://github.com/jackyaz/YazDHCP ## ## ## ########################################################## -# Last Modified: 2025-Nov-14 +# Last Modified: 2025-Nov-19 #--------------------------------------------------------- ############################################# @@ -30,7 +30,7 @@ ### Start of script variables ### readonly SCRIPT_NAME="YazDHCP" readonly SCRIPT_VERSION="v1.2.4" -readonly SCRIPT_VERSTAG="25111400" +readonly SCRIPT_VERSTAG="25111923" SCRIPT_BRANCH="develop" SCRIPT_REPO="https://raw.githubusercontent.com/AMTM-OSR/$SCRIPT_NAME/$SCRIPT_BRANCH" readonly SCRIPT_DIR="/jffs/addons/$SCRIPT_NAME.d" @@ -1294,15 +1294,14 @@ _AllowGuestNetwork_IP_Reservations_() ##-------------------------------------## _Get_DHCP_NetworkTagStr_() { - if [ $# -eq 0 ] || [ -z "$1" ] - then echo ; return 1 + if [ $# -lt 2 ] || [ -z "$1" ] || [ -z "$2" ] + then return 1 fi local dnsmasqFileStr="/etc/dnsmasq.conf" - local dhcpOptionStr dhcpRangeStr dhcpNoIFaceID - local theIPaddr3 ipAddr3str ipAddr4str ifaceNameStr + local dhcpOptionStr1 dhcpOptionStr2 dhcpRangeStr1 dhcpRangeStr2 + local theIPaddr3 ipAddr3str ipAddr4str ifaceNameStr dhcpNoIFaceID - if [ "$fwInstalledBaseVers" -ge 3006 ] && \ - { [ $# -lt 2 ] || [ "$2" != "MainLAN" ] ; } + if [ "$fwInstalledBaseVers" -ge 3006 ] && [ "$2" != "MainLAN" ] then dnsmasqFileStr="/etc/dnsmasq*.conf" fi dnsmasqIndxNum="" @@ -1311,33 +1310,55 @@ _Get_DHCP_NetworkTagStr_() ipAddr4str="$(_EscapeChars_ "$1")" theIPaddr3="$(echo "$1" | cut -d'.' -f1-3)" ipAddr3str="$(_EscapeChars_ "$theIPaddr3")" - ifaceNameStr="$(_EscapeChars_ "$2")" + ifaceNameStr="$([ "$2" = "MainLAN" ] && echo "lan" || _EscapeChars_ "$2")" for dnsmasqFile in $(ls -1 $dnsmasqFileStr 2>/dev/null) do - dhcpRangeStr="$(grep -E "^dhcp-range=.*,${ipAddr3str}[.].*," "$dnsmasqFile")" - dhcpOptionStr="$(grep -E "^dhcp-option=.*,(3|option:router),${ipAddr4str}([,].*)?$" "$dnsmasqFile")" dhcpNoIFaceID="$(grep -E "^no-dhcp-interface=$ifaceNameStr" "$dnsmasqFile")" - if [ -z "$dhcpOptionStr" ] && [ -z "$dhcpRangeStr" ] && [ -z "$dhcpNoIFaceID" ] + dhcpRangeStr1="$(grep -E "^dhcp-range=.*,${ipAddr3str}[.].*," "$dnsmasqFile")" + dhcpRangeStr2="$(grep -E "^dhcp-range=(set:)?${ifaceNameStr},${ipAddr3str}[.].*," "$dnsmasqFile")" + dhcpOptionStr1="$(grep -E "^dhcp-option=.*,(3|option:router),${ipAddr4str}([,].*)?$" "$dnsmasqFile")" + dhcpOptionStr2="$(grep -E "^dhcp-option=(tag:)?${ifaceNameStr},(3|option:router),${ipAddr4str}([,].*)?$" "$dnsmasqFile")" + + if [ -z "$dhcpNoIFaceID" ] && \ + [ -z "$dhcpOptionStr1" ] && [ -z "$dhcpRangeStr1" ] && \ + [ -z "$dhcpOptionStr2" ] && [ -z "$dhcpRangeStr2" ] then continue fi - if [ -n "$dhcpOptionStr" ] + if [ -n "$dhcpOptionStr2" ] then - dhcpNetwkTagID="$(echo "$dhcpOptionStr" | cut -d'=' -f2 | cut -d',' -f1)" + dhcpNetwkTagID="$(echo "$dhcpOptionStr2" | cut -d'=' -f2 | cut -d',' -f1)" if echo "$dhcpNetwkTagID" | grep -qE "^tag:.*" then dhcpNetwkTagID="$(echo "$dhcpNetwkTagID" | cut -d':' -f2)" fi fi - if [ -z "$dhcpNetwkTagID" ] && [ -n "$dhcpRangeStr" ] + if [ -z "$dhcpNetwkTagID" ] && [ -n "$dhcpOptionStr1" ] + then + dhcpNetwkTagID="$(echo "$dhcpOptionStr1" | cut -d'=' -f2 | cut -d',' -f1)" + if echo "$dhcpNetwkTagID" | grep -qE "^tag:.*" + then + dhcpNetwkTagID="$(echo "$dhcpNetwkTagID" | cut -d':' -f2)" + fi + fi + if [ -z "$dhcpNetwkTagID" ] && [ -n "$dhcpRangeStr2" ] + then + dhcpNetwkTagID="$(echo "$dhcpRangeStr2" | cut -d'=' -f2 | cut -d',' -f1)" + if echo "$dhcpNetwkTagID" | grep -qE "^set:.*" + then + dhcpNetwkTagID="$(echo "$dhcpNetwkTagID" | cut -d':' -f2)" + fi + fi + if [ -z "$dhcpNetwkTagID" ] && [ -n "$dhcpRangeStr1" ] then - dhcpNetwkTagID="$(echo "$dhcpRangeStr" | cut -d'=' -f2 | cut -d',' -f1)" + dhcpNetwkTagID="$(echo "$dhcpRangeStr1" | cut -d'=' -f2 | cut -d',' -f1)" if echo "$dhcpNetwkTagID" | grep -qE "^set:.*" then dhcpNetwkTagID="$(echo "$dhcpNetwkTagID" | cut -d':' -f2)" fi fi - if echo "$dnsmasqFile" | grep -qE '/etc/dnsmasq-[1-9][0-9]?.conf' + if [ -n "$dhcpNetwkTagID" ] && \ + echo "$dnsmasqFile" | grep -qE '/etc/dnsmasq-[1-9][0-9]?.conf' then dnsmasqIndxNum="$(echo "$dnsmasqFile" | cut -d'-' -f2 | cut -d'.' -f1)" fi @@ -3684,7 +3705,7 @@ Update_StaticList_MainLAN() local hostNameEntry dhcpNetwkTagID dhcpNetTagStr theIPaddr3 local LAN_IPaddr3="$(echo "$mainLAN_IPaddr" | cut -d'.' -f1-3)" - _Get_DHCP_NetworkTagStr_ "$mainLAN_IPaddr" MainLAN + _Get_DHCP_NetworkTagStr_ "$mainLAN_IPaddr" "MainLAN" while IFS=',' read -r theMACaddr theIPaddr4 theHostName theDNSaddr do @@ -3879,7 +3900,7 @@ Update_OptionsList_MainLAN() local dhcpNetwkTagID dhcpNetTagStr theIPaddr3 local LAN_IPaddr3="$(echo "$mainLAN_IPaddr" | cut -d'.' -f1-3)" - _Get_DHCP_NetworkTagStr_ "$mainLAN_IPaddr" MainLAN + _Get_DHCP_NetworkTagStr_ "$mainLAN_IPaddr" "MainLAN" while IFS=',' read -r theMACaddr theIPaddr4 theHostName theDNSaddr do From 60ccd0485cb29fe8f94bb276f912c4a5e8b5fad4 Mon Sep 17 00:00:00 2001 From: Martinski4GitHub <119833648+Martinski4GitHub@users.noreply.github.com> Date: Thu, 20 Nov 2025 01:02:07 -0800 Subject: [PATCH 5/6] Update README.md Updated. --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 175a38c..c132490 100644 --- a/README.md +++ b/README.md @@ -42,13 +42,16 @@ If you do not have Entware installed, you will need to use the full path: ## Changes made to dnsmasq configuration -YazDHCP adds 2 lines to dnsmasq.conf.add to configure DHCP IP address reservations: +YazDHCP adds up to 3 lines to **/jffs/configs/dnsmasq.conf.add** file to configure DHCP IP address reservations: ```sh +addn-hosts=/jffs/addons/YazDHCP.d/.hostnames #YazDHCP_hostnames# dhcp-hostsfile=/jffs/addons/YazDHCP.d/.staticlist #YazDHCP_staticlist# dhcp-optsfile=/jffs/addons/YazDHCP.d/.optionslist #YazDHCP_optionslist# ``` +**addn-hosts** contains a list of IP-address-to-Hostname mappings for DNS resolution of the specified clients. This is particularly useful for a network client whose IP address has been statically assigned on the device itself, not via a DHCP lease. + **dhcp-hostsfile** contains a list of MAC-address-to-IP-address bindings to reserve a specific DHCP IP address for a MAC address. **dhcp-optsfile** contains a list of MAC-address-to-DNS-server-address bindings to provide the specified DNS server as a DHCP option for a MAC address. From 9a0ed11200b2b13e5a99b935b7018faaec2c3e54 Mon Sep 17 00:00:00 2001 From: Martinski4GitHub <119833648+Martinski4GitHub@users.noreply.github.com> Date: Thu, 20 Nov 2025 23:42:46 -0800 Subject: [PATCH 6/6] Code Improvements Some minor code improvements. --- YazDHCP.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/YazDHCP.sh b/YazDHCP.sh index 25b17d1..a896ae7 100644 --- a/YazDHCP.sh +++ b/YazDHCP.sh @@ -13,7 +13,7 @@ ## Forked from https://github.com/jackyaz/YazDHCP ## ## ## ########################################################## -# Last Modified: 2025-Nov-19 +# Last Modified: 2025-Nov-20 #--------------------------------------------------------- ############################################# @@ -30,7 +30,7 @@ ### Start of script variables ### readonly SCRIPT_NAME="YazDHCP" readonly SCRIPT_VERSION="v1.2.4" -readonly SCRIPT_VERSTAG="25111923" +readonly SCRIPT_VERSTAG="25112022" SCRIPT_BRANCH="develop" SCRIPT_REPO="https://raw.githubusercontent.com/AMTM-OSR/$SCRIPT_NAME/$SCRIPT_BRANCH" readonly SCRIPT_DIR="/jffs/addons/$SCRIPT_NAME.d" @@ -754,7 +754,7 @@ Conf_FromSettings() rm -f "${SCRIPT_CONF}.tmp" "$PARSED_FILE" if [ -s "${SCRIPT_CONF}.bak" ] && \ - ! diff "$SCRIPT_CONF" "${SCRIPT_CONF}.bak" >/dev/null 2>&1 + ! diff -q "$SCRIPT_CONF" "${SCRIPT_CONF}.bak" >/dev/null 2>&1 then RESTART_DNSMASQ=true else RESTART_DNSMASQ="$DO_NVRAM_COMMIT" fi @@ -1661,7 +1661,7 @@ Auto_DNSMASQ_Handler() fi #---------------------------------------------------------------------------# if [ ! -s "$configAddFileORIG" ] || \ - ! diff "$configAddFileTEMP" "$configAddFileORIG" >/dev/null 2>&1 + ! diff -q "$configAddFileTEMP" "$configAddFileORIG" >/dev/null 2>&1 then dnsmasqConfigCHANGED=true fi