How to Find your IP Address in Ubuntu Linux

The tutorial instructs students and new users on how to find their Ubuntu system’s IP address, essential for understanding how their computer is connected to the network. It explains the difference between public and private IPs, and IPv4 and IPv6 addresses, and provides commands to execute in Ubuntu to display either their private or public…

This brief tutorial shows students and new users how to quickly determine or find their Ubuntu system’s IP address information.

For several reasons, learning how to find your IP address in Ubuntu Linux is important. For instance, understanding how your computer is connected to the network could be crucial if you’re a student or new user.

Additionally, knowing your IP address can help you troubleshoot networking issues, and it can also help you configure network settings on your Ubuntu system.

Moreover, there are two basic types of IP addresses, private and public, and understanding the difference between them is crucial if you are interested in networking.

Finally, finding your IP address in Ubuntu Linux is a fundamental skill for anyone who wants to interact with other devices on the network.

There are also two private and public IP addresses: IPv4 and IPv6.

I am not going to go too deep into networking here. However, the IP address ranges below are reserved for internal usage only.

  • 10.0.0.0/8
  • 172.16.0.0/12
  • 192.168.0.0/16

Now that you know the basics, continue below to learn how to find out or determine your IP addresses on Ubuntu

Use the IP addr | hostname -I Commands

One can determine their IP addresses on the Ubuntu system in multiple ways. A typical command to find your system IP is the ip addr command.

This command only displays your private IP addresses. To use it, run the commands below

ip addr

You should see a similar screen as shown below:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:0e:8c:aa brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.6/24 brd 10.0.2.255 scope global dynamic noprefixroute enp0s3
       valid_lft 867sec preferred_lft 867sec
    inet6 fe80::dc16:b788:bafa:470a/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

The highlighted line is the system’s private IP address

You can also use the hostname -I command to find the system IP address. to use it, run the commands below

hostname -I

The commands above display a single line with your IP address

Now that you know how to find out your private IP addresses, use the options below to determine your public IP address.

Use the dig | curl Commands

To know your public IP address, go to Google.com and type “What’s my IP?” Google will tell you your public IP address.

Use the commands below if you can’t use a browser to determine your public IP.

Some DNS providers, such as OpenDNS and Google, allow you to query their servers to obtain your public IP address information. Not all DNS providers will allow that, but the ones below will provide your public IP.

You can use any dig commands below to determine your public IP address.

dig ANY +short @resolver2.opendns.com myip.opendns.com
dig ANY +short @ns1-1.akamaitech.net ANY whoami.akamai.net
dig ANY +short @resolver2.opendns.com myip.opendns.com

The commands above should display your public IP.

If you have curl or wget installed, you can also use these.

curl -s http://tnx.nl/ip
wget -O - -q https://icanhazip.com/

That should do it!

Congratulations! You have learned to determine Ubuntu systems’ private and public IP addresses.

Richard Avatar

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *


Exit mobile version