Okay, lets understand how it all works...
When a machine boots up, it knows nothing about the network.
But, when an interface has
auto_linklocal
enabled,an IPv6 address is created automatically. These addresses are created from the MAC address, they start with fe80: and are linklocal to that network, cannot be routed onwards:
Code:
# ifconfig build
build: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
inet6 fe80::438:92ff:fe08:ac43%build prefixlen 64 scopeid 0x4
Then, when
accept_rtadv
is enabled, a router advertisement may be received from upstream, or we may run
rtsol
to explicitely request one:
Code:
# tcpdump -nibuild icmp6
17:21:05.910891 IP6 fe80::438:92ff:fe08:ac43 > ff02::2: ICMP6, router solicitation, length 16
17:21:06.123552 IP6 fe80::438:92ff:fe08:ac41 > ff02::1: ICMP6, router advertisement, length 88
That "router solicitation" request is sent from our linklocal address, and it is sent to a broadcast address
ff02::2
where the routers listen. A router in charge will then answer and send the router advertisement - which contains our real routeable prefix.
The kernel can now configure that network onto the interface. And also the kernel does now know the IPv6 address of the router - because that is the IP from which the router advertisement came! So this can be configured as the default route. In the example that would be
fe80::438:92ff:fe08:ac41%build
- so we get:
Code:
# netstat -rn6 | grep ^default
default fe80::438:92ff:fe08:ac41%build UG build
And now we're up and connective.
The problem here is: that address we got for our router, is again only a linklocal address! This is good enough for a route, because we get to the next hop, and that's all we need to. But it is only good for ad-hoc automated configuration, because such an IP may change on occasion - it should not be used in
rc.conf
to configure a default-gateway persistently.
Therefore, my hoster (scaleway) tells me
- your ipv6 prefix is 2001:bc8:xxxx:yyyy::/64
- and your nexthop/gateway is always nr. 1, i.e. 2001:bc8:xxxx:yyyy::1
That means, I cannot use the nr. 1 myself, because thats already occupied, but I could configure a defaultroute as follows (without configuring the /64 network):
Code:
route add -6 -host 2001:bc8:xxxx:yyyy::1 -iface bce0
route add -6 -net default 2001:bc8:xxxx:yyyy::1