Get Public IP on Ubuntu 20.04-Linux Hint from Terminal

Get Public IP on Ubuntu 20.04-Linux Hint from Terminal

Should you’re utilizing the web, you then’ve heard of IP handle, proper? In laptop networking, an IP (Web Protocol) handle is a numerical identifier to establish a sure gadget that makes use of the Web Protocol for communication. The IP handle could also be assigned briefly or completely to the gadget.When the gadget connects to different gadgets via the community, different gadgets see the general public IP handle. On this information, try tips on how to get the general public IP handle of your gadget from the terminal on Ubuntu 20.04.

IP handle fundamentals

There are two variations of IP addresses at present in use: IPv4 and IPv6. Any IP handle may be both non-public (may be seen solely inside a community) or public (may be seen from any machine on the web). IPv4 is but the most well-liked format however within the present period, it could’t assign sufficient gadgets with distinctive IP addresses. The IPv6 solves this by growing the variety of accessible distinctive IP addresses.

Let’s have a fast take a look at what an IP handle appears like. Within the case of IPv4, it’s a 32-bit (Four bytes) handle divided into 4 8-bit blocks separated by “.” symbols. The handle is represented with decimal digits.

The attainable vary of IPv4 is from 0.0.0.Zero to 255.255.255.255.

Within the case of IPv6, it’s a bit difficult however related in precept. An IPv6 handle is a 128-bit (Eight bytes) handle divided into eight 16-bit blocks separated by “:” symbols. The handle is represented with hexadecimal digits.

$ 2000:0000:3339:CFF1:0069:0000:0000:FEFD

Due to its sheer size, it may be problematic to make use of in varied conditions. As such, there are guidelines to shorten the handle. After shortening the instance handle, it’ll look one thing like this.

$ 2000:0:3339:CFF1:69::FEFD

Get the general public IP handle from terminal

Now, we’re able to seize the general public IP handle of our gadget. There are a number of methods to take action. For instance, when you’ve got entry to GUI, then you should use the net browser to go to websites like WhatIsMyIPAddress, WhatIsMyIP, and many others.

Because the title of the information suggests, we’ll be exploring the methods of checking the IP handle via the terminal solely. Fortunately, there are a number of instruments accessible at our disposal to verify the general public IP handle.

Get public IP handle utilizing dig

The dig (area data groper) is a straightforward utility instrument for probing DNS title servers. Utilizing the dig instrument together with OpenDNS as a resolver, we are able to get the general public IP handle.

$ dig +brief myip.opendns.com @resolver1.opendns.com

Get Public IP on Ubuntu 20.04-Linux Hint from Terminal

Get public IP handle utilizing the host

The host command is one other easy instrument for performing DNS lookups. To get your public IP utilizing host, run the next command.

$ host myip.opendns.com resolver1.opendns.com

Get Public IP on Ubuntu 20.04-Linux Hint from Terminal

The output is barely greater than the earlier instance. Need simply the IP handle because the output? Then go the output to grep and awk to filter it out. Be taught extra about grep and awk.

$ host myip.opendns.com resolver1.opendns.com |
grep “myip.opendns.com has” | awk ‘{print $4}’

Get Public IP on Ubuntu 20.04-Linux Hint from Terminal

Get public IP handle utilizing wget

Wget is a straightforward and highly effective command-line downloader. How can we use wget to get the general public IP handle? By downloading a sure file from a sure on-line service.

First, make it possible for the wget is put in in your system. Run the next command.

$ sudo apt replace && sudo apt set up wget -y

Get Public IP on Ubuntu 20.04-Linux Hint from Terminal

We’re able to verify the general public IP handle. The primary one is IP Echo Service. Run the next command.

$ wget -qO- http://ipecho.internet/plain | xargs echo

Get Public IP on Ubuntu 20.04-Linux Hint from Terminal

The following one is icanhazip.com. This web site returns the general public IP handle in a plain textual content format.

$ wget -qO- icanhazip.com

Get Public IP on Ubuntu 20.04-Linux Hint from Terminal

One other related service is ifconfig.co.

Get Public IP on Ubuntu 20.04-Linux Hint from Terminal

You may also use ifconfig.me to get the IP handle.

$ wget -qO- ifconfig.me | xargs echo

Get Public IP on Ubuntu 20.04-Linux Hint from Terminal

Get public IP handle utilizing cURL

The curl instrument is one other common command-line downloader/uploader that may function on any of the favored protocols (HTTP, HTTPS, FTP, FTPS, and others).

Curl doesn’t come pre-installed on Ubuntu 20.04. Set up curl.

$ sudo apt replace && sudo apt set up curl -y

Get Public IP on Ubuntu 20.04-Linux Hint from Terminal

The tactic is just like the wget one.

Get Public IP on Ubuntu 20.04-Linux Hint from Terminal

$ curl ifconfig.me && echo

Get Public IP on Ubuntu 20.04-Linux Hint from Terminal

$ curl icanhazip.com && echo

Get Public IP on Ubuntu 20.04-Linux Hint from Terminal

Get public IP handle utilizing ip

The ip command is chargeable for managing community gadgets, interfaces, and tunnels. It may possibly additionally report details about the related networks.

Run the next ip command to checklist the community interfaces and the IP handle.

Get Public IP on Ubuntu 20.04-Linux Hint from Terminal

The next command is the equal one. It’ll give the identical outcome.

Get Public IP on Ubuntu 20.04-Linux Hint from Terminal

Ultimate ideas

As we’ve demonstrated, there are tons of how to verify the general public IP handle of your gadget. Which one it is best to use? Will depend on you. Attempt all of them out at the least as soon as. Then, you’ll be able to simply determine which one to grasp.

Pleased computing!

ubuntu 20.04 network-manager,kubuntu 20.04 static ip,ubuntu 20.04 dhcp client,netplan/cloudinit,configure static ip ubuntu server,ubuntu 20 change hostname,ubuntu what is my public ip,ubuntu server 20.04 check ip address,ubuntu 20 change theme,upgrade ubuntu to ubuntu studio,ubuntu 20.04 desktop icons,ubuntu 20.04 show ip address command line,ubuntu 20.04 get ip address,configure static ip ubuntu 20.04 command line,ubuntu 20.04 static address,ubuntu ip address,ubuntu 19.10 static ip,ubuntu change ip address command line,ubuntu 20.04 eth0,change ip address ubuntu

More Stories
Is Dedicated Hosting The Right Hosting Solution For Your Website? > Blog by eWebGuru