Finding your IP address in Ubuntu is easy and can be done through the command line or graphically. Here are the key things you need to know:

What is an IP Address?

An IP address is a unique identifier assigned to a device on a network. It allows the device to communicate with other devices on the local network or over the internet.

There are two main types of IP addresses:

  • Public IP Address – Used to communicate over the internet. Unique globally.
  • Private IP Address – Used for local network communication. Only unique on private networks.

Finding Your Public IP Address

Your public IP reveals your device‘s identity to others on the public internet. Here are a couple ways to find it on Ubuntu:

Using curl and ipinfo.io

$ curl ipinfo.io/ip
203.0.113.10

This queries the ipinfo.io API to get your public IP.

Using dig

$ dig +short myip.opendns.com @resolver1.opendns.com 
203.0.113.10

Queries an OpenDNS service to retrieve your IP address.

Finding Your Private IP Address

Your private IP address identifies your device on your local private network. Here are a few ways to find it:

Using ip command

$ ip addr show eth0 | grep "inet\b" | awk ‘{print $2}‘ | cut -d/ -f1
192.168.0.22

This breaks out just the IPv4 private IP address from the ip command output.

Using ifconfig

$ ifconfig eth0 | grep "inet addr" | cut -d: -f2 | awk ‘{print $1}‘
192.168.0.22

Similar to above, but uses ifconfig instead of ip.

Using GUI Network Settings

You can also find your private IP graphically through the Ubuntu network settings:

Settings > Network > Gear icon > IPv4 tab

The IP address will be listed there.

Conclusion

Finding your IP address in Ubuntu is handy for getting device connectivity information. Both public and private IP addresses have their uses. Now you have a few ways to access them right from the terminal or graphically.

Similar Posts

Leave a Reply

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