What’s an IP Address?
First, you can find your Internet Protocol (IP) address Here, so if you have no idea what an IP is,
knowing what yours looks like is a good start. It is also recommended you be familiar with binary to understand some of the concepts in this article. You can familiarize yourself with binary here.
An IP address is a number assigned to network interfaces that are using the “Internet Protocol” (IP) for communication. The original concept which is still widely in use today is IPv4, which is a 32 bit number. The newer concept developed to accommodate a much greater number of addresses is IPv6, which is a 128 bit number. To keep things simple this article will mostly focus on IPv4, as this is most likely what you will encounter in your every day life.
Basics of IPv4
IPv4, being a 32 bit number, has 4,294,967,296 possible addresses, or 2^32. This may look like a lot, and it’s working out just fine. However, with more and more devices worldwide being hooked up to the internet, and the fact that large ranges of addresses are reserved for special uses, the address pool will not last forever. The main reason we have not run out of addresses yet is thanks to private networks (NAT) and subnetting, which will be discussed in other articles.
Basics of IPv6
IPv6 comes in to save the day. With its massive 128 bit size, IPv6 can support approximately 340,282,366,920,938,000,000,000,000,000,000,000,000 unique addresses. That’s enough IP addresses for every object and living thing on the planet to have an IP, and you’d still have a hell of a lot of leftovers. With this many addresses, we won’t need to be so
strict about IP allocations and NAT. An ISP could easily give you a few thousand IPs when you buy their services. NAT will still be useful for managing traffic and security however.
The Structure of an IP address
When you see an IP address such as 192.168.100.8 for example, you’re really just seeing a human-friendly (decimal) representation of a 32 bit long binary string.
192 . 168 . 100 . 8 1100 0000.1010 1000.0110 0100.0000 1000
An IP address is made up of 4 octets (groups of 8 bits). Each octet can be 0 to 255 in decimal, or 0000 0000 to 1111 1111 in binary. That’s all there is to it. Nothing magical about an IP address on its own like that. However to understand how an IP functions in the rest of it’s network, or the internet for that matter, we need to learn about network masks.
It is also possible to write out IP addresses in other formats, such as hexadecimal, or long decimal numbers. Let’s take one of google.com’s IP addresses as an example. Typing any of these with the http:// prefix in a web browser should take you to google.com’s home page, unless at the time you are reading this the IP has changed, or your web browser is crap.
google.com doted decimal: 18.104.22.168 doted hex: 0x42.0xF9.0x5A.0x68 hex: 0x42F95A68 decimal: 1123637864 (the full 32 bit string in decimal) mixed: 66.0xF9.90.0x68
Also called “subnet masks”, “net masks” or just “masks”, these identify which network an IP address belongs to. This subject touches on subnetting a little bit, which is unavoidable. There is an article dedicated entirely to subnetting which you should look at after reading this one if you would like more information. Every network has an ID, which is the first possible IP in that range. Let’s use a typical home network setup as an example.
Host IP: 192.168.1.37 Subnet Mask: 255.255.255.0
We already know that IP addresses are actually seen in binary by the computer. So is the subnet mask. The way your computer finds out the ID of the network it is on is by multiplying the IP by the mask. The result is the network ID.
IP: 1100 0000.1010 1000.0000 0001.0010 0101 Mask: 1111 1111.1111 1111.1111 1111.0000 0000 AND: 1100 0000.1010 1000.0000 0001.0000 0000 Net ID: 192 . 168 . 1 . 0
AND is just a fancy computer science way of saying multiplication. 1×0 = 0, 1×1 = 1, 0x0 = 0.
If we convert the result back into decimal, you notice everything that was matched up to a 255 stayed the same, while anything matched up to a 0 became a 0. So that is our network’s ID. Of course the network ID is not a valid IP for the host to use, valid IPs start one higher than the net ID. In this case, 192.168.1.1 would be the first valid IP, and that is usually the one assigned to an out-of-the-box router you buy in a store for your home network.
The role of the network ID is primarily to manage traffic on the network. A router knows where to send data based on this ID. For example a router with one interface on the 192.168.1.0 network, and an interface on the 192.168.2.0, will know which interface the data has to go out by to reach the destination.
For example, Host A wants to send data to Host C, the router knows host A is on the 192.168.1.0 network, and that host B is on the 192.168.2.0 network. It will send the packets of data to the proper place based on this pair of IP + Mask.
This is just the very basic of network masks, subnets and network IDs. My article on subnetting goes into much greater detail.
Reserved Groups of IP Addresses
There are many IP addresses reserved for special purposes. Some of these are never to be used on the global internet, some are for special purposes only and can not be configured to an interface at all. Others still are either unallocated, reserved for future use, or reserved for testing purposes.
10.0.0.0 - 10.255.255.255 172.16.0.0 - 172.31.255.255 192.168.0.0 - 192.168.255.255
Private networks are used at home, offices, corporations, schools, or anywhere that has a local network using the IP protocol. These networks can then be connected to the internet, via a single IP addresses allocated to them by their ISP, without having to worry about the IP addresses of each device on the network.
0.0.0.0 - invalid / can mean various things (default route for example, on a router) 127.0.0.0 - 127.255.255.255 - Loopback 169.254.0.0 - 169.254.255.255 - Link Local (as seen when DHCP doesn't work)
Several other blocks of addresses have been reserved for future uses or experimental stuff, and others are simply not allocated yet. Full details of IP address allocation can be found by reading RFC 3330. The ones listed above are those likely to be encountered by the average user.
Where do IPs Come From
Knowing the structure of an IP and how they work is great and all, but where exactly do they come from? The IP addresses themselves do not come from anywhere. Computers and other devices that support the Internet Protocol just know how to use them because of software developed and included in their operating systems/firmware, and people assign the IPs to those devices. However, you can’t just assign any IP to any device and let it loose on the internet. Doing so would be chaotic. There would be IP conflicts everywhere (try setting 2 machines on your home network to the same IP).
This is why there is a global agreement on how to assign IP addresses. This is managed by the IANA (Internet Assigned Numbers Authority). The IANA is operated by ICANN (Internet Corporation for Assigned Names and Numbers). The IANA cooperates with the five Regional Internet Registries, who in turn assign IP addresses to all of their Local Internet Registries, such as internet service providers. The service providers then assign addresses or groups of addresses to customers as needed. Each regional internet registry takes care of one section of the world, which is why you can track someone’s approximate location based on IP address.
This article was redone on: March 6, 2010, for reason: Simplified and improved.