local ips
This commit is contained in:
@@ -4,14 +4,24 @@
|
|||||||
function helpexit() {
|
function helpexit() {
|
||||||
echo "Print your public internet IP address."
|
echo "Print your public internet IP address."
|
||||||
echo "-n return as host name."
|
echo "-n return as host name."
|
||||||
|
echo "-l display only local addresses."
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
function locals_only() {
|
||||||
|
ip -4 -o addr | awk '!/^[0-9]*: ?lo|link\/ether/ {printf "%18s %s\n", $4, $2}' | sort -k 2
|
||||||
|
exit $?
|
||||||
|
}
|
||||||
for (( i=1; i<=$#; i++ )); do
|
for (( i=1; i<=$#; i++ )); do
|
||||||
[[ "${!i}" = "--help" ]] && helpexit
|
[[ "${!i}" = "--help" ]] && helpexit
|
||||||
[[ "${!i}" = "-h" ]] && helpexit
|
[[ "${!i}" = "-h" ]] && helpexit
|
||||||
[[ "${!i}" = "-n" ]] && { NAME=1; continue; }
|
[[ "${!i}" = "-n" ]] && { NAME=1; continue; }
|
||||||
|
[[ "${!i}" = "-l" ]] && { LOCAL=1; continue; }
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [[ "$LOCAL" -eq 1 ]]; then
|
||||||
|
locals_only
|
||||||
|
fi
|
||||||
|
|
||||||
which dig &> /dev/null || {
|
which dig &> /dev/null || {
|
||||||
echo Install apt dnsutils >&2
|
echo Install apt dnsutils >&2
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
Reference in New Issue
Block a user