Setup IPv6 subnets on Linux

From ivc wiki
Jump to navigationJump to search

This is a guide on how to delegate a he.net IPv5 /48 subnet into multiple smaller networks that you can route and manage on your own network. This uses Linux as the base.

This is a necessary if you want to run IPv4 on another router that can't handle IPv6 for some reason, this adds a dedicated IPv6 router in parallel to the IPv4 router - dual stack.

Topology

                               / ---- Router #2 ---- Hosts subnet #2
---- he.net ---- Router #1 ----
                               \ ---- Hosts subnet #1

Net info

(obfuscated to hide my ip range)

IP block: 2001:450:bb44::/48

Split into subnets

I decided to split the IP block into blocks of /117, 2048 addresses each, using http://www.gestioip.net/cgi-bin/subnet_calculator.cgi

The two networks I'm setting up now are:

Subnet #1: 2001:450:bb44::/117 - main subnet, router #1 needs to route subnet #2 to router #2
Subnet #2: 2001:450:bb44::800/117 - subnet connected to a router #2 which is behind subnet #1

Router for subnet #1

External (eth0) router IP: 2001:470:17:1e5::2/64
Default gateway: 2001:470:17:1e5::1/128

Internal (eth1) router IP: 2001:450:bb44::1/117
ip -6 route add 2001:470:17:1e5::2/64 via 2001:470:17:1e5::1 dev eth0

Add route 2001:450:bb44::801/117 via 2001:450:bb44::29 (this is another internal router)

ip -6 route add 2001:450:bb44::801/117 via 2001:450:bb44::29 dev eth1

Hosts behind subnet #1

Calculate or use https://www.ultratools.com/tools/ipv6CIDRToRange to convert the CIDR to the actual range.

Host IP: pick one between 2001:470:27:2d5::2 to 2001:470:27:2d5::7ff
Netmask/block size: 117
Default gateway: 2001:450:bb44::1

Manually assign addresses to the hosts or use DHCPv6 to automate the process - radvd won't work since it requires /64 subnets.

Router for subnet #2

External (eth0) router IP: 2001:450:bb44::29/117
Default gateway: 2001:450:bb44::1/117

Internal (eth1) router IP: 2001:450:bb44::801/117
ip -6 route add 2001:450:bb44::29/117 via 2001:450:bb44::1 dev eth0

Enable IPv6 forwarding:

sysctl -w net.ipv6.conf.all.forwarding=1 and store it in /etc/sysctrl.conf

Hosts behind subnet #2

Host IP: pick one between 2001:470:27:2d5::802 to 2001:470:27:2d5::fff
Netmask/block size: 117
Default gateway: 2001:450:bb44::801

Manually assign addresses to the hosts or use DHCPv6 to automate the process - radvd won't work since it requires /64 subnets.

Delete/remove subnets and host addresses

Find addresses/subnets:

route -n -6
ifconfig 

Remove them:

ip -6 route del 2001:450:bb44::/64 dev eth0
ip -6 addr del 2001:450:bb44::1 dev eth0

Test connectivity

From subnet #2 ping router #1:

ping9 2001:450:bb44::1

Find IPv6 aaaa record from DNS:

dig google.com aaaa

References