And it is now the top of the hour. Good morning. And now we have our second talk of the day, our second of four, sponsored by the Packet Hacking Village. And we are honored to have Dennis Smilovic on IPv6. Dennis, take it away. Hi. Yeah, as Ming said, my name is Dennis Smilovic. I'm a principal security consultant at Nova Information Security based in San Francisco, California. And so IPv6 was something that I used to struggle with a lot. I've seen when working with different clients that it's a general thing in the security community that it's kind of this thing that's hard to understand, and we prefer keeping our infrastructure on the legacy IP version, which it actually is when you're working with IPv4. And so when going through this process of wanting to understand IPv6, what really happened was that I realized after going through everything that the reason that it was so hard is that because over the years, IPv4 has gotten so many extensions and NATing and other technologies that you're putting in place that is... they're making the internet work, but really they're abstracting from what was actually intended. And so when understanding IPv6, what we really need to do is to dial back, understand IPv4, and from that, it's really easy to jump the next step, because then IPv6 is just a couple of more bits and a different way to write things. So yeah, I hope this is going to be useful to you. So... with IPv4, all of my knowledge had come from practical use. And that boiled down to something like the following. So this might also be the case for some of you. My understanding was that this was an IP address, which it also is, and that the subnet mask is probably 255.255.255.0, but only DHCP really knows. And the last one was that the default gateway was the same IP as my IP, but just with a 1 at the end. So these are not like set in stone. That's not actually how things work. But it's so close to, like, the configuration that you see most of the times, that you can probably wing it by doing something like that. And so that continued on to being that an IP address is something... a private IP address is one that starts with 192.168.something.something, or 10.something.something.something. And I didn't really understand why. I just knew that, like, that was probably a private IP address and the rest was the internet. And so this configuration that I'm showing up here, it's a fine way to do it. Now, this is not going to work if we're working with a network that's not, like, very standard, or what we see in, like, all our home routers. And that's where, you know, it becomes a problem, and we try to set this up, and then the network doesn't actually work. So specifically, this configuration is limited to exactly 253 client devices, and so you'll pretty quickly outgrow that for a private network. But let's take a look at what these numbers actually mean. So again, this is an IP address. It consists of four, we'll call them fields for now. One, two, three, four. And they each can have a value between zero and 255, giving us 256 possibilities for each field. And now, each of those numbers, they actually represent a binary value. We know that that's how computers work. And so to represent 256 bits, 256 possibilities in binary, you need 8 bits. And so every one of the fields is 8 bits, and that's what's called an octet. Like, we have one octet, two octets, three octets, four octets. And that gives us 32 bits. Every IPv4 address is 32 bits, and that's full stop. So next up is the subnet mask. Here we have 255.255.255.0, which is a very common configuration, as I mentioned, unlike most of our home routers. And so what the subnet mask actually does is that it makes your computer understand where to send a packet. If I need to send a packet to another machine that's on the same network as me, on the same Wi-Fi or behind the same router, it's in the same LAN, I need to send it out on that. But if I want to send a packet somewhere else, a server on the internet, for instance, I can't reach that. And so I have to send it to my router. But there needs to be some kind of mechanism where the computer can distinguish whether their packet goes one way or the other way. And that's what the subnet mask does. So if you convert this to binary, what we see... I didn't have to use a calculator for this, by the way. We see that this is what the subnet mask becomes. And so part of the reason why subnet masks can be a bit intimidating to understand is because 255.255.255.0 doesn't really mean anything. It's only when we look at the binary representation that we can understand what the computer is actually doing. So let's take a look at that. On top is the IP address of my machine, and on the bottom is the IP address that I want to speak to. And so in between those, we put the subnet mask. And so basically what the computer does is that it takes the subnet mask, it looks at it. If there's a one, the top one and the bottom one have to match. So if we look at the first ductet of the subnet mask, all of the first eight bits in both IP addresses have to match. If they do match, the packet is destined for our local network. If they don't match, we have to send it off to someone else who can figure out how to get the packet where it needs to be. So we take a look at the first. They have to match. All first eight bits match. The second ductet, okay, they're all ones, so they all have to match. We look at the two addresses, they all match. The third ductet of the subnet mask are all ones, so they all have to match. And we look at the source address, my IP address, and the destination address, and they also match. And so for the last ductet of the subnet mask, after checking all of them, we see that they don't actually have to match. Which is very convenient because they don't match. So that's fine. This packet is destined for my local network. So I can just send it out on the network. But if we change that, I've changed the destination address to the address that Google.com was resolving to at one point when I made this presentation. And so when we look at this, already from the beginning, we see that our subnet mask says that if a packet is destined for the local network, all of the bits in the first ductet have to match. And we see that that's not the case. So we already know by just checking the first one, that this packet is not destined for the local network. And so because of that, we send it to the default gateway, which is the last parameter that we configure. And so I'm going to do something that's a little bad. I'm gonna go back to the previous slide. And I'm gonna remove these so that we only have the subnet mask left. And I know that I just told you how all of this works. But we don't really need it anymore. So because subnet masks are confusing, when there's a much, much shorter way to actually write this. If you look at the binary representation here, it's very simple. It's a bunch of ones, and then it's a bunch of zeros. And so in modern network, the ones and the zeros in the subnet mask, they have to be contiguous. And they always have to start with the ones, and then they have the zeros. So the easier way to represent this would be to just write it in something called CIDR notation. And so the only thing that you do is that you count how many ones do we have before the zero. In this case, we have 8, we have 16, and we have 24. And so because of that, instead of writing both our IP address and our subnet mask, we can just write our IP address in CIDR notation. And by that, we're representing both values. So we end up with 192.168.1.27.24. And this is going to be really important for when we take a look at IPv6. So we get away with that. And we still can't avoid having to specify a default gateway, but at least this is much more condensed and easier to understand, and not as redundant as what we were looking at before. So before we use all this knowledge to learn about IPv6, I just want to quickly go over the layout of the current allocations of the IPv4 internet. And so that essentially means how many addresses do we have, and what are they used for. So this one is from January 2023. Not much has changed in the meantime. And what's very interesting is that you can see it's very, very, very full, except for the two boxes up in the corner. It's taken. Like, they're small, minor allocations within, like, other networks that you might still be able to get from, like, the regional internet registries. But it's full. Like, this is very, very full. And so then someone might say, and have also said, that, oh, but why don't we just repurpose the multicast space or the future use space? Like, they made a very nice convenient block up in the top right, so why don't we just, like, use that? Like, it's for future use, so we'll just start, like, using it. And so the problem is that a lot of devices actually have hard-coded that these addresses cannot be used, or some engineers decided that they could use them to do, like, some internal stuff, and so using them for actual IP addresses is not something that can actually be done. Like, I would obviously never name anyone who would do this, but, oh, I might be some technical glitches or something. That was completely unrelated to what I just said. So a challenge for all of you, by the way, can someone count how many times USDOD appears in, like, the internet routing table? It's a lot of times, and it's, like, okay, I mean, do they need that many IP addresses? What did you say? Ford Motor Company has a slash eight. And so from what we talked about before, we know that that means that the first octet is set, like, the number before the first dot of the IPv4 address. In this case, it would be 19. The rest is theirs. So every public IPv4 address that starts with 19 belongs to Ford Motor Company. Now, we have less than 256 of those to share between all the people on the planet. So Ford, the car company, they own one 223rd of the internet. And that takes me to my point. It's unsustainable. So after knowing all of this, we know it's 32 bits, like, this is an IPv4 address, and you look at it, and you're thinking, oh, this would all be solved if we just had more bits, double the bits. That's a lot of bits. That's 64 bits. And that would give us more addresses, sure, but if we go back and look at the allocations of the IPv4 internet, we see that not only is it very full, we also see that the same entities appear multiple times, essentially meaning that people run out, and then they grab, like, another block. And so it would be really cool if we could make a system that has so many addresses that as soon as we make an allocation, the person that we've given it to will never outgrow it. Like, we'll just give them so ridiculously many IP addresses that you'll only ever need one block that's gonna show up in, like, the internet routing table. And so 128 bits. Like, it's not double, it's double the double, and it's a lot of bits. So just to be sure that we're all on the same page, when we add a bit, it's not double the IP address. When we go from 32 bits to 64 bits, it's not double the addresses. When we go from 32 bits to 33 bits, it's double the addresses. So every time we add a bit, 33 bits is double the IPv4 internet, 34 bits is four times the IPv4 internet, 35, eight times that, and you get the drill, but 128 is, like, a lot of IP addresses. I think someone told me that the IPv6 internet is so huge that there's addresses enough to represent every grain of sand on the globe, or every star in the visible universe, or something crazy like that. Yeah. So that brings me to our next section. So to represent 128 bits, we can't use the same system with octets as we used in IPv4 and just separate them with a dot. It would look horrible. So IPv6 addresses work a bit differently. And so this is the IPv6 address that, again, Google.com resolved to at some point when I was doing this presentation, and it looks way more confusing than an IPv4 address, and that's, like, the big thing that I hear with people in IPv6, like, oh, I look at the addresses and, like, my head starts hurting, and it's so confusing, which is true. But what is really cool is that we can start breaking this up and understand how it works, and suddenly it goes from being, like, a random string of, like, colons and letters and stuff to actually making sense. So let's try to take a look at that. First of all, the numbers, they're in hex, and we'll get there in a second. But before we go that, I'm just going to tell you that we have eight fields, and each of them are 16 bits. So you have 16 bits, then a colon, 16 bits, then a colon, 16 bits. You get the drill. And now, so to make this easier, we're just going to have a look at the last field. And so the thing is that we have 16 bits here, and we know that the whole IPv4 internet is 32 bits. So actually, with only two fields from an IPv6 address, we can already represent all addresses in the IPv4 internet. Yeah. So in hex, just to understand hex, we count from zero, and then we count up to F. And so that's done by zero, one, two, three, four, five, six, seven, eight, nine, A, B, C, D, E, F, zero, one, two, three, four, five, six, seven, eight, nine, A, B, C, D, E, F, zero, one, two, three, four, five, six, seven, eight, nine, A, B, C, D, E, F. And it just keeps counting like that. Very important to understand to get, like, these addresses are actually... why they look so weird. Okay. Does that make sense? Okay. So now that we understand the basics of how hex numbers work, let's try to understand what information we can extrapolate from the different parts of an address. It's not a rule, but, like, most IPv6 addresses consist of a host, that's the first orange part, and then an... sorry, a host, the blue last part, and the network, the first orange part. And they're often separated in the middle by 64 bits for the network, here in orange, and 64 bits for the host, here in blue. So what we learned about in the IPv4 section, this would be a slash 64, because the blue part is our network, when we have an address that has the same first half as ours, we can send it to our local network. If it's an address outside of that, we have to send it to someone who knows how to pass it on. Usually our default gateway. So the reason that having 64 bits in the host part is actually that it allows for some pretty cool features. And so one of them is stateless address auto-configuration, and the other one is privacy extensions. And so I'm just going to go over what they are, because then we'll actually see how, like, we go from having a network, and then actually setting the last part. Because when you look at an IPv6 address, unless you've set it statically, you're not going to see 0, 0, 0, 0, 0, 1, A, 0, 0, 0, 0, and counting up like that. So what stateless address configuration is actually really cool. It uses the 64 bits that we have available as the subnet of the network, and then it generates an IP address by itself, just from knowing the first network part. And the process is called EUI64, and what it does is that it takes the 48-bit MAC address of the network interface, and then it expands it to 64 bits. So by that, we have, like, our network, which is the orange part, and then the last part is decided by calculating it based on the MAC address that the interface has. And so without doing any DHCP or anything, by just knowing the network that we're working on, our computer can pick an address for itself, because MAC addresses are pretty unique. It's unlikely that it's going to clash with anything. It's supposed to be unique. And by that, we can just pick an address by ourselves. We don't need to be told what IP address is available on the network. And the second cool feature is privacy extensions. So with pretty much every device on version 6 of the internet, you're suddenly vulnerable to tracking. Maybe someone realized before that if you have the same MAC address between every network that you move across, you'll be pretty easy to track. And so that would be pretty problematic that, like, you can be correlated across, like, many different networks. So what privacy extensions does is that it works by changing your IP address regularly. So we have the 64 bits in our host part, and they just change, like, over time. You visit a website, it uses one address. You visit another website, it uses another address. After some time, it changes to a third address, and it cycles through them. Which is pretty cool. Like, it gives an increased level of privacy. So the reason... yeah. And then I just wanted to mention the last really cool feature about IPv6 is that when you have this huge space, when you have 64 bits to work with, you do get the thing that, like, suddenly the subnets that you're making, the smallest meaningful subnet that you're making, 64 bits, which is very standard, you can make them smaller. But, like, you make a 64-bit subnet, and suddenly it can contain pretty much an endless amount of addresses. Like, if you're working with IPv4, you have to decide, okay, do we want this network to be a slash 64? Then we have 250 free addresses that can join that network. With IPv6, you just always do a slash 64. Did I say 64 the other time? Yeah. With IPv4, you'll usually make a slash 24 network for your home network that limits it to 250 free addresses. And then, like, if you're an enterprise setting or something, you need to start making address plans to make sure that there will be enough addresses, considering what it is that you want to do. And then maybe you get an office in the future, and then suddenly, ah, it doesn't fit into the address plan, and then you're kind of screwed, because you're out of addresses. With IPv6, you can always make a slash 64 subnet, and you basically are able to put in... there's not a limit of 250 free or however many you've specified when you designed a network. You can just have pretty much an endless amount of machines be on that network. Which is a pretty cool feature. So, now that you know how to read an IPv6 address, looking at just, like, the same plain thing as we did before should hopefully be easier. And hopefully also, you know, not just easier to understand, but also easier to remember. Because if you work in the same environment, it's very likely that the first 64 bits are gonna be the same. We know that, like, depending on where you are geographically, or where you got your IP addresses from, the first part of the range that you got is usually gonna be the same. So, as you work with this, things are gonna be pretty familiar. And then you know the first part, and then the last part is up to you when you design the network. It's either gonna be decided by the host itself, or maybe you set it statically and it becomes something like 0, 0, 0, 0, 0, 0, 0, 0, 0, 1. So, let's just see how you should handle these addresses when using them. You heard me say... you heard me mention, like, a lot of zeros there. And so, what's really cool is that we're actually allowed to do this. Where instead of putting four zeros in each field, just put one. Like, a zero is a zero. And then, like, moving on from that, like, we're also allowed to do something else. We have three fields of zeros here right next to each other. And we're allowed to shorten that by doing a double colon. We know that an IPv6 address is 128 bits. So, if we see an address and we have a double colon, it means that everything between... you just expand it up to 128 bits in that section with zeros. And then, you have, like, the full IPv6 address. You can only have one double colon, though. So, that's very important to know. Because if you had multiple double colons, it wouldn't know, like, where the section in between them would go with all the zeros. So... and I think this is maybe what trips up a lot of people. Like, you both have, like, hex numbers and you have colons in your IP address. And you have double colons. And then, you have, like, slashes. And then, it just becomes, like, way too abstract from what you're familiar with. Yeah. So, the next thing that would probably be really good to just mention is how do you browse the web with this? We know that protocol handlers, HTTP, HTTPS, use colons. So, if you suddenly have a protocol handler, HTTPS colon slash slash. And then, you have this address, like, that seems to, like, mess something up. So, the problem with pasting it, yeah, in the address bar is what I just mentioned. Colons are used to indicate protocol handlers and used to indicate port numbers. So, putting in an address with a bunch of colons is just gonna make everything more confusing. So, that's not going to work. And so, what we instead do is that we put this address in square brackets. And then, we press enter. And then, we browse to the web. So, that's just, like, a good thing that's good to be aware of. Because you understand IPv6. You know how the addresses work. You see this. You're, like, oh, I want to try to browse to an IPv6 address. And then, it doesn't work because your browser's, like, what are all these colons doing? But this is the way to do it. So, lastly, in this section, I'm just gonna end it the same way that I did with the other one, by showing you a map of the internet. And so, in this case, it's IPv6. And as you can see here, our idea of using double double the amount of bits, as in an IPv4 address, it achieved what we wanted. Like, everyone seems to have pretty much one large IP block. And it's not a scattered mess that we saw with IPv4. And so, essentially, this is not even the whole IPv6 internet. This is just a part of the IPv6 internet that we have allocated today. So, people say, will we run out of addresses? And it seems like we're only having a couple of seconds left. Will we run out of addresses? No. Because this is one eighth of the IPv6 internet. And we can fuck up seven more times until we're out. Thank you very much.