Check Public IP on Linux

In a Linux system, there are several ways to view the public IP address.

  1. Use the curl command: enter the following command in the terminal and press Enter.
curl ifconfig.me

This command will send a request to ifconfig.me and return your public IP address.

  1. Use the dig command: type the following command in the terminal and press enter.
dig +short myip.opendns.com @resolver1.opendns.com

This command will query resolver1.opendns.com to retrieve your public IP address.

  1. Use the wget command: type in the following command in the terminal and press enter.
wget -qO- http://ipecho.net/plain ; echo

This command will send a request to ipecho.net and return your public IP address.

  1. Use the ip command: Input the following command in the terminal and press Enter.
ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'

Eth0 is the name of your network interface. If you are using a wireless connection, it might be called wlan0 or a similar interface name.

Any of these methods can be used to view the public IP address on a Linux system.

bannerAds