Migrate to RunxBuild and earn up to $50 in hosting credit on your first deposit.

Calculate your savings
unxBuild

How to Check Your IP Address in Ubuntu (And Which One You Actually Want)

Sean

Platform Writer

Jul 14, 2026
6 min read

ip addr show is the command, and ifconfig is the one you remember from a decade ago - it is deprecated and not even installed on a modern Ubuntu. But the more useful thing to know is that the question has two different answers. Your server’s private IP is what ip addr reports and what other machines on your network use to reach it. Your public IP is what the rest of the internet sees, and on any cloud VM behind NAT, the machine itself has no idea what it is. Asking the wrong one is why people end up confused for an hour.

How to Check Your IP Address in Ubuntu (And Which One You Actually Want)

Table of contents

The command

ip addr show

Or the short forms, which do the same thing: ip a and ip addr.

The output:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536
    inet 127.0.0.1/8 scope host lo
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500
    inet 10.116.0.3/20 brd 10.116.15.255 scope global eth0
    inet6 fe80::a4d2:1cff:fe4a:2b31/64 scope link

Read it:

  • lo is the loopback interface. 127.0.0.1 is always your own machine. It is never the answer to “what is my IP”.
  • eth0 (or ens3, enp0s3 - the name depends on the hardware) is the real network interface.
  • inet 10.116.0.3/20 is your IPv4 address. The /20 is the subnet mask in CIDR notation.

So the answer here is 10.116.0.3.

To skip the noise and get just the addresses:

hostname -I

10.116.0.3 172.17.0.1

That is a capital I. Note it can return several addresses - the second one there is Docker’s bridge interface, which is a common source of confusion on any box running containers.

Private versus public, and why it matters

The address ip addr gives you is almost certainly a private address. You can tell by the range:

  • 10.x.x.x
  • 172.16.x.x to 172.31.x.x
  • 192.168.x.x

These are reserved for private networks and are not routable on the internet. Your cloud VM has one, your laptop has one, and your Docker containers have one.

On a cloud provider, your VM sits behind NAT. It has a private address that it knows about, and a public address that the provider maps to it - and the operating system genuinely cannot see the public one. It is not hiding it; it does not have it. There is no interface configured with it.

So to find your public IP, you have to ask something outside:

curl ifconfig.me
curl -4 icanhazip.com
curl -s https://api.ipify.org

Use -4 if you want to force IPv4 - on a dual-stack machine these services will often hand you back your IPv6 address, which is correct and probably not what you wanted.

This is the crux of the confusion. Someone runs ip addr, gets 10.116.0.3, puts it into a DNS record or hands it to a colleague, and nothing works - because that address is meaningless outside the private network. The public IP is in your cloud console, or from curl ifconfig.me, and nowhere on the machine itself.

ifconfig is gone, and that is fine

ifconfig

Command 'ifconfig' not found, but can be installed with:
apt install net-tools

ifconfig is part of net-tools, which has been deprecated for years and is not installed by default on modern Ubuntu. The iproute2 suite replaced it, and the mapping is simple:

ifconfig              ->  ip addr
ifconfig eth0 up      ->  ip link set eth0 up
route -n              ->  ip route
netstat -tulpn        ->  ss -tulpn
arp -a                ->  ip neigh

Do not apt install net-tools out of nostalgia. The ip commands are faster, better maintained, and report things ifconfig cannot - it does not, for instance, show all IPv6 addresses correctly, and it has no idea about network namespaces, which means it lies to you on any box running containers.

The one to genuinely commit to memory is ss -tulpn, the replacement for netstat. It answers “what is listening on which port”, which comes up far more often in practice than “what is my IP”.

The rest of the network picture

The IP is rarely the whole question. The other three commands that complete it:

The default gateway - where traffic leaves for the outside world:

ip route

default via 10.116.0.1 dev eth0 proto static
10.116.0.0/20 dev eth0 proto kernel scope link src 10.116.0.3

The default via line is the gateway. If that line is missing entirely, the machine has no route to the internet - which is a complete explanation for a box that can ping its neighbours and nothing else.

DNS servers - on modern Ubuntu, this is systemd-resolved, so do not just read /etc/resolv.conf (it usually points at a stub at 127.0.0.53 and tells you nothing):

resolvectl status

Listening ports:

ss -tulpn

Together with ip addr, those four commands describe the machine’s entire network position: what its address is, how it gets out, how it resolves names, and what it is offering to the world.

Making the address stick

A note on the thing people usually want next.

On most cloud VMs the IP arrives via DHCP and never changes for the life of the instance, so this is a non-problem. On a home server or a VM you manage yourself, DHCP means the address can move after a reboot, which is a genuine nuisance when it is the box you SSH into.

Modern Ubuntu configures the network with Netplan, in /etc/netplan/*.yaml. It is worth knowing where that lives, and worth knowing three things about editing it:

  • Run sudo netplan try rather than netplan apply. It applies the config and automatically rolls back after 120 seconds unless you confirm. On a remote machine, this is the difference between a mistake and a lockout.
  • Getting the config wrong on a remote box means losing the box. There is no undo over a connection you have just severed.
  • On a cloud provider, do not fight the platform: use the provider’s reserved or static IP feature rather than pinning the address inside the guest. The cloud’s DHCP is the source of truth, and a statically-configured guest that disagrees with it will break in confusing ways after a rebuild.

For the common case - a cloud VM you SSH into - the right answer is a reserved IP from the provider, not a Netplan edit.

How this fits the rest of the stack

Whatever you decide here, the cost of the decision only shows up as a bill. The RunxBuild hosting calculator is the right place to model that before committing: the compute, the database, the storage, the bandwidth, the worker - each one is a separate line item, and the real cost of a platform is the sum, not the headline number. The RunxBuild dashboard is where the team sees the actual usage once it is running.

Useful related references:

FAQ

How do I check my IP address in Ubuntu?

Run ip addr show, or hostname -I for just the addresses. ifconfig is deprecated and not installed by default on modern Ubuntu - the iproute2 suite replaced it, and ip addr is the direct equivalent.

Why does my Ubuntu server show a 10.x.x.x address instead of my public IP?

Because that is its private address, and on a cloud VM behind NAT the operating system genuinely cannot see the public one - there is no interface configured with it. Find the public IP with curl ifconfig.me, or look in your cloud provider’s console.

What is the difference between hostname -I and ip addr?

hostname -I prints just the IP addresses with no other output, which is convenient for scripts. ip addr shows the full picture - every interface, the subnet mask, IPv6 addresses, and interface state. Note hostname -I can return several addresses if Docker or other virtual interfaces are present.

Why is ifconfig not found on Ubuntu?

It is part of net-tools, which has been deprecated for years and is no longer installed by default. Use ip addr instead. Do not install net-tools out of habit - ifconfig does not report network namespaces correctly, so it actively misleads you on any machine running containers.

How do I find my public IP from the command line?

curl ifconfig.me, or curl -4 icanhazip.com to force IPv4. The machine cannot tell you this itself when it is behind NAT, so you have to ask an external service that can see the address your traffic arrives from.

#ubuntu#linux#networking#ip-address#dev-infra