SpunkArt
Command line and project setup

How to find and understand an IP address

An IP address is the number that routes traffic to a device on a network. Most devices have two that matter: a private address on the home or office network, and a public address that the rest of the internet sees. This page shows how to find both and what you can learn from an address.

IPv4 and IPv6 in one minute

An IPv4 address is 32 bits written as four numbers from 0 to 255, such as 192.0.2.44. That allows 232 = 4,294,967,296 addresses in total, which is not enough for every device, so networks share them. An IPv6 address is 128 bits written as eight groups of hexadecimal digits separated by colons, such as 2001:db8:0:0:0:0:0:7. A run of zero groups can be shortened once to ::, giving 2001:db8::7. (Both examples come from ranges reserved for documentation.)

Find your own addresses

SystemPrivate (local) address
Windowsipconfig
macOSipconfig getifaddr en0 (Wi-Fi is often en0)
Linuxip addr or hostname -I
PhoneWi-Fi settings, then the details of the connected network

Your public address belongs to your router or your provider, so local commands cannot show it. You have to ask something on the outside. One way uses DNS: dig +short myip.opendns.com @resolver1.opendns.com asks a public resolver to reply with the address it sees you coming from. Your router’s admin page usually shows it too, as the WAN or internet address. Be aware that any outside service you ask learns your address in the process.

Private and special ranges

Some ranges are reserved and never route on the public internet. Recognising them tells you at once whether an address is local.

RangeCoversMeaning
10.0.0.0/810.0.0.0 – 10.255.255.255Private network
172.16.0.0/12172.16.0.0 – 172.31.255.255Private network
192.168.0.0/16192.168.0.0 – 192.168.255.255Private network (most home routers)
100.64.0.0/10100.64.0.0 – 100.127.255.255Shared space used by providers for carrier-grade NAT
127.0.0.0/8127.0.0.1 is the usual oneLoopback: this same machine
169.254.0.0/16—Link-local: often means the device failed to get an address

Reading the slash: CIDR notation

The number after the slash is how many leading bits are fixed for the network. The rest are free for devices.

addresses in a block = 2(32 − prefix)

Worked examples.

  • /24: 28 = 256 addresses. For 192.168.1.0/24 the mask is 255.255.255.0; hosts usually use .1 to .254, because .0 names the network and .255 is broadcast.
  • /28: 24 = 16 addresses, 14 usable for hosts.
  • /16: 216 = 65,536 addresses.

Who owns an address?

  • Reverse DNS. dig -x 192.0.2.44 +short or nslookup 192.0.2.44 returns the PTR name, if one is set. Names often hint at the provider or hosting company.
  • Whois. whois 192.0.2.44 queries the regional internet registry and shows the organisation that holds the block and an abuse contact.

What an IP address does not tell you

IP location databases guess a country, and sometimes a city, from registry data and measurements. Country is often right; city is often wrong, and mobile and VPN users can appear far from where they are. An address does not reveal a name or a street address. Only the provider can link an address to a customer, and it normally does so only under a legal process.

Questions

Why does my public IP change?

Many home and mobile connections get a dynamic address that the provider reassigns from time to time, for example after the router restarts.

Why is there no lookup box here?

Finding a public address or querying whois needs a network request. This page explains the built-in commands instead, so nothing about you is sent anywhere by this site.