4 Ways to Find Server Public IP Address in Linux Terminal

In computer networking, an IP (Internet Protocol) address is a numerical identifier assigned permanently or temporarily to every device connected to a network that uses the Internet Protocol for communication. Its two major functions are to identify a network or host on a network and also serve for location addressing.


There are currently two versions of IP addresses: IPv4 and IPv6, which can either be private (viewable within an internal network) or public (can be seen by other machines on the Internet).


Additionally, a host can be assigned a static or dynamic IP address depending on the network configurations. In this article, we will show you 4 ways to find your Linux machine or server public IP address from the terminal in Linux.


1. Using dig Utility


dig (domain information groper) is a simple command-line utility for probing DNS name servers. To find your public IP addresses, use the resolver as in the command below:

$ dig +short


2. Using host Utility


host command is an easy-to-use command-line utility for carrying out DNS lookups. The command below will help to display your systems public IP address.

$ host | grep " has" | awk '{print $4}'


Important: The next two methods employ third party websites to display your IP address on the command line as described below.


3. Using wget Command Line Downloader


wget is a powerful command-line downloader that supports various protocols like HTTP, HTTPS, FTP and many more. You can use it with third-party websites to view your public IP address as follows:

$ wget -qO- | xargs echo
$ wget -qO -


4. Using cURL Command Line Downloader


curl is a popular command-line tool for uploading or downloading files from a server using any of the supported protocols (HTTP, HTTPS, FILE, FTP, FTPS and others). The following commands display your public IP address.

$ curl
$ curl
$ curl


  • Find Server Public IP Address
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

System Requirements

Most current web servers with PHP & MySQL installed will be capable of running WHMCS. The...

Common logs file paths

Log files are helpful in troubleshooting issues and in monitoring the performance of cPanel...

Disable ModSecurity in cPanel

What is ModSecurity?Mod_security is an apache module that helps to protect your website from...

How to disable directory listing in cpanel?

Disable directory listing in cpanelIndex Manger in cPanelThe Index Manager allows you to...

How to disable the listing in a non-cPanel CentOS server?

How to disable the listing in a non-cPanel CentOS server?1. Locate your httpd.conf file. Normally...