Juniper JNCIA-Junos JN0-104 – Section 1: Networking Basics Part 3
April 15, 2023

7. Introduction to IPv4

Now, let’s talk a bit about IPv4 addresses. An IPv4 address is a 32-bit logical address assigned to a network device, stress on the word logical. And that’s because we can configure any IP address on any device. Of course, that’s not completely true. There are restrictions on what IP address we can configure, but as long as you stay within the allowed range of IP addresses, you can configure any IP address on any interface, which is why we call it as a logical address. We can decide what IP address we want to configure on an interface. It is not hardcoded on the device like a MAC addresses.

An IPv4 address is written in decimal format with four octets separated by dots. An example is 192.168.1.1. Every number that you see in the address can be represented by eight binary bits. Hence we call it as an octet. So we have four octets. Each octave can be represented by eight binary bits. So we have a 32-bit address. When we say 32-bit, there are 32 binary bits in there. And we know that every binary bit can have a 0 or a 1. So that’s why the total number of possible IP addresses is 2^32.

An important thing to keep in mind is that not all IP addresses are usable (or routable) over the Internet. There are limitations or I should say there are restrictions on what IP addresses can be configured on the devices.

IP addresses are divided into five classes. The first one is called Class A. And the range for that is 0.0.0.0 to 127.255.255.255. Next, we have Class B, which starts from 128.0.0.0 to 191.255.255.255. Next, we have Class C, which starts from 192.0.0.0 to 223.255.255.255. Next, we have Class D, which starts with 224.0.0.0 to 239.255.255.255. The entire Class D range is reserved for multicast purposes. And the last one is Class E, which starts from 240.0.0.0 to 255.255.255.255. The whole of Class E is reserved for experimental purposes. So if you want to assign an IP address to a device, you would have to choose from Class A, Class B or Class C.

Now, within each of these classes, we have some IP addresses that are reserved. We’ll talk about that in the next slide. If you’re wondering why we stopped at 255.255.255.255, remember, the IP address is a 32-bit address and its binary bits. So it can only have zeros or ones.

The least possible value is when you substitute all the bits as zeros and that will give you 0.0.0.0, which is the first and the lowest address. If you substitute the bits with ones, you would get the highest possible value, which is 255.255.255.255. If that does not make sense to you right now, don’t worry. We have a lecture coming up. We will talk about decimal to binary conversion. And there we’ll understand how 255 represents all ones.

Okay, so the important thing to keep in mind is that we have five classes of IP addresses and each class has a specific range allocated to it.

Now, there are specific addresses which are called as RFC 1918 addresses. So in each class – A, B and C – a block of IP addresses has been reserved as private IP addresses. These addresses are not routable over the Internet. Hence, they are known as private IP addresses.

Now, you might be wondering what happens if I tried to route a packet over the Internet by assigning a private IP address. Well, in that case, you could configure a device with a private IP address and try to send a packet over the Internet. But your Internet service provider, or your ISP, will drop that packet. So RFC 1918 addresses are private IP addresses. They are called private because you can use it within your organization or within your private setup, but you will not be able to use these addresses to route packets over the Internet. These addresses can be used by anyone. Nobody owns these IP addresses. Unlike public IP addresses, that you purchase, private IP addresses are free for anyone to use.

RFC 1918 addresses help to conserve the IP address space by allowing organizations to use these private IP addresses for internal addressing. Now, think about this. If we did not have RFC 1918 addresses, if we did not have these private IP addresses, every device that is trying to connect on the Internet would require a public IP address. And as we’ve already seen, we only have so many addresses. We only have 0.0.0.0 to all 255s. And within that range we have two classes which are reserved – Class D and Class E. So we’re only left with Class A, B and C, which is not a lot of IP addresses compared to the number of devices that we connect today. So these private IP addresses help us solve the problem of not having enough public IP addresses. Anybody can use them.

So what are these IP addresses? Within Class A, the range 10.0.0.0 to 10.255.255.255 is reserved as a private IP address range. This can also be denoted as 10.0.0.0/8. In the upcoming lecture, we’ll talk about what a subnet mask is, and then you should be able to understand what the notation means – 10.0.0.0/8.

In Class B, the reserved range is 172.16.0.0 to 172.31.255.255. This can also be denoted as 172.16.0.0/12.

And in Class C, the result range is 192.168.0.0 to 192.168.255.255. This can be denoted as 192.168.0.0/16.

From the JNCIA examination perspective, you do not have to memorize these IP address ranges. But as a network engineer, it is important that you know these ranges. This could come up in any interview as well. So make sure, you know, these RFC 1918 ranges.

Next, we have loopback addresses. The entire 127.0.0.0/8 address block is reserved as a loopback address range. This means it cannot be assigned to a device. These addresses are called as loopback addresses and out of that entire range the most commonly used loopback address is 127.0.0.1. This address is also known as local host. It is your own IP address, meaning 127.0.0.1 represents the device itself.

When you send a packet to a loopback address, it is received by the same host. So if you go to the terminal of your device and if you try to ping 127.0.0.1, you will get a response back because you are trying to ping your own device.

So the important takeaways from this video are the classes of IP addresses, their ranges and the ranges for the RFC 1918 addresses and the loopback address range.

8. Decimal to Binary Conversion

Let’s talk about decimal to binary conversion.

So we’ll understand how to convert a decimal number to a binary number. And then we’ll also understand how to convert a binary number to a decimal number. For this lecture, I recommend that you have a pen and paper handy so you can follow along with me as I perform this on the screen.

So here’s the first example. Let’s convert 16, which is a decimal number, to binary. Now there are several methods by which you can convert decimal to binary. I’m going to show you the simplest method to do a decimal to binary conversion.

So you start by drawing a few lines. One vertical line and a few horizontal lines. At the top, you write the number that you want to convert which in this case is 16. And the number by which we’re going to divide this is two. Because the result that we’re looking for is binary. So we’re going to divide the decimal number by two so we get the binary equivalent for that. On the right side, we’ll write the remainder of the division. So let’s start dividing. Sixteen divided by two. The quotient in this case will be eight. And the remainder will be 0, which will write on the right side.

Now we need to continue the division process. So eight divided by two. The quotient is four. And the remainder is 0. Four divided by two. The quotient is two. And the remainder is 0. Two divided by two. The quotient is one. And the remainder is 0.

Now, at this point, we shouldn’t stop. We need to divide this one more time. So we need to divide one by two. The quotient will be 0 and the remainder will be one. So, any time you try to convert a decimal number to binary and when you’re dividing by two, you should continue dividing till the quotient becomes 0.

Now that the quotient is 0, we need to look at the remainders in the opposite direction from bottom to top. And that is your binary equivalent. So 16, which is the decimal number, in binary, is 1 0 0 0 0.

Let’s look at one more example. So now we’ll understand how to convert 31 to binary. We’ll start by drawing a few lines. One vertical and few horizontal. We’ll write the number at the top and the divider on the left and the remainder on the right. So let’s divide 31 by two. That quotient is 15 and the remainder is one. Fifteen divided by two. The quotient is seven, the remainder is one. Seven divided by two. The quotient is three, the remainder is one. Three divided by two. The quotient is one, the remainder is one. Now we know that we shouldn’t stop here. We need to go further until the quotient becomes zero. So, one divided by two, the quotient is 0, and the remainder is one. The answer that we’re looking for is from bottom to top. So, 31 in decimal is 1 1 1 1 1 in binary.

Let’s look at one more example before we move to binary to decimal conversion. This time we’re going to convert 52 to binary. We start by drawing a few lines. The number at the top, the divider on the left and the remainder on the right. Fifty-two divided by two. The quotient is 26, the remainder of zero. Twenty-six divided by two. The quotient 13, the remainder is zero. Thirteen divided by two. The quotient is six, the remainder is one. Six divided by two. The quotient is three, the remainder is zero. Three divided by two. The quotient is one, the remainder is one. We need to do it one more time. One divided by two. The quotient is zero, the remainder is one. The answer is from bottom to top. So 52 in decimal is 1 1 0 1 0 0 in binary.

Now, let’s do the opposite. We’ll understand how to convert binary to decimal. So, this is the binary number that we need to convert 1 0 1 0 1. The first step is to write the powers of two, starting from left to right. So, over here we’ll write the first power of two, which is 20, 21, 22, 23, 24. We’ll convert those powers into actual values, but only for those powers that correspond to a one, not for a zero. So, 24 is 16. Now 23 corresponds to a zero. So we’ll ignore that. 22 is 4. 21 corresponds to a zero. So we’ll ignore that. And 20 is 1. Now, all, that remains, is an addition operation. So, 16+0+4+0+1 equals 21. So, 1 0 1 0 1 in binary is 21 in decimal. That is simple, isn’t it?

Let’s do it one more time. This time, we’re going to kind word 1 0 0 0 0 in binary to a decimal. Step number one. Write the powers of two starting from left to right. So 20, 21, 22, 23, 24. Next, we convert those powers of two into their actual values but only for the bits that correspond to a one, the zeros should be ignored. So in this case, the only power of two that matters is 24, which is 16. And then we add all of them together, 16 plus all zeros is 16. So, 1 0 0 0 0 in binary is 16 in decimal.

Let’s look at one more example. This time we’re going to convert a bigger number 1 1 1 1 1 1 0 1 in binary to decimal. We start the exact same way. We write the powers of two starting from left to right. So we’re going all the way from 20 to 27. We then convert the powers of two into their actual values but only for those powers of two that correspond to a one. If you have a zero, you ignore that. So, this is what it looks like. We have 128, 64, 32, 16, 8, 4 and a 0, because one of the bits is a zero, and a 1. Now all, that remains, is an addition operation. So 128+64+32+16+8+4+1 is 253. So, 1 1 1 1 1 1 0 1 in binary is 253 in decimal.

Now, I have some examples for you that you can try on your own, try to convert the decimal numbers: 85, 43, and 101 to binary. And try to convert these binary values to decimal: 1 1 1 0 1, 1 0 0 1 0 0 1, 1 0 0 1 0 0 0 1.

9. Subnet Mask and its importance

Let’s talk about subnet mask. In this video, we’ll understand what is a subnet mask and what is its importance. Let’s start with the first question. What is a subnet mask?

So let’s consider an IP address 192.168.1.0/24. Every IP address has two parts. The first one is the network portion. And the second part is the host portion. Like the example that we see above 192.168.1.0/24 every IP address is accompanied by a subnet mask. And the number that you see after the slash is your subnet mask. So, in this example, the subnet mask is /24.

The subnet mask is a 32-bit number that helps you separate the network portion from the host portion.

Now, let’s step back for a minute and look at another example. Think of your home address. Your home address has a house number and a street name or a street number. We need both of them to complete the address. We need the name of the street on which your house is located. And we also need the house number or the door number. In a similar way to identify a host on a network. We need the network address. And we also need the host address. The function of the subnet mask is to separate this. The subnet mask will help you identify which portion of the IP address represents the network address and which portion represents the host address.

A subnet mask can be denoted in two ways. For example, you can write it as 10.0.0.0/8. Or we can also write it as 10.0.0.0/255.0.0.0. The number that you see after the slash, in this case /8 represents the number of ones in the binary format of the subnet mask.

So, we just understood that a subnet mask is a 32-bit number, of which the first eight bits are going to be substituted as ones. And when you add eight ones together, you get 255. So, 10.0.0.0/8 can also be represented as 10.0.0.0/255.0.0.0.

When the subnet mask is converted to binary, the ones denote the network portion, while the zeros denote the host portion. So, let’s look at the example again, 10.0.0.0/255.0.0.0. The subnet mask in decimal format is 255.0.0.0. When we convert this to binary, we have the first eight bits set to ones, and the remaining 24 bits set to zeros. Which is why you can write this as 10.0.0.0/8. That represents the number of ones in that subnet mask.

The first eight bits are made up of ones, that is your network portion. Remember, the network portion is identified by ones and the host portion is identified by zeros. Since we have eight ones in the beginning, we can also write this as 10.0.0.0/8. The number after the slash indicates the network portion.

Let’s look at one more example, 192.168.1.0/24 can also be written as 192.168.1.0/255.255.255.0. So, the subnet mask in decimal format is 255.255.255.0. When we convert this to binary, we’ll have 24 ones and then eight zeros which is why the subnet mask is written as 192.168.1.0/24. The first 24 bits are made up of ones, that is the network portion. Hence, the notation /24. The last eight bits are made up of zeros. That is the host portion.

In one of the earlier videos, we spoke about the classes of IP addresses. We had Class A, Class B and Class C. Now each of these classes has a default subnet mask.

For Class A, the default subnet mask is /8. So if you take any IP address in class A, it would have a /8 subnet mask. For example, 122.0.0.0/8. Class B has a default subnet mask of /16. An example is 172.16.0.0/16. And Class C has a default subnet mask of /24.

An example is 192.168.10.0/24. Given an IP address, how can we find out the total number of hosts that can exist on that network? There is a formula to find this out. The total number of possible host IP addresses on a network is equal to 2H where H represents the number of host bits or the number of zeros in a subnet mask.

So, for example, if we have 192.168.1.0/24 as the IP address, the first 24 bits are taken up for network bits and the last eight bits are used for host bits. The last eight bits are the zeros. So, the total number of possible hosts on that address would be 28 which is 256.

On any network, the first address is considered as the network address and the last address is considered as the broadcast address. So, for example, if we have 192.168.1.0/24, the first address of this network is 192.168.1.0. That is the address of the network, also known as the network address. And the last address is 192.168.1.255. That is the broadcast address for that network. These addresses cannot be assigned to a host. So, that means we cannot configure a host with the network address or the broadcast address.

Since the first and the last addresses are not usable, you always subtract 2 from the total. So the total number of usable IP addresses equals 2H – 2, because one address is used up for the network and one for broadcast. So the total number of possible IP addresses in a network is to 2H. But the total number of usable IP addresses is 2H – 2. From the JNCIA examination perspective, this may not be important. But as a network engineer, it is important that you know these concepts. It is important that you know these numbers.

Let’s look at an example. 192.168.1.0/24. The total number of possible host IP addresses is 28 which is 256. But you have to subtract 2, one for the network and one for broadcast. So, usable IP addresses is 28 – 2 that is 254.

Now that we’ve understood what a subnet mask is, let’s go to the important question. Why do we need subnetting to understand this? Let’s take an example. Consider the public IP address 11.0.0.0/8. Now, we all know that this is a public IP address, which means this is an address that can be used on the Internet. Here, the first eight bits are network bits. This leaves 24 bits as host bits. So, the total number of usable host addresses is 224 – 2, which is a big number 16777214. That’s the number of usable host IP addresses, meaning all those IP addresses can be assigned to hosts.

Most organizations don’t need such a large network. And it would be difficult to manage such a large network. And the broadcast traffic would also be enormous. Think about this. How many companies really need to put so many hosts on a single network? Well, not too many. There are large companies, but there are not too many of them. And putting so many hosts on the same network will make it difficult to manage. Subnetting can help solve this problem by breaking this large network into smaller networks.

Now, let’s look at one more example. Consider two routers connected with a link. These routers exist on the Internet, which means these two links that connect the routers need to have public IP addresses. Now, we know that there are three classes of IP addresses – Class A, B and C, and the class that has the smallest subnet mask is Class C, which is /24. Now, if you’re wondering why is /24 smallest and not /8? Well, the reason is that /24 has the least number of usable IP addresses, which is to 28 – 2 while for Class A, which has a /8 subnet mask the total number of usable IP addresses would be 224 – 2. We know that the total usable IP addresses is 28 – 2, which is 254. So, if we were to assign an IP address with the smallest subnet mask to this link over here, we would be using only two IP addresses from that, which means we still have 252 IP addresses left. Imagine this. We would be wasting so many IP addresses.

After all, we only need two IP addresses. This is where subnetting comes into the picture. Instead of assigning a /24 subnet mask to this link, consider assigning a /30 subnet mask. On this /30 subnet mask, the first 30 bits are assigned for network and the last two bits are assigned for host. That means the total number of usable IP addresses will be 22 – 2. That’s 2. We have the exact number of IP addresses that we need. One over here and one over here. So, subnetting allows efficient use of IP addresses.

Now that we’ve understood what is your subnet mask and what is its importance, we’ve set the context for the next discussion, which is subnetting examples. We’ll understand how to break a large network into multiple smaller networks.

Leave a Reply

How It Works

img
Step 1. Choose Exam
on ExamLabs
Download IT Exams Questions & Answers
img
Step 2. Open Exam with
Avanset Exam Simulator
Press here to download VCE Exam Simulator that simulates real exam environment
img
Step 3. Study
& Pass
IT Exams Anywhere, Anytime!