Last active
October 28, 2016 14:15
-
-
Save tommelo/e70479cb3cd1fdf13f8b0149697e9d98 to your computer and use it in GitHub Desktop.
Lazy Local and External IP
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 characters
#!/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