Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # View IP Address
- myip() {
- if [ -z "$1" ] || [ "$1" == "--help" ]; then
- echo "Usage: myip OPTION
- OPTIONS:
- --remote displays remote (internet) IP Address
- --local displays local IP Address(s)
- --help display this help and exit
- NOTE: Dependency 'dig' from dnsutils package to fetch remote address";
- elif [ "$1" == "--remote" ]; then
- dig +short myip.opendns.com @resolver1.opendns.com
- elif [ "$1" == "--local" ]; then
- case "$(uname -s)" in
- Darwin|Linux)
- ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'
- ;;
- CYGWIN*|MINGW32*|MSYS*)
- ipconfig | awk '$1 == "IPv4" {print $NF}'
- ;;
- esac
- else
- echo "Invalid arguments supplied. Use --help for more information"
- fi
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement