Need your external I.P. address but are tired of going to [insert what's my i.p. website here]?, or are on your way to automate something related in bash?, here's a recipe that permits you to do just that:
In your bin directory, create a file and call it "myip".
/bin/touch myip
Edit the file with your favorite text editor.
/bin/nano myip
Insert the following instruction.
dig +short myip.opendns.com @resolver1.opendns.com
If you don't have dig installed, it's about time you did, it's an excellent network diagnostics tool.
sudo apt install dig
Apply necessary permissions.
/bin/chmod +rwx myip
If your bin directory is in your path environment variable like it already should, then you can just type "myip" from just anywhere and obtain your (IPV4) external address.
you@YOUR-COMPUTER:~$ myip
42.42.42.42
you@YOUR-COMPUTER:~$
Top comments (0)