Students and new users who are starting out with Ubuntu Linux may find it difficult to get IP address info when using the system. If you’re a student or new user and need to understand how your computer is connected to the network, getting the system’s IP address information can be crucial.
This brief tutorial shows students and new users how to determine or find their Ubuntu system’s IP address information easily.
When it comes to IP addressing, there’s are two basic types. Private and Public addresses.
Private IP addresses are reserved for internal use only and are not route-able across the Internet. This means, if your computer is assigned a private IP address, no one will be able to connect to it from across the Internet directly.
Public IP address are those that are unique and are assigned to each device that are connected to the internet. They are publicly route-able.
There are also two types of 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 basic, continue below to learn how to find out or determine your IP addresses on Ubuntu
Option 1: Use the ip addr | hostname -I Commands
There are multiple ways one can determine their IP addresses on Ubuntu system. A common command to find out your system IP is to use 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 out the system IP address. to use it, run the commands below
The commands above displays 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.
Options 2: Use the dig | curl Commands
If you want to know your public IP address, then you can simple 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 allows 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 of the 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 you private and public IP addresses on Ubuntu systems.
You may also like the post below: