Categories
Gushing About Tech

The Basics of Home Networking (or: Why IPv6 is Awesome)

I was getting excited over on Fedi about finally having native IPv6 support on my home Internet connection, no tunnels necessary, and after someone asked, that led into an explanation of the basics of IP addressing, NAT, port forwarding, and routers generally. It was a bit long to dump onto people’s timelines, but that sort of long-form infodump is exactly what I put this site up for, so here we go.

I’m going to try to keep the assumed level of knowledge low so as not to exclude anyone, so if you already know some of the basics, feel free to skip ahead a bit. Seriously, I won’t mind. Or even notice. I’m not even tracking how many people load these pages up, never mind actually read them.

IP Addresses: v4 and v6

Oh, wow, did you see what happened to my voice there? That was cool. I bet it had a dramatic echo and everything. I sound Authoritative and Well-Read with all these fancy Section Headings.

So why is any of this IP address stuff and all those other acronyms even important? Well, it all comes down to knowing where to send things.

The Internet runs on the Internet Protocol, appropriately enough. Everything on the Internet has an IP address, and data tagged with an IP address will go to that thing, wherever it is. Hence, address.

Most of the Internet you know runs on IPv4 – version 4 of the Internet Protocol. No one talks about versions 1, 2, or 3, and even mentioning them can draw the ire of the Elders of the Internet, and you do not want that kind of attention. Version 5 is likewise verboten.

(More seriously, versions 1-3 and 5 were experimental and never made it into the real world. I don’t know much about them.)

An IPv4 address is a 32-bit number, and that means there are about 4 billion of them in total. That sounds like a lot, right? Nope. Not even close to enough. The way addresses were allocated in the early days was massively wasteful, and even if they were distributed fairly, there are 7.8 billion people in the world. It’s hard enough sharing a postal address with someone else, and at least letters have your name on them.

No, I haven’t been reading your mail. I’m offended that you’d even ask.

Anyway, not enough IPv4 addresses. Clearly what we need is a bigger number so we can have more of them! And that’s all IPv6 is: 128-bit addresses so we can have more of them. So many that each one of those 7.8 billion people could have a few zillion IPv4 Internets of their own and not even use a fraction of a percent of what’s available.

Overkill? Maybe. But better than running out again. And we did run out of IPv4 addresses. Luckily, IPv6 was finalized in 1998, and following that was swiftly adopted worldwide and effectively solved the problem— ahahaha, no. About three quarters of all Internet traffic is still IPv4.

NAT: Network Address Translation

So how did the world actually deal with there not being enough IP addresses? Well, they learned to share. That’s called NAT.

This is something that almost all IPv4 routers do, and that’s (mostly) a good thing.

In the early days, everyone on the Internet had their own block of addresses that they could assign as they liked, but that hasn’t been true since 1990 or so, due to the address shortage I spent the entire previous section going on about.

What this means is that your router gets one and only one IP address that can be reached from the Internet. Any time you connect to something else out there through the router, you appear to be connecting from that one address, and when replies come back to you, the router keeps track of which connections belong to whom and send them to the right place. Hence, “router”.

So how do you connect in, to a specific device, when there isn’t already a connection from that device out? Like running a server? Well, that’s the problem with NAT. You more or less can’t. The router doesn’t know what to do with an incoming request with no context behind it.

Unless you tell it. And that’s where port forwarding comes in.

Port Forwarding (you want me to do what to my router?)

Almost all traffic on the Internet is either TCP or UDP, and while the specifics are a bit beyond the scope of what I’m talking about here, those protocols have a port number associated with them. Think of it like an extra number on the end of the IP address.

It’s like having your name on the letter. Because computers can do more than one thing, that port number is intended for the receiving computer to know which program should handle the incoming data.

But we can also make use of this when working with a NAT router. When a connection comes in on a specific port, a router can be configured to always send that on to one specific address on the internal network.

For example, you can have the router send everything on TCP port 80 (HTTP) to whichever computer is running your web server. Others on your home network can still browse the web, but unprompted external connections can be sent to that one server box.

So, if you know the port number the program you’re working with listens to, and the internal IP address of the computer running it, you can configure the router to send all the traffic for that program to that computer.

Notably, you cannot have two servers for the same thing running on the same network without doing some complicated shenanigans with proxies that I won’t go into. As much as I love a good shenanigan, this post is way too long as it is.

DHCP: Why It’s Not That Simple

Now, if it’s just a temporary thing for a game, you can find out your machine’s local IP address, plug it in, and off you go. Unfortunately, the nature of private Local-Area Networks means there’s a bit of extra work if you want a permanent server, and that’s because of DHCP.

Dynamic Host Configuration Protocol is how computers on a network get their IP addresses. When they connect to the network, or their current address expires, they send out a DHCP request to anyone who’ll listen.

Your router is also a DHCP server, which means it is listening for such broadcasts. When it gets one, it’ll assign the computer an IP address, usually in the 192.168.x.x range (though there are others) which is reserved for LANs like this. Such assignments are temporary – after a set period, usually 24 hours, the computer has to ask for its assignment to be renewed.

Most DHCP servers will try to keep a computer’s address consistent, but it’s best-effort only, and there is no guarantee the address will remain stable over time.

So if you’re running a permanent server on a private network, you need to assign it a static IP address in the router. That *does* guarantee that that computer will always receive the same address, and that no one else will ever have that address.

It makes sense on small home networks, but for bigger setups it can be a problem to permanently take an address out of service, as there are only 250 or so to go around on a given network due to the way IPv4 was designed.

Big company networks with more computers than that? Actually composed of several sub-networks that talk to each other through routers, which all just works because that’s what the Internet Protocol was designed to do without NAT getting in the way.

(Yes, I know CIDR with variable subnets is a thing, but that’s way above the level I’m going for in this post. Don’t worry about it.)

Wrapping It All Up

IPv6 was designed to make all of this unnecessary. There is no NAT in IPv6. There is no port forwarding in IPv6. There is a greatly reduced need for proxy shenanigans and subnetworks can be bigger than the entire IPv4 Internet.

So why aren’t we all using IPv6? Money.

IPv6 isn’t backwards-compatible with IPv4. What that means is that you need to run the two separate systems side by side until everyone’s on IPv6 and you can turn IPv4 off for good. You can run them on the same physical wires, but you need two completely different sets of software and, in some cases, switching hardware.

That’s more expensive than having a single IP system you can use for both, and NAT really doesn’t hurt most home users that much. I care because I’m running things on my home network that I want to be reachable from the Internet, but non-technical users don’t have any such need.

What that means is that people aren’t willing to pay for IPv6, so penny-pinching companies naturally don’t want to invest in setting them up.

What about companies that actually need lots of IP addresses to make things available on the Internet and would pay for IPv6? Well, aside from the fact that most of them already do support IPv6, they can also afford to buy blocks of IPv4 addresses at a premium.

Should You Care?

I can’t answer that. I do and I think I’m right to do so, but I’m not exactly your typical Internet user. I literally write blog posts about computer networking, as it turns out.

But if you’ve read this and decided that you should care, or at least want more information to decide if you do, the World IPv6 Launch site is a good place to start.

If not, don’t worry about it. There are more important things in this world to worry about than IP addresses. Look after yourself first.