1 00:00:00,130 --> 00:00:03,130 Okay, so now let's talk about CIDR or CIDRs 2 00:00:03,130 --> 00:00:06,590 or Classless Inter-Domain Routing, 3 00:00:06,590 --> 00:00:09,650 which I will call CIDR for the rest of this course. 4 00:00:09,650 --> 00:00:12,500 So, it's a method for allocating IP addresses 5 00:00:12,500 --> 00:00:14,310 and we've seen them before in this course, 6 00:00:14,310 --> 00:00:16,470 because when we look at security group rules for example 7 00:00:16,470 --> 00:00:19,230 and networking in AWS, we saw something like this. 8 00:00:19,230 --> 00:00:21,290 So, these are my security group rules 9 00:00:21,290 --> 00:00:23,090 and if we look at the source column, 10 00:00:23,090 --> 00:00:26,780 here we remember we had an IP address / and then a number 11 00:00:26,780 --> 00:00:29,880 and this was our first touch with CIDRs. 12 00:00:29,880 --> 00:00:31,880 So, CIDRs help define IP ranges 13 00:00:31,880 --> 00:00:33,990 that we've seen some very, very simple one. 14 00:00:33,990 --> 00:00:37,060 So, when we have an IP address /32, 15 00:00:37,060 --> 00:00:39,460 this actually represents only one IP. 16 00:00:39,460 --> 00:00:42,830 And when we saw 0.0.0.0/0 17 00:00:42,830 --> 00:00:45,470 then this is represented all IPs, 18 00:00:45,470 --> 00:00:47,890 but there are a lot of different possibilities. 19 00:00:47,890 --> 00:00:48,723 For example, 20 00:00:48,723 --> 00:00:53,290 if we define 192.168.0.0/26 21 00:00:53,290 --> 00:00:56,280 then this represents a range of 64 IP addresses 22 00:00:56,280 --> 00:00:58,130 as you see in this slide. 23 00:00:58,130 --> 00:01:00,360 So, how does CIDR work? 24 00:01:00,360 --> 00:01:01,980 Well, CIDR has two components. 25 00:01:01,980 --> 00:01:05,550 There's the base IP and this is an IP that is contained 26 00:01:05,550 --> 00:01:06,383 in the range. 27 00:01:06,383 --> 00:01:08,460 Usually it is the beginning of the range, 28 00:01:08,460 --> 00:01:10,660 but it could be that it's contained in the range. 29 00:01:10,660 --> 00:01:15,347 And then, so this is example, so 10.0.0.0 or 192.168.0.0. 30 00:01:16,570 --> 00:01:18,640 And then the other thing is the subnet mask 31 00:01:18,640 --> 00:01:20,870 and the subnet mask will define how many bits 32 00:01:20,870 --> 00:01:22,830 can change in the IP. 33 00:01:22,830 --> 00:01:27,090 So, we have the /0, /24 all the way to /32 34 00:01:27,090 --> 00:01:29,340 and this can take two different forms. 35 00:01:29,340 --> 00:01:31,830 So, if we have /8 this is equivalent 36 00:01:31,830 --> 00:01:35,980 to subnet mask of 255.0.0.0 37 00:01:35,980 --> 00:01:40,360 and /16 is 255.255.0.0 38 00:01:40,360 --> 00:01:41,610 and so on, okay. 39 00:01:41,610 --> 00:01:46,610 But the most common form we see in this course and in AWS 40 00:01:47,700 --> 00:01:49,250 is the / form, okay? 41 00:01:49,250 --> 00:01:50,440 So, for the rest of this course 42 00:01:50,440 --> 00:01:53,710 we'll be using /8, /16 and so on. 43 00:01:53,710 --> 00:01:56,250 Now, let's have a detailed look at subnet masks. 44 00:01:56,250 --> 00:01:58,210 So, this is how we can define 45 00:01:58,210 --> 00:02:00,840 which values can change from the base IP. 46 00:02:00,840 --> 00:02:03,940 So, if we have an IP address /32, 47 00:02:03,940 --> 00:02:07,140 this allows for one IP, 2 to the power of 0 48 00:02:07,140 --> 00:02:10,759 and this is the IP that we have on the left hand side. 49 00:02:10,759 --> 00:02:13,370 Now, if we have an IP /31, 50 00:02:13,370 --> 00:02:15,420 then we allow for two different IPs. 51 00:02:15,420 --> 00:02:20,420 And so we'll allow for 192.168.0.0 and then .0.1. 52 00:02:20,710 --> 00:02:23,870 If we have the same IP /30, 53 00:02:23,870 --> 00:02:25,670 now this goes exponentially as you can see, 54 00:02:25,670 --> 00:02:27,380 we allow for 4 IPs. 55 00:02:27,380 --> 00:02:31,060 So, we'll have a bigger range from .0 to .3, 56 00:02:31,060 --> 00:02:34,813 then /29 allows for 8 IPs so .0 to .7. 57 00:02:36,458 --> 00:02:41,458 /28 allow for 16 IPs, so .0 to .15, 58 00:02:41,640 --> 00:02:43,190 then we can look at the table, okay. 59 00:02:43,190 --> 00:02:48,190 So, it goes from 4, 8, 16, 32, 64, 128, 256 IPs to change. 60 00:02:48,780 --> 00:02:53,110 So, the /24 is 256 IPs, which is 2 to the power of 8 61 00:02:53,110 --> 00:02:56,740 and this is from .0 to .255. 62 00:02:56,740 --> 00:02:58,660 Then if we go one step deeper, 63 00:02:58,660 --> 00:03:02,020 so we go to /16, so I skipped some in the middle. 64 00:03:02,020 --> 00:03:04,780 Then we allow for 2 to the power of 16 IP to change, 65 00:03:04,780 --> 00:03:07,560 so 65,536. 66 00:03:07,560 --> 00:03:10,640 So, as we can see the last two parts of the IPs have changed 67 00:03:10,640 --> 00:03:13,770 and then /0 allows for all IPs, 68 00:03:13,770 --> 00:03:15,880 so from the very beginning to the very end. 69 00:03:15,880 --> 00:03:16,713 So, how do we know? 70 00:03:16,713 --> 00:03:20,250 As a quick memo we know an IP is made of 4 Octets, 71 00:03:20,250 --> 00:03:21,820 so the first part, the second part, 72 00:03:21,820 --> 00:03:23,660 the third part and the fourth part. 73 00:03:23,660 --> 00:03:26,603 And /32 means no octets can change, 74 00:03:26,603 --> 00:03:29,157 /24 means the last octet can change, 75 00:03:29,157 --> 00:03:31,580 /16 means the last 2 octets can change 76 00:03:31,580 --> 00:03:32,413 and take different values. 77 00:03:32,413 --> 00:03:35,200 /8 is the last three octets can change 78 00:03:35,200 --> 00:03:37,510 and /0 is all octets can change. 79 00:03:37,510 --> 00:03:39,420 So, hopefully they started making a little bit more sense 80 00:03:39,420 --> 00:03:40,790 into how CIDRs work. 81 00:03:40,790 --> 00:03:43,120 So, now here comes a little exercise, 82 00:03:43,120 --> 00:03:45,390 feel free to pause the video if you need to answer. 83 00:03:45,390 --> 00:03:49,543 So, what is 192.168.0.0/24? 84 00:03:50,850 --> 00:03:53,440 So, /24 so that means the last octet can change 85 00:03:53,440 --> 00:03:56,130 and so therefore we have 256 IPs, 86 00:03:56,130 --> 00:03:58,670 because the last number it can go from the number 0 87 00:03:58,670 --> 00:04:01,670 to the number 255 included. 88 00:04:01,670 --> 00:04:05,393 Now, what is 192.168.0.0/16? 89 00:04:07,000 --> 00:04:08,080 Well, this is /16, 90 00:04:08,080 --> 00:04:10,060 so the last two octets can change, 91 00:04:10,060 --> 00:04:12,893 so we have a 65,536 IPs. 92 00:04:13,760 --> 00:04:18,760 And what is 134.56.78.123/32? 93 00:04:19,130 --> 00:04:22,630 Well, /32 so it's only one IP, so just one IP. 94 00:04:22,630 --> 00:04:26,140 And then 0.0.0.0/0 we know this one, 95 00:04:26,140 --> 00:04:29,030 it is all IPv4 space, okay? 96 00:04:29,030 --> 00:04:31,140 When in doubt, there is this little website 97 00:04:31,140 --> 00:04:33,560 that I can show you that is very, very handy. 98 00:04:33,560 --> 00:04:35,210 So, on this website we have two options, 99 00:04:35,210 --> 00:04:36,810 we can have a CIDR to an IP range 100 00:04:36,810 --> 00:04:39,250 or an IP range to a CIDR, so let's try both. 101 00:04:39,250 --> 00:04:44,000 So, if you have 10.0.0.0/ let's say a 16, 102 00:04:44,000 --> 00:04:47,270 we calculate it as you can see we see the first IP 103 00:04:47,270 --> 00:04:49,240 and the last IP in here. 104 00:04:49,240 --> 00:04:51,670 How many IPs are including to the range and so on? 105 00:04:51,670 --> 00:04:52,503 Okay. 106 00:04:52,503 --> 00:04:55,570 If we do /17, which is a little bit less obvious. 107 00:04:55,570 --> 00:04:58,550 In this one, we have 32,000 or so IPs. 108 00:04:58,550 --> 00:05:00,670 We can have a look at the first bit so 109 00:05:00,670 --> 00:05:03,690 this is the first IP and this is the last IP, 110 00:05:03,690 --> 00:05:05,790 so it's quite handy and again you can play. 111 00:05:05,790 --> 00:05:08,440 And reversely if you wanted to for example, 112 00:05:08,440 --> 00:05:11,580 take an IP range, so this IP range and figure out 113 00:05:11,580 --> 00:05:14,740 what CIDR this corresponds to, then click on calculate 114 00:05:14,740 --> 00:05:18,520 and this will give us a result of 10.0.0.0/17. 115 00:05:18,520 --> 00:05:20,770 So it's quite handy, if you start doing some networking 116 00:05:20,770 --> 00:05:23,400 to use a website like this to help you out. 117 00:05:23,400 --> 00:05:24,990 So, why are we talking about all these things? 118 00:05:24,990 --> 00:05:27,420 Well, because we want to discuss public versus private IP 119 00:05:27,420 --> 00:05:28,910 in the IPv4 space. 120 00:05:28,910 --> 00:05:31,500 So, there is the Internet Assigned Numbers Authority 121 00:05:31,500 --> 00:05:34,800 the IANA that established certain blocks of IPv4 addresses 122 00:05:34,800 --> 00:05:37,620 that will be used only for private LAN networks, 123 00:05:37,620 --> 00:05:40,930 so local network or public internet addresses. 124 00:05:40,930 --> 00:05:44,090 So, the private IPs can only allow for certain values. 125 00:05:44,090 --> 00:05:46,980 So we have this range for 10.0.0.0/8 126 00:05:46,980 --> 00:05:49,660 which represents, you know a huge amount of IPs. 127 00:05:49,660 --> 00:05:52,120 So, this is a private IP range you can use 128 00:05:52,120 --> 00:05:54,690 and this is your least something you use in big networks, 129 00:05:54,690 --> 00:05:57,200 because it allows for lot of different values. 130 00:05:57,200 --> 00:06:01,450 Then we have the 172.16.0.0/12, 131 00:06:01,450 --> 00:06:04,380 which is another sets of private IP addresses. 132 00:06:04,380 --> 00:06:06,040 And when you create an account 133 00:06:06,040 --> 00:06:08,270 it will provide you with a default VPC 134 00:06:08,270 --> 00:06:10,040 and it turns out the default VPC 135 00:06:10,040 --> 00:06:13,630 will be included in that networking space. 136 00:06:13,630 --> 00:06:14,463 And then finally, 137 00:06:14,463 --> 00:06:19,320 another one you may have seen before is 192.168.0.0/16, 138 00:06:19,320 --> 00:06:20,790 which represents your home network. 139 00:06:20,790 --> 00:06:22,940 So, this is very common when you have an internet router 140 00:06:22,940 --> 00:06:24,250 to have your own devices, 141 00:06:24,250 --> 00:06:26,620 have an IP that starts with 192, okay? 142 00:06:26,620 --> 00:06:29,550 So, all the other IP addresses out there in the world 143 00:06:29,550 --> 00:06:31,130 are going to be on the internet 144 00:06:31,130 --> 00:06:33,610 and they're going to be public IP addresses. 145 00:06:33,610 --> 00:06:37,800 So, that's it for these basics of IPv4s and CIDRs, 146 00:06:37,800 --> 00:06:40,750 I hope you liked it and I will see you in the next lecture.