DEV Community 👩‍💻👨‍💻

Cover image for Public and Private IP Addresses: A Beginner’s Guide
techslang
techslang

Posted on • Updated on

Public and Private IP Addresses: A Beginner’s Guide

By now, you probably know what an IP address is but for those who are truly new to the subject, it is simply a set of numbers that identifies a device (computer, mobile device, or IoT device) on the Internet. In this guide, let’s talk about the different types of IP addresses, how they differ from one another, and dive into public and private IP addresses and how they work.

IP Address Types

Before we get started with public and private addresses, we need to understand the types of IP addresses. Classifying IP addresses can be done in three ways.

IPv4 or IPv6

IPv4 addresses are more widely used than IPv6 addresses today. In fact, 94% of Internet-connected devices are identified by IPv4 addresses. IPv4 uses a 32-bit address scheme to store more than 4 billion addresses. It is made up of four sets of numeric characters, ranging from 1 to 255, separated by periods. An example would be 127.255.255.255.
IPv4 address distribution worldwide using data from Wikipedia.
As more devices accessed the Web, experts began worrying about running out of available IPv4 addresses, and so entered IPv6.

An IPv6 address comprises eight sets of alphanumeric characters (with four characters per set), separated by colons, such as 2001:0db8:85a3:0000:0000:8a2e:0370:7334. And because of its 128-bit address space, users now have an additional 340 undecillion IPv6 addresses to use. You can take a closer look at the IPv6 address allocations at this Internet Assigned Numbers Authority (IANA) page or learn about their distribution across countries compared to IPv4 addresses by using a list of IP addresses by country.

Static or Dynamic

A static IP address does not change, a dynamic address does. When a device with a static IP address accesses the Internet, its identifier never changes. Most devices, though, use dynamic IP addresses that are assigned by their ISPs. These can change periodically, depending on which IP address (from the ones the ISP owns) is not in use at a given time. Static and dynamic IP addresses can fall under either the IPv4 or IPv6 address space.

Note, however, that you can’t control which of the IP address types mentioned above get assigned to your network. Users’ IP addresses are determined by availability.

Public and Private

IP addresses, whether IPv4 or IPv6 and static or dynamic, can also be categorized as either public or private. Simply put, a public IP address is one which anyone on the Internet can see while a private IP address is only accessible to users who are connected to the same network (either home or corporate). Read on to find out more about how they work in the next section.

How Public and Private IP Addresses Work

Public IP addresses are directly accessible over the Internet. Your ISP assigns them to your network routers. Each time you visit a website, this public IP address gets picked up by the site owner’s network log. Think of it as a post office box number that you wouldn’t mind giving out to almost anyone as opposed to letting them know your home address. Similarly, public IP addresses don’t tell network owners as much about your location and personal details, as their records would point to your ISP.

Private IP addresses, on the other hand, are those that your network router assigns to each of your devices. Each private address is unique so your connected devices can talk to each other (and not get confused) within the network. When router-connected devices access the Internet, their private IP addresses won’t be visible to others. What website owners will see is your public or router’s IP address.

The following diagram shows how they differ from each other:
Public and private IP addresses in a home network

Public and Private IP Address Ranges

Not all IP addresses are publicly seen on the Internet. The IP ranges reserved for private use are:

-10.0.0.0–10.255.255.255
-172.16.0.0–172.31.255.255
-192.168.0.0–192.168.255.255

All other IP addresses excluded from the ranges above are public IP addresses.

To recap, no one sees private IP addresses on the Internet. They don’t get recorded in network logs. Network owners only see your public IP address when you visit their websites, purchase something on their e-commerce platforms, or download files from their sites.

Why Knowing Public and Private IP Addresses Matters

At the end of the day, any home or corporate router is identifiable by its public IP address. If your business goal is to determine where your traffic comes from, then you need to pay attention to your site visitors’ public IP addresses. It doesn’t matter if it's an IPv4 or IPv6 address or if it’s a static or dynamic IP address. Given their public IP address and armed with a list of IP addresses by country or an IP geolocation database, you can already identify where they are based.

If you’re a network administrator for a company or complex home network, you also need to pay attention to all connected devices’ private IP addresses. Each system must have a unique private IP address. Your printer should not share the same private IP address as your Voice over Internet Protocol (VoIP) phone. If they do and you want to print a document from your laptop, your computer may not be able to correctly identify the printer from the phone and you’d fail at accomplishing that task.


In this article, you’ve learned about public and private IP addresses and their difference from other types. To reiterate, whether you use a static or dynamic IPv4 or IPv6 address, anyone with access to a list of IP addresses by country or an IP geolocation database can track the traffic coming from your network via your public IP address. And if you want to maintain the security of your home network and your privacy, you may want to ensure that only your public IP address is visible to everyone.

Top comments (0)

🌙 Dark Mode?!

 
Turn it on in Settings