DEV Community

Cover image for What Is an IP Address? Explained Simply
Lavkush Kumar
Lavkush Kumar

Posted on Originally published at codingcush.com

What Is an IP Address? Explained Simply

Originally published on CodingCush.

An IP address is a number that identifies a device on a network, like a house number identifies a house on a street. Every phone, laptop and website server has one, and without it, data would have no idea where to go. In this guide you will learn what the four numbers mean, how public and private addresses differ, what IPv4 and IPv6 are, and how to find your own IP address, with a small Python demo you can run yourself.

Your Device Has an Address, Just Like Your Home

When you order food online, the delivery rider needs your home address. The internet works the same way: every message, video and web page travels to a numbered address, and that number is the IP address. IP stands for Internet Protocol, the set of rules that moves data between devices.

A typical address looks like this: 192.168.1.10. Four numbers, separated by dots, each between 0 and 255. That is IPv4, the older version, and it gives about 4.3 billion possible addresses. That sounded like plenty in the 1980s, when the internet was a research project. Today, with phones, TVs, fridges and doorbells all online, we are running out, which is why a newer version exists. The MDN glossary entry for IP address defines it in one short paragraph if you want the textbook version.

Public vs Private: Two Kinds of Address

Not every IP address is visible to the whole internet. Your home has one public address, given by your internet provider, and every device inside your home has a private address, given by your router. The router is the doorman: it takes messages from the internet and passes them to the right device inside.

Private addresses always fall in three ranges, and you can spot them at a glance:

Range Where you see it
10.0.0.0 to 10.255.255.255 Large company networks
172.16.0.0 to 172.31.255.255 Medium networks, some routers
192.168.0.0 to 192.168.255.255 Almost every home router

Your phone at home is probably 192.168.1.5 or something close. Your public address is different, and it is the one websites see. If your home Wi-Fi feels slow, the first check is often the router itself, and our guide to why Wi-Fi gets slow and how to fix it walks through that step by step.

IPv4 vs IPv6: Why a New Version Exists

IPv4 uses 32 bits, which is why it tops out near 4.3 billion addresses. IPv6 uses 128 bits, which allows about 340 undecillion addresses, more than enough for every grain of sand on Earth to have its own. An IPv6 address looks very different: 2001:0db8:85a3:0000:0000:8a2e:0370:7334, eight groups of hex digits separated by colons.

Most of the internet still runs on IPv4, and the two versions run side by side. Your device usually has both: an IPv4 address for the old world and an IPv6 address for the new one. You do not need to memorise either, but knowing the difference helps when a settings page asks you to choose. The numbering itself is coordinated by IANA, the Internet Assigned Numbers Authority, whose numbers page lists the registries that hand out address blocks around the world.

Screenshot of the IP Address glossary page on MDN Web Docs, defining an IP address as a number used to address each device on an IP network

The IP Address glossary page on MDN Web Docs, defining an IP address as a number used to address each device on an IP network.

How a Website Gets Found: DNS Does the Translating

Nobody types 142.250.80.14 into a browser. You type google.com, and a system called DNS turns that name into the right IP address in milliseconds. It is the internet phone book: names in, numbers out.

The chain goes like this. You type a name, your device asks a DNS server, the server answers with the IP address, and your browser connects to that address. When a site will not load at all, DNS is often the first suspect, and our guide to fixing DNS problems and server not found errors shows how to test it. A web server sits at the other end of that address, and our guide to what a web server is and how Apache and Nginx serve websites explains what answers when your browser arrives.

Find Your Own IP Address with Python

You can see all of this working with a few lines of Python. This demo resolves a website name to its IP address, then checks whether two addresses are private:

import socket

print("codingcush.com resolves to:", socket.gethostbyname("codingcush.com"))

def is_private(ip):
    parts = [int(p) for p in ip.split(".")]
    return (parts[0] == 10
            or (parts[0] == 172 and 16 <= parts[1] <= 31)
            or (parts[0] == 192 and parts[1] == 168))

print("192.168.1.10 is private:", is_private("192.168.1.10"))
print("8.8.8.8 is private:", is_private("8.8.8.8"))
Enter fullscreen mode Exit fullscreen mode

Output, run on Python 3.12.3 (the exact address for a site can change, because big sites use many servers):

codingcush.com resolves to: 198.18.42.233
192.168.1.10 is private: True
8.8.8.8 is private: False
Enter fullscreen mode Exit fullscreen mode

The function splits the address on the dots and checks the three private ranges from the table above. 192.168.1.10 is a home network address, so it returns True. 8.8.8.8 is Google's public DNS server, so it returns False. To see your own device address without code, open a terminal and run ipconfig on Windows or ifconfig on macOS and Linux, and look for the IPv4 line.

What an IP Address Can and Cannot Tell Someone

An IP address shows roughly where you are, usually your city, and which provider you use. It does not show your name, your exact street address or your browsing history. That is why websites show local weather without knowing who you are.

Two things are worth knowing. First, most home connections get a new public address every so often, so the number is not a permanent name tag. Second, a VPN hides your real address behind the VPN server address, which is why your location seems to change when one is on. Neither is magic, and neither makes you invisible: the provider and the VPN company can still see the traffic.

Common Mistakes and Troubleshooting

Confusing your public and private address. The 192.168 address on your phone is only valid inside your home. Giving it to a friend will not let them reach your device from outside.

Seeing 169.254.x.x and thinking the internet is down. That range means your device asked for an address and got no answer, usually because the router or cable is the problem. Restart the router first.

Typing an IP address with a typo. One wrong digit sends you to a different device or nowhere at all. Copy and paste addresses instead of typing them.

Assuming IPv6 is broken because it looks strange. Colons and letters are normal in IPv6. If a site works on IPv4 but not IPv6, the problem is usually the network settings, not the address format.

Sharing your public IP in a screenshot. It is not a password, but it is still personal. Crop it out of screenshots you post publicly.

Frequently Asked Questions

Can two devices have the same IP address?

Not on the same network. Two phones on your home Wi-Fi always get different private addresses. On different networks, though, two homes can both use 192.168.1.5, because private addresses are only unique inside their own network.

Does my IP address change?

Usually yes. Most home connections use dynamic addresses, so your public IP changes when the router restarts or the provider rotates it. Business connections often pay for a fixed, static address.

What is the difference between an IP address and a domain name?

A domain name like codingcush.com is the human friendly name. The IP address is the number the network actually uses. DNS translates the name into the number every time you visit.

Is my IP address private information?

Partly. It reveals your rough location and provider, but not your identity. Treat it like a phone number: fine to share with services you trust, not something to post publicly.

Why do I have both IPv4 and IPv6 addresses?

Because the internet is mid move from one version to the other. Your device keeps both so it can talk to old IPv4 only sites and new IPv6 sites alike.

Conclusion

An IP address is simply a device's number on a network: four numbers for IPv4, eight hex groups for IPv6, private inside your home and public outside it. DNS turns names into those numbers so you never have to memorise them. Next time a site will not load, check the address first, because half of all network mysteries start there.

Top comments (0)