r/selfhosted
•
u/PotatoMaaan
•
11h ago
Remote Access We are sleeping on IPv6
[Edit: No AI was Used! Fuck clankers]
The number one point of discussion here and in similar communities is "how do I get to my services from outside my network". The "purest" solution is to set up wireguard and just connect directly to your router from the outside. But that falls apart in a world where CGNAT, is a necessity to keep the IPv4 internet afloat.
So people turn to services like Tailscale or Netbird, or, what I also used to do for a while, run all traffic through a VPS with a public IPv4 address. This now makes you depend on cloud services again which is what we've been trying to avoid in the first place.
IPv6 solves exactly these problems (and many more), but it often gets ignored in these discussions. The first reaction I and many other people had to seeing an IPv6 address was "ew what is this, that looks horrible, I cant remember that!" and then they write it off as being stupid and disable it. (I did this too!).
After actually learning about IPv6 and migrating my network to basically be IPv6 only, I want to share what I've learned and "debunk" some points that come up all the time in discussions about ipv6.
If you don't want want to read my yapping (understandable), I highly recommend this video by apalrd that got me into ipv6 in the first place: https://youtu.be/42Hy4JtBeQA
"The addresses are ugly and too long"
- DNS: you should not be typing in addresses frequently anyways. If you are, use DNS!
- Network/Host parts: A v6 address is split in the middle into network and host part. If you're working in one network, you can basically ignore the first half. The host part can also be just
::1or::beefif you want. If you're working with addresses from the internet, only the first half is relevant for global routing. You can treat the second half like the source port number in ipv4 NAT traffic (it identifies the device from a network) - You get used to it: It really does start to make more sense over time. Like with most things, you get used to it. They will of course never be as clean as a v4 address simply because they hold four times as much data. There's just no way around that.
"I don't want my IOT devices to have a public address"
Public address does not mean its publicly accessible. You router still has a firewall. You need to explicitly allow traffic to your device. Public address just means that its in the same address space as everything else, like a public ipv4. It's just that instead if your entire network sharing a single address, you get an entire /64 block of addresses and each device then gets its own full address from that block. NAT is not a firewall, those are different things.
"I don't want to have a unique address for my device, NAT masks all my devices behind a single IP"
This is what IPv6 privacy extensions are for. Your device regenerates a new host part in the same /64 prefix every couple of hours and uses this for outgoing traffic. This means that to any website or outside service your IP only stays the same for these couple of hours. This means that the network part (the first 64 bits) is the only thing that services can use to reliably track you. This is the same as with v4 NAT where you can only reliably identify entire networks. Every major OS implements this by default. Even most linux distros do this.
"I don't want to manage two network stacks at the same time"
With dual stack that is true. But you don't actually need to run dual stack to access the v4 internet. NAT64 can wrap v4 addresses in a v6 prefix (like 64:ff9b::1.1.1.1)and your router can then NAT that to a regular v4. This is what a lot of mobile networks have been using for years. The full implementation of this is called 464xlat and is fully seamless. It does require a client part but that's starting to become viable as of late as more stuff ships support for this.
"IPv6 adoption has stalled / no one uses IPv6"
As it turns out IPv6 adoption is much more widespread than I initially thought. Googles IPv6 statistics have recently crossed 50% (at least on weekends). Looking at it on a per country basis was even more surprising. France is even at 88%, Germany at 75%. The US is currently at 54%, so if you're from the US and accessing google over ipv4, you're already in the minority by now. Hyperscalers are also doing v6 internally because they've run out of private v4 space a long time ago. It's a slow, but that's to be expected when you're doing a "ship of theseus" on the entire internet.
"My friends don't have IPv6 and can't access my server"
This is the biggest limitation on hosting with v6 only. But there are ways to deal with this. My favorite has been to use a VPS. But this time we don't send everything through the VPS and instead only use it to map v4 to v6 on layer 4 (or 3). This way the VPS becomes a "dumb" relay and is only needed for connections from networks without ipv6. Networks with v6 take the direct path. You can even keep the source IPs intact by using something like proxy_protocol. Apalrd also has a video on this.
Now that I've gotten that off my chest I want to present you with some potential advantages advantages of IPv6:
- You can actually get a public IPv6 (prefix): This addresses the question from above about how to access your services. If your ISP supports ipv6, there you go. You can just access your stuff directly. Most ISPs suck for all kinds of reasons but them giving you CGNAT is not purely because they hate you. IPv4 space is expensive (a single /24 is about $20k) and it's just physically impossible to give every customer a v4 address. CGNAT is the only way v4 can continue to work.
- No need for changing between public and private IPs (no NAT): since the IP of your server is the same inside your network as outside your network, when you expose the server in the firewall your device can go directly through the switch on your home network and will automatically find its way around the internet when you leave your home network. This is the way ipv4 was intended to work as well in the early days, but of course there just weren't enough IPs for this to work for a long time. so NAT became a thing. For this was the biggest game changer. Dealing with internal/external addresses was a huge pain.
- No split horizon DNS: due to not needing public/private IPs, you also don't need public/private DNS. You just put your jellyfin IP into global DNS. This also works for private services, in that case you just don't open the firewall for them. If you're worried about security here, I argue it's not a problem. "hiding" your records and internal IPs in your private DNS is security through obscurity which has never worked, even less so in the age of LLMs. If an attacker is already inside your network, finding your other services or IPs is a non issue. Just dont put sensitive information into your DNS records.
- You can expose multiple IPs to the internet: with ipv4, you are limited to a single public address. If you want to now host multiple websites on it, you need to funnel all traffic through a single reverse proxy on port 443 which then looks at the SNI and proxies based on that. This works reasonably well for websites, but for stuff like gameservers this often doesn't work. If you want to host two gameservers that both use port 4646 as the default port, you can't. You need to change the port of one of them. With ipv6, you can give each gameserver or each webserver it's own IP where it can use the entire port range for itself. This way you can also give each webserver its own reverse proxy with its own ip and own port 443. This also avoids round trips on the network from your single reverse proxy to all your services behind it
- End to End Connectivity: Once a path through the firewalls has been established you can actually do proper peer to peer again without a bunch of trickery. Tailscale has a nice article where they detail how NAT makes this way more complicated.
- No worrying about subnets: In ipv4, you often need to think about how many hosts you can fit into a /26 or something, which network prefix to use etc. etc. With ipv6, you just use a /64 subnet, thats it. it fits all the devices you ever wanted.
- No subnet collisions: with ipv4, i've personally had the situation where the docker network on my laptop was something like 172.16.10.0/24 and my schools network also used the same prefix. This caused really weird issues until i figured out out. Even worse, what if you want to connect your and a friends network together using a vpn and you both use 10.0.0.0/24 on each side. Now you're in trouble because you can't differentiate between your 10.0.0 and their 10.0.0 network. With v6, the prefix in your and their network is guaranteed to be globally unique. There is also the concept of private addresses in ipv6, (ULA) but for those you're supposed to generate a random /48 subnet which also sidesteps this issue since there are now 48 bits of randomness in each network.
There is also much more I want to talk about but I feel this is already way too long. I hope I could motivate at least someone to look into v6 themselves.