- Add internal IP reporting to myip command,
- Add internal IP service CGI script.
This commit is contained in:
51
bin/myip
51
bin/myip
@@ -1,3 +1,52 @@
|
||||
#!/bin/bash
|
||||
|
||||
dig +short myip.opendns.com @resolver1.opendns.com | grep -E '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$'
|
||||
if [[ "$1" == "-h" ]]
|
||||
then
|
||||
echo "myip [-i] | [-a] | [-h]"
|
||||
echo "default: external IP"
|
||||
echo " -i: internal IP"
|
||||
echo " -a: internal + external IP"
|
||||
else
|
||||
if [[ "$1" == "-a" ]]
|
||||
then
|
||||
INT_FLAG="TRUE"
|
||||
EXT_FLAG="TRUE"
|
||||
VERBOSE_FLAG="TRUE"
|
||||
else
|
||||
VERBOSE_FLAG="FALSE"
|
||||
|
||||
if [[ "$1" == "-i" ]]
|
||||
then
|
||||
INT_FLAG="TRUE"
|
||||
EXT_FLAG="FALSE"
|
||||
else
|
||||
INT_FLAG="FALSE"
|
||||
EXT_FLAG="TRUE"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
if [[ ${VERBOSE_FLAG} == "TRUE" ]]
|
||||
then
|
||||
INT_LABEL="internal_ip: "
|
||||
EXT_LABEL="external_ip: "
|
||||
else
|
||||
INT_LABEL=""
|
||||
EXT_LABEL=""
|
||||
fi
|
||||
|
||||
|
||||
if [[ ${INT_FLAG} == "TRUE" ]]
|
||||
then
|
||||
INT_IP="$( curl -s http://www.rx3/cgi-bin/myip.cgi | grep -E '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$')"
|
||||
|
||||
echo "${INT_LABEL}${INT_IP}"
|
||||
fi
|
||||
|
||||
if [[ ${EXT_FLAG} == "TRUE" ]]
|
||||
then
|
||||
EXT_IP="$( dig +short myip.opendns.com @resolver1.opendns.com | grep -E '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$')"
|
||||
|
||||
echo "${EXT_LABEL}${EXT_IP}"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user