-
-
Save isomorpheric/7ed3fff5b1d4833784a5b4fe6ebbd5f8 to your computer and use it in GitHub Desktop.
Revisions
-
pjobson revised this gist
Apr 8, 2022 . 1 changed file with 7 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,23 +9,23 @@ fi VPNIFACE=$1 DEFIFACE=$2 VPNCMD="/mnt/c/Windows/system32/netsh.exe interface show interface \"${VPNIFACE}\"" VPNRES=$(eval "$VPNCMD") DEFCMD="/mnt/c/Windows/system32/netsh.exe interface show interface \"${DEFIFACE}\"" DEFRES=$(eval "$DEFCMD") if [[ "$DEFRES" == *"Disconnected"* ]] && [[ "$VPNRES" == *"Disconnected"* ]]; then echo "Both interfaces are disconnected." exit 0 fi IPCMD="" if [[ "$VPNRES" == *"Disconnected"* ]]; then IPCMD="/mnt/c/Windows/system32/netsh.exe interface ip show addresses \"${DEFIFACE}\"" else IPCMD="/mnt/c/Windows/system32/netsh.exe interface ip show address \"${VPNIFACE}\"" fi IPCMD="${IPCMD} | grep \"IP Address\" | perl -lpe 's/\s+IP Address:\s+(\d+.+?)[\r\n]*\$/\$1:0.0/'" -
pjobson created this gist
Apr 7, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ #!/bin/bash # Check for user input if [ -z "$1" ] || [ -z "$2" ]; then echo "Expects: getdisplayip.sh \"VPN Interface\" \"Default Interface\"" exit 0 fi VPNIFACE=$1 DEFIFACE=$2 VPNCMD="/mnt/c/Windows/system32/netsh.exe interface show interface \"${VPNIFACE}\" | grep \"Disconnected\"" VPNRES=$(eval "$VPNCMD") DEFCMD="/mnt/c/Windows/system32/netsh.exe interface show interface \"${DEFIFACE}\" | grep \"Disconnected\"" DEFRES=$(eval "$DEFCMD") if [[ "$DEFRES" == *"Disconnected"* ]] && [[ "$VPNRES" == *"Disconnected"* ]]; then echo "Both interfaces are disconnected." exit 0 fi # Set the IP Command to use the default, we'll overwrite it with the VPN if it is not disconnected, below. IPCMD="/mnt/c/Windows/system32/netsh.exe interface ip show address \"${DEFIFACE}\"" if [[ "$DEFRES" == *"Disconnected"* ]]; then IPCMD="/mnt/c/Windows/system32/netsh.exe interface ip show addresses \"${VPNIFACE}\"" fi IPCMD="${IPCMD} | grep \"IP Address\" | perl -lpe 's/\s+IP Address:\s+(\d+.+?)[\r\n]*\$/\$1:0.0/'" echo $(eval "$IPCMD")