minor adjustments to add dhcp section as needed

This commit is contained in:
Christopher Landwehr
2025-08-15 23:34:21 -04:00
parent 09daba4ad5
commit 0e60336199

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,9 +26,9 @@ 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)
# 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
@@ -42,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
@@ -210,14 +210,15 @@ toggle_custom_dns() {
get_current_settings "$interface"
local dns=$(prompt "Enter DNS servers (comma-separated)" "$CURRENT_DNS")
# @Cameron if uci set properties does not exist will uci create it?
if uci get dhcp.$interface.dhcp_option &>/dev/null; then
if uci show dhcp.$interface &>/dev/null; then
echo -e "\e[93mSetting DNS to: $dns\e[0m" # Yellow
uci set dhcp.$interface.dhcp_option="6,$dns"
apply_changes
else
echo -e "\e[91m$interface DHCP_Option Setting not found with UCI. Not setting. \e[0m" # Red
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
}
# Function to use the provider's DNS (IPv4 only)