Skip to content

Instantly share code, notes, and snippets.

@tommelo
Last active October 28, 2016 14:15
Show Gist options
  • Save tommelo/e70479cb3cd1fdf13f8b0149697e9d98 to your computer and use it in GitHub Desktop.
Save tommelo/e70479cb3cd1fdf13f8b0149697e9d98 to your computer and use it in GitHub Desktop.
Lazy Local and External IP
#!/bin/bash
####################################################################################
#
# addr.sh
#
# 'cause we're too damn lazy to read all the information that ifconfig gives us!
#
# Usage:
#
# ./addr.sh
#
# Output:
#
# [local_ip] [external_ip]
#
# Creating a symlink:
#
# sudo chmod +x addr.sh
# sudo ln -s /path/to/addr.sh /usr/bin/addr
#
# Then just call addr on your terminal =)
#
# [mr.church]
#
####################################################################################
akamai="http://whatismyip.akamai.com/"
local_ip=$(ip route get 1.1.1.1 | awk '{print $NF; exit}')
external_ip=$(curl -s $akamai)
echo $local_ip" "$external_ip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment