How to Configure Static IP Address on Ubuntu 22.04 LTS?

Jul 15, 2022 . Admin

Hi Guys,

In this article we will cover on how to implement How to Configure Static IP Address on Ubuntu 22.04 LTS?. This article goes in detailed on Set a Get Public IP Address on Ubuntu 22.04. This tutorial will give you simple example of Display Public IP Address Using the Command Line in Linux. This post will give you simple example of Get your IP address - Official Ubuntu Documentation. So, let's follow few step to create example of Ubuntu Get Public IP Address Code Example.

You can use this post for ubuntu 14.04, ubuntu 16.04, ubuntu 18.4, ubuntu 20.04, ubuntu 21 and ubuntu 22.04 versions.

Step 1: Use Dig command to get public IP address

The Dig along with the OpenDNS will help you in getting your public IP address on the terminal. The below-given command will be used for this purpose:

$ dig +short myip.opendns.com @resolver1.opendns.com
Step 2: Use host command to get public IP address

You can also find the IP address using the host command that gives you a public IP address through DNS lookups. Run the following host command to get a public IP address:

 
$ host myip.opendns.com resolver1.opendns.com
Step 3: Use wget command to get IP address

You can also get a public IP address using the wget piped with xarg command which is shown below:

$ wget -qO- http://ipecho.net/plain | xargs echo
Step 4: Use curl command to get IP address

Another way to get a public IP address from the terminal on Ubuntu is using the curl command. However, first you will need to install curl using the following command:

 
$ sudo apt install curl

To construct the virtual environment, run the following command inside the directory:

$ curl ifconfig.co

You can also use the curl command with ifconfig.me and it will give the public IP address on the terminal:

$ curl ifconfig.me && echo

Or you can use the following curl command with icanhazip service to get public IP on your Ubuntu 2.04 terminal:

$ curl icanhazip.com && echo
#Ubuntu