Every device connected to a network—computer, tablet, camera, whatever—needs a unique identifier so that other devices know how to reach it. In the world of TCP/IP networking, that identifier is the Internet Protocol (IP) address.
If you’ve worked with computers for any amount of time, you’ve likely been exposed to IP addresses—those numerical sequences that look something like 192.168.0.15. Most of the time, we don’t have to deal with them directly, since our devices and networks take care of that stuff behind the scenes. When we do have to deal with them, we often just follow instructions about what numbers to put where. But, if you’ve ever wanted to dive a little deeper into what those numbers mean, this article is for you.
Why should you care? Well, understanding how IP addresses work is vital if you ever want to troubleshoot why your network isn’t working right, or why a particular device isn’t connecting the way you’d expect it to. And, if you ever need to set up something a little more advanced—like hosting a game server or media server to which friends from the internet can connect—you’ll need to know something about IP addressing. Plus, it’s kind of fascinating.
Note: We’re going to be covering the basics of IP addressing in this article, the kind of stuff that people who use IP addresses, but never really thought much about them, might want to know. We’re not going to be covering some of the more advanced, or professional, level stuff, like IP classes, classless routing, and custom subnetting…but we will point to some sources for further reading as we go along.
RELATED: What is an IP Address
An IP address uniquely identifies a device on a network. You’ve seen these addresses before; they look something like 192.168.1.34.
An IP address is always a set of four numbers like that. Each number can range from 0 to 255. So, the full IP addressing range goes from 0.0.0.0 to 255.255.255.255.
The reason each number can only reach up to 255 is that each of the numbers is really an eight digit binary number (sometimes called an octet). In an octet, the number zero would be 00000000, while the number 255 would be 11111111, the maximum number the octet can reach. That IP address we mentioned before (192.168.1.34) in binary would look like this: 11000000.10101000.00000001.00100010.
Computers work with the binary format, but we humans find it much easier to work with the decimal format. Still, knowing that the addresses are actually binary numbers will help us understand why some things surrounding IP addresses work the way they do.
Don’t worry, though! We’re not going to be throwing a lot of binary or math at you in this article, so just bear with us a bit longer.
The Two Parts of An IP Address
A device’s IP address actually consists of two separate parts:
- Network ID: The network ID is a part of the IP address starting from the left that identifies the specific network on which the device is located. On a typical home network, where a device has the IP address 192.168.1.34, the 192.168.1 part of the address will be the network ID. It’s custom to fill in the missing final part with a zero, so we might say that the network ID of the device is 192.168.1.0.
- Host ID: The host ID is the part of the IP address not taken up by the network ID. It identifies a specific device (in the TCP/IP world, we call devices “hosts”) on that network. Continuing our example of the IP address 192.168.1.34, the host ID would be 34—the host’s unique ID on the 192.168.1.0 network.
On your home network, then, you might see several devices with IP address like 192.168.1.1, 192.168.1.2, 192.168.1 30, and 192.168.1.34. All of these are unique devices (with host IDs 1, 2, 30, and 34 in this case) on the same network (with the network ID 192.168.1.0).
To picture all this a little better, let’s turn to an analogy. It’s pretty similar to how street addresses work within a city. Take an address like 2013 Paradise Street. The street name is like the network ID, and the house number is like the host ID. Within a city, no two streets will be named the same, just like no two network IDs on the same network will be named the same. On a particular street, every house number is unique, just like all host iDs within a particular network ID are unique.
The Subnet Mask
So, how does your device determine which part of the IP address is the network ID and which part the host ID? For that, they use a second number that you’ll always see in association with an IP address. That number is called the subnet mask.
On most simple networks (like the ones in homes or small businesses), you’ll see subnet masks like 255.255.255.0, where all four numbers are either 255 or 0. The position of the changes from 255 to 0 indicate the division between the network and host ID. The 255s “mask out” the network ID from the equation.
Note: The basic subnet masks we’re describing here are known as default subnet masks. Things get more complicated than this on bigger networks. People often use custom subnet masks (where the position of the break between zeros and ones shifts within an octet) to create multiple subnets on the same network. That’s a little beyond the scope of this article, but if you’re interested, Cisco has a pretty good guide on subnetting.
The Default Gateway Address
In addition to the IP address itself and the associated subnet mask, you’ll also see a default gateway address listed along with IP addressing information. Depending on the platform you’re using, this address might be called something different. It’s sometimes called the “router,” “router address,” default route,” or just “gateway.” These are all the same thing. It’s the default IP address to which a device sends network data when that data is intended to go to a different network (one with a different network ID) than the one the device is on.
The simplest example of this is found in a typical home network.
If you have a home network with multiple devices, you likely have a router that’s connected to the internet through a modem. That router might be a separate device, or it might be part of a modem/router combo unit supplied by your internet provider. The router sits between the computers and devices on your network and the more public-facing devices on the internet, passing (or routing) traffic back and forth.
Say you fire up your browser and head to www.myip.world. Your computer sends a request to our site’s IP address. Since our servers are on the internet rather than on your home network, that traffic is sent from your PC to your router (the gateway), and your router forwards the request on to our server. The server sends the right information back to your router, which then routes the information back to the device that requested it, and you see our site pop up in your browser.
Typically, routers are configured by default to have their private IP address (their address on the local network) as the first host ID. So, for example, on a home network that uses 192.168.1.0 for a network ID, the router is usually going to be 192.168.1.1. Of course, like most things, you can configure that to be something different if you want.
There’s one final piece of information you’ll see assigned alongside a device’s IP address, subnet mask, and default gateway address: the addresses of one or two default Domain Name System (DNS) servers. We humans work much better with names than numerical addresses. Typing www. myip.world into your browser’s address bar is much easier than remembering and typing our site’s IP address.
DNS works kind of like a phone book, looking up human-readable things like website names, and converting those to IP addresses. DNS does this by storing all that information on a system of linked DNS servers across the internet. Your devices need to know the addresses of DNS servers to which to send their queries.
On a typical small or home network, the DNS server IP addresses are often the same as the default gateway address. Devices send their DNS queries to your router, which then forwards the requests on to whatever DNS servers the router is configured to use. By default, these are usually whatever DNS servers your ISP provides, but you can change those to use different DNS servers if you want. Sometimes, you might have better success using DNS servers provided by third parties, like Google or OpenDNS.
What’s the Difference Between IPv4 and IPv6?
You also may have noticed while browsing through settings a different type of IP address, called an IPv6 address. The types of IP addresses we’ve talked about so far are addresses used by IP version 4 (IPv4)—a protocol developed in the late 70s. They use the 32 binary bits we talked about (in four octets) to provide a total of 4.29 billion possible unique addresses. While that sounds like a lot, all the publicly available addresses were long ago assigned to businesses. Many of them are unused, but they are assigned and unavailable for general use.
In the mid-90s, worried about the potential shortage of IP addresses, the internet Engineering Task Force (IETF) designed IPv6. IPv6 uses a 128-bit address instead of the 32-bit address of IPv4, so the total number of unique addresses is measured in the undecillions—a number big enough that it’s unlikely to ever run out.
Unlike the dotted decimal notation used in IPv4, IPv6 addresses are expressed as eight number groups, divided by colons. Each group has four hexadecimal digits that represents 16 binary digits (so, it’s referred to as a hextet). A typical IPv6 address might look something like this:
The thing is, the shortage of IPv4 addresses that caused all the concern ended up being mitigated to a large extent by the increased use of private IP addresses behind routers. More and more people created their own private networks, using those private IP addresses that aren’t exposed publicly.
So, even though IPv6 is still a major player and that transition will still happen, it never happened as fully as predicted—at least not yet. If you’re interested in learning more, check out this history and timeline of IPv6.
How Does a Device Get Its IP Address?
Now that you know the basics of how IP addresses work, let’s talk about how devices get their IP addresses in the first place. There are really two types of IP assignments: dynamic and static.
A dynamic IP address is assigned automatically when a device connects to a network. The vast majority of networks today (including your home network) use something called Dynamic Host Configuration Protocol (DHCP) to make this happen. DHCP is built into your router. When a device connects to the network, it sends out a broadcast message requesting an IP address. DHCP intercepts this message, and then assigns an IP address to that device from a pool of available IP addresses.
There are certain private IP address ranges routers will use for this purpose. Which is used depends on who made your router, or how you have set things up yourself. Those private IP ranges include:
- 10.0.0.0 – 10.255.255.255: If you’re a Comcast/Xfinity customer, the router provided by your ISP assigns addresses in this range. Some other ISPs also use these addresses on their routers, as does Apple on their AirPort routers.
- 192.168.0.0 – 192.168.255.255: Most commercial routers are set up to assign IP addresses in this range. For example, most Linksys routers use the 192.168.1.0 network, while D-Link and Netgear both use the 18.104.22.168 range
- 172.16.0.0 – 172.16.255.255: This range is rarely used by any commercial vendors by default.
- 169.254.0.0 – 169.254.255.255: This is a special range used by a protocol named Automatic Private IP Addressing. If your computer (or other device) is set up to retrieve its IP address automatically, but cannot find a DHCP server, it assigns itself an address in this range. If you see one of these addresses, it tells you that your device could not reach the DHCP server when it came time to get an IP address, and you may have a networking issue or trouble with your router.
The thing about dynamic addresses is that they can sometimes change. DHCP servers lease IP addresses to devices, and when those leases are up, the devices must renew the lease. Sometimes, devices will get a different IP address from the pool of addresses the server can assign.
Most of the time, this is not a big deal, and everything will “just work”. Occasionally, however, you might want to give a device an IP address that does not change. For example, maybe you have a device that you need to access manually, and you find it easier to remember an IP address than a name. Or maybe you have certain apps that can only connect to network devices using their IP address.
In those cases, you can assign a static IP address to those devices. There are a couple of ways to do this. You can manually configure the device with a static IP address yourself, although this can sometimes be janky. The other, more elegant solution is to configure your router to assign static IP addresses to certain devices during what would normally be dynamic assignment by the DHCP server. That way, the IP address never changes, but you don’t interrupt the DHCP process that keeps everything working smoothly.
This article is inspired from here.