0
Hello guys, I wish you are having  a great time. Today, we are going to see how to check your current public IP address from the terminal (CLI) without the need to use the GUI interface. In this tutorial, we will show you a list of command line tools and commands that will easily display your public IP address under Linux operating systems (CentOS, Debian, Fedora, FreeBSD, OpenSUSE, Arch Linux, etc.).



Getting Started

From the terminal, you can check your public IP address by running one of these commands:

For Google Public DNS, issue this command:

dig TXT +short o-o.myaddr.l.google.com @ns1.google.com

or (OpenDNS):

dig +short myip.opendns.com @resolver1.opendns.com

To use the host command line tool, run this command:

host myip.opendns.com resolver1.opendns.com

Output:

$ host myip.opendns.com resolver1.opendns.com
Using domain server:
Name: resolver1.opendns.com
Address: 208.67.222.222#53
Aliases: 
myip.opendns.com has address 41.42.66.172   -------> Public IP Address
Host myip.opendns.com not found: 3(NXDOMAIN)
Host myip.opendns.com not found: 3(NXDOMAIN)

To check my public IP address using the time command-line tool, use this command:

time dig +short myip.opendns.com @resolver1.opendns.com

Some other useful commands:

nc 4.ifcfg.me 23 | grep IPv4 | cut -d' ' -f4 
ifconfig -a 
ip addr show

You can also use some third-party websites to check IP address:

curl icanhazip.com 
curl ifconfig.co 
curl -s http://whatismyip.akamai.com/

Finally, you can also use  the externalip bash script to get your public IP address:

wget https://goo.gl/By7CJK -O externalip 
chmod +x externalip 
sh externalip

Post a Comment

 
Top