How can i bind a network interface to an entire /48 subnet of IPv6 addresses without having to enumerate each and every individual address?
Context
I need to know how to setup an entirely /48 IPv6 block in my server to perform outgoing requests with any of these IPv6 addresses without setting up each one individually.
My ISP provides this subnet via an DHCP6 server connected directly to my machine on their data center.
The machine runs Ubuntu Server 20.04.
I've arleady tried this:
-
ip addr add 0000:000:00::/48 dev lo
, works really well with IPv4 adresses, i already get an /26 IPv4 block working this way for outgoing requests, but i can't with IPv6; -
ip route add local 0000:000:00::/48 dev lo
, i can ping any IP locally usingping6
, but i can't bind any TCP socket to the IP and perform outgoing requests, I receiveEADDRNOTAVAIL
;
Question
Am I missing something? How i can get this working?
Resourses
Netplan config
network:
version: 2
renderer: networkd
ethernets:
enp132s0:
dhcp4: yes
dhcp6: yes
enp6s0:
dhcp4: yes
dhcp6: yes
Other Serverfault questions
- How to bind a range of ips to ubuntu interfaces;
- Adding a whole IPv6 /64 block to an network interface on debian;
- Assign Entire IPV6 /64 Subnet to Network Interface [duplicate];
- Can I bind a (large) block of addresses to an interface?
Your second Server Fault link outlines what is required. Routed prefix to you, local route on that host, and allow non local IP in socket also known as IP_FREEBIND. EADDRNOTAVAIL implies step three is incomplete.
Confirm your routed prefix and local route works by pinging an IP in it from a different IPv6 network.
On Linux, allow bind to other IPs by creating /etc/sysctl.d/freebind.conf
containing
net.ipv4.ip_nonlocal_bind = 1
net.ipv6.ip_nonlocal_bind = 1
Applications should bind to a desired IP address. Otherwise if not provided, the usual source address selection would pick some local IP assigned to an interface. Also possible to set IP_FREEBIND option on a per socket level.
Note that even without this routed prefix trick, a large number of IP addresses can be assigned to a host. Possibly several thousand before neighbor discovery becomes a problem.
IPv6 subnets should be /64 in size. Standardizing on lower half interface ID, upper half aggregation for routing. As router, this host might still be routed a /48, but only needs a /64 on the loopback route to itself.
Number of IP addresses is not important, as 2^64 is already effectively unlimited in size. Perfectly fine to only use one or two /64s out of a /48, leave room in the address plan for other things.