fix linux net

This commit is contained in:
Stephen
2020-11-27 14:31:58 -08:00
parent 9b831166f8
commit f86a321035

View File

@@ -6,14 +6,14 @@ function shownetinfo() {
if [ "$OSTYPE" = "Linux" ]; then if [ "$OSTYPE" = "Linux" ]; then
IP=$(ifconfig | grep -v "127.0.0.1" | grep "inet " | head -1 | cut -d " " -f10) IP=$(ifconfig | grep -v "127.0.0.1" | grep "inet " | head -1 | cut -d " " -f10)
GW=$(ip route | grep default | cut -d " " -f3) NET=$(ip route | grep default | cut -d " " -f3)
elif [ "$OSTYPE" = "Darwin" ]; then elif [ "$OSTYPE" = "Darwin" ]; then
NET=$(system_profiler SPNetworkDataType | grep "Router:" | cut -c 19-30 | head -1) NET=$(system_profiler SPNetworkDataType | grep "Router:" | cut -c 19-30 | head -1)
IP=$(ifconfig | grep -v "127.0.0.1" | grep "inet " | head -1 | cut -d " " -f2) IP=$(ifconfig | grep -v "127.0.0.1" | grep "inet " | head -1 | cut -d " " -f2)
fi
if [ "$NET" != "" ]; then if [ "$NET" != "" ]; then
GW=$(dig +short myip.opendns.com @resolver1.opendns.com) GW=$(dig +short myip.opendns.com @resolver1.opendns.com)
fi fi
fi
tput setaf 7; tput bold; echo -en "Net: " tput setaf 7; tput bold; echo -en "Net: "
tput sgr0 tput sgr0
tput setaf 7; echo -en "internal $IP" tput setaf 7; echo -en "internal $IP"