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

Calculate your savings
unxBuild

Check IP Address on Ubuntu: The 6 Commands That Always Work

Sean

Platform Writer

Jun 29, 2026
4 min read

Six commands that always work to find the IP address on Ubuntu: ip, hostname, ifconfig, nmcli, ip route, and curl. The right one depends on whether you want the local IP, the public IP, the network interface, or the routing table.

Check IP Address on Ubuntu: The 6 Commands That Always Work

Table of contents

The local IP

The local IP is the IP address of the network interface. The command:

ip addr show

The output shows the network interfaces, the IP addresses, the MAC addresses, and the MTU. The right IP for the team is the one on the eth0 or ens5 interface, not the lo (loopback) interface.

The public IP

The public IP is the IP address that the rest of the internet sees. The command:

curl ifconfig.me

or

curl icanhazip.com

The output is the public IP. The team that has a NAT or a proxy in front of the server will see a different IP than the local IP.

The network interfaces

The network interfaces. The command:

ip link show

The output shows the network interfaces, the state (up or down), the MTU, and the MAC address. The right one for the team is the one that is state UP and has a name like eth0 or ens5.

The routing table

The routing table. The command:

ip route show

The output shows the routing table: the default gateway, the local subnet, the default route. The team that needs to know where the traffic is going looks at the default route.

The DNS-resolved IP

The DNS-resolved IP. The command:

nslookup example.com

or

dig +short example.com

The output is the IP address that the DNS resolver returns for the domain. The team that needs to verify the DNS is resolving correctly uses this.

The hostname

The hostname. The command:

hostname

or

hostname -I

The output is the hostname or the IP address(es) of the host. The team that needs the hostname uses hostname. The team that needs the IP addresses uses hostname -I.

FAQ

How do I check my IP address on Ubuntu?

Six commands: ip addr show for the local IP, curl ifconfig.me for the public IP, ip link show for the network interfaces, ip route show for the routing table, nslookup or dig for the DNS-resolved IP, hostname for the hostname.

What is the difference between the local IP and the public IP?

The local IP is the IP address of the network interface on the host. The public IP is the IP address that the rest of the internet sees. The team behind a NAT or a proxy will see different IPs.

What is the network interface name on Ubuntu?

Usually eth0 on older kernels, ens5 on newer kernels. The team that has a custom network configuration may have a different name. Use ip link show to find the actual name.

What is the default gateway?

The router that the host uses to send traffic to other networks. The team that has multiple network interfaces may have multiple default gateways. Use ip route show to find the default gateway.

What is the difference between ip and ifconfig?

ip is the modern command (part of the iproute2 package). ifconfig is the legacy command (part of the net-tools package). The team that is on a modern Ubuntu should use ip.

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

curl ifconfig.me, curl icanhazip.com, or curl api.ipify.org. The team that has a corporate proxy in the way may need to use a different service or a different approach.

If you are sizing a server tier for a new project, the RunxBuild hosting calculator is the place to model the line items. The instances, the IPs, the network, the bandwidth - each one is a separate number, and the team’s mental model for the platform is the sum of those numbers. The RunxBuild dashboard is where the team sees the actual server fleet in one place.

#ip address#ubuntu#linux#networking