This brief tutorial shows students and new users how to easily determine or find their Ubuntu system’s IP address information.
Getting the system’s IP address information can be crucial if you’re a student or new user and need to understand how your computer is connected to the network.
When it comes to IP addresses, there are two basic types. Private and Public addresses.
Private IP addresses are reserved for internal use and are not route-able across the Internet. This means, if your computer is assigned a private IP address, no one can connect to it directly across the Internet.
A public IP address is unique and assigned to each device connected to the Internet. They are publicly route-able.
There are also two private and public IP addresses: IPv4 and IPv6.
I am not going to go too deep into networking here. but the IP address ranges below are reserved for internal usage only.
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
There are multiple ways one can determine their IP addresses on the Ubuntu system. A common command to find your system IP is using the ip addr command.
This command only displays your private IP addresses. To use it, run the commands below
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
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
If you want to know your public IP address, you can simply go to Google.com and type in “what’s my IP” Google will tell you your public IP address.
If you can’t use a browser to determine your public IP, then use the commands below.
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 use these as well.
curl -s http://tnx.nl/ip wget -O - -q https://icanhazip.com/
That should do it!
Congratulations! You have learned how to determine Ubuntu systems’ private and public IP addresses.