To check your IP addressIP address The number address of a device on the internet, like 203.0.113.10. Computers use it to find each other, the way post uses street addresses. More about IP address → in Linux, run ip addr for the addresses on the machine itself, or curl -4 icanhazip.com for the public address the internet sees. This guide is for anyone working on a Linux server or PC who needs the right IP address for an SSHSSH A secure way to type commands on a server from your own computer, as if you were sitting at it. More about SSH → login, a DNS record or a firewall rule.
Run **ip -br addr to list every network interface and its IP addresses in one short table, or hostname -I for just the addresses. These show the addresses configured on the machine. If the machine sits behind a router, its public address is different: find it with curl -4 icanhazip.com**. The ifconfig command is older and often not installed.
Which IP address do you need?
A Linux machine usually has more than one IP address, so first decide which one you are after.
| Address | What it is | Example | How to find it |
|---|---|---|---|
| Loopback | The machine talking to itself | 127.0.0.1 | Always the same, no need to check |
| Private (local) | Used inside a home, office or cloud network | 192.168.1.20, 10.0.0.5 | ip addr |
| Public | The address the rest of the internet sees | 203.0.113.10 | ip addr on most VPS servers, otherwise curl |
| IPv6 | The newer, longer address format | 2001:db8::10 | ip -6 addr |
On a typical VPSVPS A private slice of a powerful server, with its own guaranteed share of memory and processing and full control, at a fraction of the price of a whole machine. More about VPS → or dedicated server, the public address is attached directly to the server’s network card, so ip addr shows it. On a home PC, a Raspberry Pi or a laptop on office Wi-Fi, the machine only has a private address and the router translates it to a public one (a process called NAT). In that case ip addr will never show the public address, and you need to ask an outside service.
Some cloud platforms also use NAT: the server’s network card holds a private address such as 10.0.0.5, and the provider maps a public address to it. If ip addr only shows a private address on a cloud server, check the public address in the provider’s control panelControl panel A website you log into to manage your hosting with buttons and forms, instead of typing commands. cPanel and Plesk are the common ones. More about Control panel → or with the curl method below.
Check the IP address with the ip command
The ip command is part of the iproute2 package and is installed on every current distribution, including Ubuntu 22.04 and 24.04, Debian 12, AlmaLinux 9 and Rocky Linux 9. You do not need root to read addresses.
1. Get a short summary
ip -br addr
The -br option means brief: one line per interface. The output looks like this:
lo UNKNOWN 127.0.0.1/8 ::1/128
eth0 UP 203.0.113.10/24 2001:db8::10/64 fe80::5054:ff:fe12:3456/64
Each line shows the interface name, whether it is up, and its addresses. The number after the slash is the network size (the prefix length), not part of the address itself: the IP address here is 203.0.113.10.
Interface names vary. Older systems and many cloud servers use eth0; newer systems often use names such as ens3, enp0s3 or enp1s0. Wi-Fi usually starts with wl, for example wlp2s0. Ignore lo, which is the loopback interface, and docker0 or names starting with veth or br-, which belong to Docker containers and bridges.
2. See the full details
ip addr show
This is the long form (ip a is a common shortcut). Look for lines starting with inet (IPv4) and inet6 (IPv6) under each interface:
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff
inet 203.0.113.10/24 brd 203.0.113.255 scope global eth0
inet6 2001:db8::10/64 scope global
inet6 fe80::5054:ff:fe12:3456/64 scope link
The word scope global marks an address that can be used beyond this machine. scope link marks an IPv6 link-local address starting with fe80:, which only works on the local network segment and is not the one you want for DNSDNS The internet’s phone book. It turns a name people can remember, like example.com, into the number address computers use to find the server. More about DNS → or SSH.
3. Show only IPv4 or IPv6, or one interface
ip -4 addr show
ip -6 addr show
ip addr show dev eth0
Replace eth0 with your own interface name from step 1.
4. Find the address used for outgoing traffic
When a server has several addresses, this shows which one Linux actually uses to reach the internet:
ip route get 1.1.1.1
The output includes src 203.0.113.10, the source address the server will use. The command only looks up the route; it does not send anything to 1.1.1.1.
Quicker ways: hostname -I and ifconfig
For a plain list of addresses without interface names, run:
hostname -I
It prints every configured address except loopback and IPv6 link-local addresses, separated by spaces, for example 203.0.113.10 172.17.0.1 2001:db8::10. The order is not guaranteed, so do not assume the first address is the main one. Here 172.17.0.1 belongs to Docker, not to the server’s real network.
You will also see ifconfig in older guides. It comes from the net-tools package, which has been replaced by iproute2 and is often missing on fresh installs, giving ifconfig: command not found. Use ip addr instead. If you really need ifconfig, install net-tools with sudo apt install net-tools on Ubuntu and Debian, or sudo dnf install net-tools on AlmaLinux and Rocky Linux.
Check your public IP address from the terminal
To see the address the internet sees, ask an outside service to echo it back:
curl -4 icanhazip.com
curl -6 icanhazip.com
The -4 and -6 options force IPv4 or IPv6. If the IPv6 command fails or hangs, the machine has no working IPv6 connection, which is common on home networks.
If curl is not installed, use DNS instead. This asks the OpenDNS resolver to return the address your request came from:
dig +short myip.opendns.com @resolver1.opendns.com
dig is in the dnsutils package on Ubuntu and Debian (bind9-dnsutils on newer releases) and in bind-utils on AlmaLinux and Rocky Linux. The DNS lookup guide explains how to read its output.
If you are on a VPN or behind a proxy, these services report the VPN or proxy address, not your own connection.
What to do with the address
- SSH: use the public address (or a domain pointing at it) to connect to the server with SSH, for example
ssh exampleco@203.0.113.10. - DNS: put the public IPv4 address in your domain’s A recordA record The line in a domain’s settings that says which server’s address to send visitors to. Like a forwarding address card for your website. More about A record → and the global IPv6 address in its AAAA record. Never use a private address in public DNS.
- FirewallFirewall A gatekeeper that decides which connections are allowed into a server and blocks the rest. More about Firewall → rules: when you allow your own office or home address through a firewall, use the public address of that connection, found with the
curlmethod on a machine there. - Local network: to reach a Raspberry Pi or test server from another device at home, use its private address, such as 192.168.1.20.
Home and some office connections get a dynamic public address that can change. If a firewall rule or DNS record suddenly stops working, check whether the address has changed.
Common problems
| Symptom | Cause | Fix |
|---|---|---|
ifconfig: command not found | net-tools is not installed | Use ip addr, or install net-tools |
ip addr shows only 192.168.x.x or 10.x.x.x | The machine is behind NAT | Use curl -4 icanhazip.com for the public address |
curl shows a different address from ip addr | NAT, a VPN or a proxy is in the path | Use the curl result for anything on the internet |
An interface shows DOWN and no inet line | The network is not connected or not configured | Check the cable or Wi-Fi, then the network configuration |
hostname -I lists many addresses | Docker, VPN or bridge interfaces add their own | Use ip -br addr to see which address belongs to which interface |
Only an fe80: IPv6 address appears | The network has no IPv6 service | Use IPv4, or enable IPv6 with your host or ISP |
Official documentation
Related
- DNS record types explained: how A and AAAA recordsAAAA record The same as an A record, but for the newer, longer kind of internet address (IPv6). Only needed if your server has one. More about AAAA record → point a domain at the address you just found.
- What is a port number?: the next step once you have the address, finding the right program on it.
- How to check your Ubuntu or Linux version: the other thing to confirm when you first log in to a server.
Something out of date? Software changes. If a step no longer works, tell us and we will check it and update the page.


