diff --git a/scripts/libs/get_config.sh b/scripts/libs/get_config.sh index af3305d4..31fcdb1d 100644 --- a/scripts/libs/get_config.sh +++ b/scripts/libs/get_config.sh @@ -17,7 +17,7 @@ routing_mark=$((fwmark + 2)) [ -z "$dns_nameserver" ] && { dns_nameserver='223.5.5.5, 1.2.4.8' - netstat -ntlup 2>/dev/null | grep -q '127.0.0.1:53' && dns_nameserver='127.0.0.1' + netstat -ntlup 2>/dev/null | grep -q '127.0.0.1:53' || ss -ntlup 2>/dev/null | grep -q '127.0.0.1:53' && dns_nameserver='127.0.0.1' } [ -z "$dns_fallback" ] && dns_fallback="1.1.1.1, 8.8.8.8" [ -z "$dns_resolver" ] && dns_resolver="223.5.5.5, 2400:3200::1" diff --git a/scripts/menus/8_tools.sh b/scripts/menus/8_tools.sh index ad1c0f7c..95f2e3e1 100644 --- a/scripts/menus/8_tools.sh +++ b/scripts/menus/8_tools.sh @@ -592,10 +592,17 @@ testcommand() { 2) line_break echo "===========================================================" - netstat -ntulp | grep 53 + if ckcmd netstat;then + netstat -ntulp | grep 53 + elif ckcmd ss;then + ss -ntulp | grep 53 + else + echo -e "Neither net-tools nor iproute2 is installed. Please install one of these packages and try again." + fi echo echo -e "$TOOLS_NETSTAT_HINT" echo "===========================================================" + sleep 2 ;; 3) line_break diff --git a/scripts/menus/check_port.sh b/scripts/menus/check_port.sh index 5d5f1acd..ada49d58 100644 --- a/scripts/menus/check_port.sh +++ b/scripts/menus/check_port.sh @@ -1,13 +1,18 @@ #!/bin/sh # Copyright (C) Juewuy +. "$CRASHDIR"/libs/check_cmd.sh + load_lang check_port _get_netstat_cmd() { + local cmd=netstat + ckcmd ss && cmd=ss + case "$1" in - tcp) echo "netstat -ntl" ;; - udp) echo "netstat -nul" ;; - *) echo "netstat -ntul" ;; + tcp) echo "$cmd -ntl" ;; + udp) echo "$cmd -nul" ;; + *) echo "$cmd -ntul" ;; esac } diff --git a/scripts/menus/dns.sh b/scripts/menus/dns.sh index b960d2f3..72b0491a 100644 --- a/scripts/menus/dns.sh +++ b/scripts/menus/dns.sh @@ -95,7 +95,7 @@ set_dns_mod() { ;; *) if [ "$num" -ge 1 ] && [ "$num" -lt 65535 ]; then - if ckcmd netstat && netstat -ntul | grep -q ":$num "; then + if netstat -ntul 2>/dev/null | grep -q ":$num " || ss -ntul 2>/dev/null | grep -q ":$num "; then dns_redir_port="$num" setconfig dns_redir_port "$dns_redir_port" common_success