Understanding IP Addresses and How They Work

As we get into a deeper understanding of IPs this won’t even get through the crust of the issue of IPs. They are deeper than what can be explained in a simple blog, and I can’t even begin to understand some of them. Unfortunately, I don’t know it all and that’s okay there are experts out that to help ALL of us.

As we talked about Why Networking is Important, we briefly discussed what IPs are. They are the addresses that make the internet go around. Each device is assigned a unique IP within their collective Network. MAC Addresses bind to IPs and all of the magic takes place within a network. Frames and packets can flow as designed.

What are IP Addresses

There are two types of IP Addresses these days, IPv4 and IPv6. IPv6 came into play because there were thoughts 20+ years ago that we were going to run out of IPv4 addresses, which at this point I THINK most IPv4 public addresses are exhausted. We have been steadily running out since we started using them, however, starting in 2010ish we actually started seeing the exhaustions take place. There looks to be some remaining IPv4 public IPs from AFRINIC.

But that is why we needed to have IPv6 addresses. We just don’t have enough public IPv4 addresses for each company that needs a public IP. I am surprised that in my home network I wasn’t issued an IPv6 address. I do remember at one point seeing an IPv6 but I don’t remember which ISP that was with. Right now, I only have an IPv4 public IP, which is nice.

IPv4

This is the most common IP address when talking to other professionals when they speak of IP, 9 out of 10 times they would be speaking about IPv4. It’s just the common thing we use.

IPv4 IPs are 32-bit long IPs are usually broken into 4 groups of 8-bit binary numbers. The 4 groups are separated with a period and it is called dot notation. We can have a whole chat on binary and what that means how that works. But, for now, if you don’t know binary it’s fine. But, you will WANT to have an idea of what binary is and how it works at that level.

A Binary IP Address:

11000000101010000000000100000001

Broken into 4 groups with dot notation:

11000000.10101000.00000001.00000001

Human readable IP address:

192.168.1.1

IPv6

IPv6 IPs are 128 bit long broken into 8 groups of 16-bit hexadecimal numbers. The 8 groups are separated by colons and called a “quartet” or “hextet.” IPv6 is NOT my specialty, I learned it enough to pass a few exams, but I don’t know it well enough to sit here and tell you exactly how it all works. I know enough to give a brief explanation of what it is.

IPv6 in quartet form:

2001:0C18:E004:0000:0000:0000:0000:0C21

Unlike IPv4 this is the human readable format. That’s why IPv6 kind of just sucks for us because it’s hard to remember this long IPv6 address. I can remember a 10.16.5.1 network over whatever I just created above.

IP Subnetting

The concept of subnetting is breaking down the IP network into smaller parts. The crucial concept of subnetting comes from the subnet mask, in IPv4 there are /8, /16, and /24 which are the naming conventions that identify which period the IP is broken out from. CIDR breaks those down to even smaller numbers than just a /24 for example a /26.

If you remember our talk about 32-bit IPs that is how subnets are broken up. We start with all 32 bits as 1s

11111111.11111111.11111111.11111111 = /32 or 32 ones or a 255.255.255.255 subnet mask

11111111.11111111.11111111.00000000 = /24 or 24 ones or 255.255.255.0 subnet mask

11111111.11111111.11111111.10000000 = /25 or 25 ones or 255.255.255.128 subnet mask

Everything after the 1s is the amount of usable IPs – 2 that are available. Think in turns of how many 1s and 0s are there

I think subnetting deserves its own blog and deep dive into more of the specifics and examples.

Network IDs

Network IDs or Network Address is the IP address that identifies the local network, your local machine uses the Network ID and the Subnet Mask to determine if the destination IP address is in its local network or is in an external address. The network ID is the portion of the IP that is not designated for host IPs. For example, 192.168.1 could be the Network ID for a /24 subnet mask. The last octet would be for identifying the host IP address.

The machine does some Binary Math calling ANDing where it takes the Network ID in binary and the subnet mask in binary to determine if it is local. If it is local it will match the ANDing of the host IP and the destination IP. Long story short on ANDing, both bits have to be 1 for the solution to be 1. If they are both zero or if one bit is 1 the solution is 0.

ANDing example:

  1011

+ 1010

———-

1010

Examples:

Host IP: 192.168.1.25 -To Binary> 11000000.10101000.00000001.00001101

Host Subnet: 255.255.255.0 -To Binary> 11111111.11111111.11111111.00000000

Host Network ID: 192.168.1.0 -To Binary> 11000000.10101000.00000001.00000000 ß WE WANT TO MAKE THIS MATCH WITH OUR DESTINATIONS

Local Destination:

Destination IP: 192.168.1.32 -To Binary> 11000000.10101000.00000001.00010000

Host Subnet: 255.255.255.0 -To Binary> 11111111.11111111.11111111.00000000 – Anding Destination IP and Host Subnet

Destination Network ID: Binary Math à 11000000.10101000.00000001.00000000 ß IT MATCHES IT MUST BE LOCAL!

External Destination:

Destination IP: 201.25.36.25 -To Binary> 11001001.00011001.00100100 .00011001

Host Subnet: 255.255.255.0 -To Binary> 11111111.11111111.11111111.00000000 – Anding Destination IP and Host Subnet

Destination Network ID: Binary Math à 11001001.00011001.00100100.00000000 ß IT DOESN’T MATCH IT MUST BE EXTERNAL

How IPs get assigned

So how do our machines get IPs? Since we have to have an IP address for the MAC Address binding, we have to get those IPs assigned. There are two ways that IP addresses get assigned to devices, either we do it manually or we have a protocol to help us assign that IP address.

Static IPs

When we need to manually IP devices we have to have 3 pieces of information, Host IP address, Gateway IP address, and subnet mask. Within all systems, you will need to configure your host interface with this information for the computer to talk with the rest of the network.

Dynamic IPs

When you have 100s of systems that need IP addresses that would be way too many systems to configure by hand. Luckily, there is a protocol called DHCP (Dynamic Host Configuration Protocol) which allows the system to communicate with one device, a DHCP server with a list of IPs, to be assigned an IP from that device. This makes it easy for all devices within a network to retrieve an IP easily and without any overlap of IPs, remember each IP HAS to be unique. This protocol works in 4 steps: Discover, Offer, Request, Acknowledgement or DORA which ends with an IP lease. The IP is leased from this DHCP server for a specified time period before the host device needs to renew that lease, like an apartment.

  • Discover – The host device sends out a “Are there any DHCP servers out there? I would like an IP!”
  • Offer – The DHCP Server receives that message and sends a  “I have this IP, gateway, and subnet for you”
  • Request – Once the host device receives this offer it needs to formally request that this IP address be taken
  • Acknowledgement – The DHCP server sends an acknowledgement that it has assigned that IP to that device

Conclusion

IP Addresses are needed to make the world go round and many factors go into how IP addresses are created and assigned. It is important to know these as a network or network security engineer. As professionals of the network, we need to make sure that our network not only talks with each other but also with the other devices out in the world.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *