Merge pull request #184 from clndwhr/bug/custom-dns-fix

[BUG FIX] Fix for Custom DNS Menu Option
This commit is contained in:
Cameron Thompson
2025-08-24 15:54:44 -04:00
committed by GitHub

View File

@@ -7,7 +7,7 @@ menu() {
echo -e "\e[92m1) Enable/Disable Single IP DMZ Passthrough Mode\e[0m" # Green
echo -e "\e[94m2) Set Gateway Address\e[0m" # Blue
echo -e "\e[93m3) Set DHCP Start/Limit Range\e[0m" # Yellow
echo -e "\e[96m4) Set Custom DNS\e[0m" # Cyan
echo -e "\e[96m4) Set Custom DNS (Recommended to be connected through ADB over USB)(Network restart required)\e[0m" # Cyan
echo -e "\e[95m5) Use Provider's DNS (IPv4 only)\e[0m" # Magenta
echo -e "\e[92m6) Enable/Disable IP Passthrough with NAT (Access to modem's LAN locally)\e[0m" # Green
echo -e "\e[91m7) Exit\e[0m" # Red
@@ -26,11 +26,12 @@ apply_changes() {
# Function to check if IPPT is enabled by inspecting the MPDN rules
is_ippt_enabled() {
local mpdn_output=$(atcmd 'AT+QMAP="mpdn_rule"')
local mpdn_output=$(sms_tool at -t 3 'AT+QMAP="mpdn_rule"')
echo "$mpdn_output"
# Check if any MPDN rule has IPPT enabled (non-zero second-to-last value)
if echo "$mpdn_output" | grep -q "+QMAP: \"MPDN_rule\",.*,.*,.*,[1-9],.*"; then
# The expected format is: +QMAP: "MPDN_rule",<rule_id>,<pdp_id>,<vlan>,<ippt>,<auto-connect>
if echo "$mpdn_output" | grep -q "+QMAP: \"MPDN_rule\",.*,[1-9].*,.*,[1-9],[1-9]"; then
return 0 # IPPT is enabled
else
return 1 # IPPT is not enabled
@@ -41,7 +42,7 @@ is_ippt_enabled() {
are_mpdn_rules_clear() {
local mpdn_output=$(atcmd 'AT+QMAP="mpdn_rule"')
echo "$mpdn_output"
# Check if all MPDN rules are clear (all values are 0)
if echo "$mpdn_output" | grep -q "+QMAP: \"MPDN_rule\",0,0,0,0,0"; then
return 0 # MPDN rules are clear
@@ -208,6 +209,14 @@ toggle_custom_dns() {
get_current_settings "$interface"
local dns=$(prompt "Enter DNS servers (comma-separated)" "$CURRENT_DNS")
if uci show dhcp.$interface &>/dev/null; then
echo -e "\e[93mSetting DNS to: $dns\e[0m" # Yellow
else
uci add dhcp.$interface
echo -e "\e[91m$interface section not found with UCI. Created and set dhcp_option to 6,$dns. \e[0m" # Red
fi
uci set dhcp.$interface.dhcp_option="6,$dns"
apply_changes
}