IPv6 Neighbor Discovery
CLI reference:/ipv6/nd/ipv6/address/ipv6/nd/settings/ipv6/nd/prefix/ipv6/nd/proxy/ipv6/neighbor
RouterOS supports IPv6 Neighbor Discovery and stateless address autoconfiguration with its router advertisement daemon (RADVD). Hosts on a link use the router advertisements to configure their IPv6 addresses and their default router.
Standards
RFC 4861: Neighbor Discovery for IP version 6 (IPv6).RFC 4862: IPv6 Stateless Address Autoconfiguration.
Node description
A node is a device that implements IPv6. RFC 4861 divides nodes into two types:
- Routers: nodes that forward IPv6 packets not explicitly addressed to themselves.
- Hosts: all nodes that are not routers.
A single device can have both roles: it forwards packets (router) and receives traffic addressed to itself (host).
Stateless address autoconfiguration
There are several types of autoconfiguration:
- Stateless: the host configures its address from the prefixes in Router Advertisement (RA) messages that have the autonomous (A) flag.
- Stateful: the host gets its address from DHCPv6. The RA sets the managed address configuration (M) flag.
- Both: the RA has prefixes with the A flag and also sets the M flag, or the other configuration (O) flag, which tells the hosts to get other settings, such as DNS servers, from DHCPv6.
With stateless autoconfiguration, IPv6 hosts configure themselves without a protocol such as DHCP. It is called stateless because the router keeps no state about the hosts. It is a simple, robust and effective method.
RFC 4862 defines address autoconfiguration for multicast-capable interfaces only.
RouterOS uses RADVD to send information about the link to all nodes on the link at regular intervals. The information is carried in an ICMPv6 router advertisement packet, which includes:
- The IPv6 subnet prefix.
- The link-local address of the default router.
- Optional parameters, such as the link MTU, the default hop limit and the router lifetime.
A host uses the advertisement to configure its global IPv6 address and its default router. The global address is built from the advertised subnet prefix and an interface identifier, for example an EUI-64 identifier.
A host can ask for an advertisement right away by sending an ICMPv6 router solicitation packet. On Linux, the rtsol utility sends router solicitations. Mobile nodes should send router solicitations regularly.
Address states
An autoconfigured address is in one of these states:
tentative: the host checks that the address is unique, with duplicate address detection.preferred: the address is unique, and the node can send and receive unicast traffic with it. The RA message sets how long the address stays preferred (the preferred lifetime).deprecated: the preferred lifetime has expired. The address is still valid, but it is not used for new connections.invalid: the valid lifetime has expired. The node can no longer send or receive unicast traffic with the address.
The following diagram shows how the states follow each other and which lifetime ends each state:
flowchart LR T["Tentative"] -- "duplicate address detection passed" --> P["Preferred"] P -- "preferred lifetime expired" --> D["Deprecated"] D -- "valid lifetime expired" --> I["Invalid"]
Neighbor discovery
Neighbor Discovery (ND) uses messages and processes that determine the relationships between neighboring nodes. In IPv6, ND replaces the IPv4 Address Resolution Protocol (ARP), ICMP Router Discovery and ICMP Redirect, and adds more functions.
Hosts use ND to:
- Discover neighboring routers.
- Discover addresses, address prefixes and other configuration parameters.
Routers use ND to:
- Advertise their presence, host configuration parameters and on-link prefixes.
- Inform hosts of a better next-hop address for a specific destination.
Nodes use ND to:
- Resolve the link-layer address of a neighboring node to which an IPv6 packet is being forwarded, and notice when that address changes.
- Find out whether IPv6 packets can be sent to and received from a neighbor.
RFC 4861 defines five ND message types: Router Solicitation (RS), Router Advertisement (RA), Neighbor Solicitation (NS), Neighbor Advertisement (NA) and Redirect. The router handles them as follows, and the /ipv6/nd menu controls its RS replies and RAs:
- Router Solicitation (RS): the router listens for RS messages from hosts and replies with a Router Advertisement.
- Router Advertisement (RA): the router sends unsolicited RAs at regular intervals (
ra-interval) and also responds to the RS messages it receives. The content of the RA (prefixes, flags, lifetimes, MTU, timer values) comes from the/ipv6/ndsettings of the interface and from the/ipv6/nd/prefixentries. The/ipv6/ndlist has an entry for the interfaceall. An entry for a specific interface takes priority over theallentry on that interface. - Neighbor Solicitation (NS), not controlled by
/ipv6/nd: the router sends NS messages to resolve the link-layer addresses of its neighbors, and replies with a Neighbor Advertisement when it receives an NS for one of its own addresses on the interface (link-local, SLAAC or static). This includes duplicate address detection (DAD) for the addresses of the router. - Neighbor Advertisement (NA): sent in response to an NS, as described in the previous item.
The NS and NA messages between hosts are handled by the hosts themselves.
A router advertisement carries more than the prefix: the hop limit, the managed address configuration and other configuration flags, the router lifetime and preference, the reachable time and retransmit timer, the source link-layer address, the MTU, the DNS servers and the NAT64 prefix. They are all set per interface in /ipv6/nd, and the advertised prefixes in /ipv6/nd/prefix.
Examples
Stateless autoconfiguration example
A router has a global address on ether2 with advertise=yes, the default for a new /64 address:
[admin@MikroTik] > /ipv6/address/print where interface=ether2 and global
Flags: G - GLOBAL
Columns: ADDRESS, INTERFACE, VRF, ADVERTISE, VALID, PREFERRED
# ADDRESS INTERFACE VRF ADVERTISE VALID PREFERRED
1 G 2001:db8::2/64 ether2 main yes forever forever
Because of the advertise setting, the router added a dynamic /ipv6/nd/prefix entry, which it advertises on ether2:
[admin@MikroTik] > /ipv6/nd/prefix/print
Flags: D - DYNAMIC
0 D prefix=2001:db8::/64 6to4-interface=none interface=ether2 on-link=yes
autonomous=yes dhcp6-pd-preferred=no valid-lifetime=4w2d
preferred-lifetime=1w
On a Linux host that is directly connected to the router, an address appears. Its first 64 bits are the advertised prefix, and its last 64 bits are generated from the MAC address of the host:
atis@atis-desktop:~$ ip -6 addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qlen 1000
inet6 2001:db8::21a:4dff:fe56:1f4d/64 scope global dynamic
valid_lft 2588363sec preferred_lft 601163sec
inet6 fe80::21a:4dff:fe56:1f4d/64 scope link
valid_lft forever preferred_lft forever
The host received the 2001:db8::/64 prefix from the router and configured an address with it.
Address taken from a pool
When the address on the advertising interface is taken from a pool, the dynamic /ipv6/nd/prefix entry takes its lifetimes from that address, and the address takes them from the pool. The advertised value is the lower of the remaining address lifetime and the lifetime in /ipv6/nd/prefix/default, so a shorter default shortens the advertisement, and so does a delegated prefix with a shorter lifetime. Hosts then deprecate the prefix together with the delegated prefix, so they do not keep using an address whose prefix is gone.
The pool in this example holds a prefix delegated by the ISP. The router takes the LAN prefix from the pool and advertises it on the bridge that carries the local network:
/ipv6/dhcp-client/add interface=ether1 request=prefix \
pool-name=isp-pool pool-prefix-length=64
/ipv6/address/add address=::1/64 interface=-lan \
from-pool=isp-pool advertise=yes
[admin@MikroTik] > /ipv6/address/print where interface=-lan
Flags: D - DYNAMIC; G - GLOBAL, L - LINK-LOCAL
Columns: ADDRESS, FROM-POOL, INTERFACE, VRF, ADVERTISE, VALID
# ADDRESS FROM-POO INTERFACE VRF ADV VALID
0 G 2001:db8:7500::1/64 isp-pool -lan main yes 2d23h59m53s
1 DL fe80::8038:75ff:fe5d:9227/64 -lan main no
[admin@MikroTik] > /ipv6/nd/prefix/print
Flags: D - DYNAMIC
0 D prefix=2001:db8:7500::/64 6to4-interface=none interface=-lan
on-link=yes autonomous=yes dhcp6-pd-preferred=no valid-lifetime=2d23h59m53s
preferred-lifetime=2d16h47m53s
The advertised lifetimes count down in real time, each by its own remaining time. How the preferred lifetime relates to the valid one depends on the DHCPv6 server that delegated the prefix: a RouterOS DHCPv6 server offers a preferred lifetime of 90% of the lease time, another server may offer something else, and the advertisement passes on whatever arrived.
Advertising DNS servers
RADVD can also send DNS servers to the hosts:
/ipv6/nd/set [find where interface=all] \
dns=2001:db8::2 advertise-dns=yes
Or it can send the link-local address of the router itself as the DNS server, so that the hosts use the router as their DNS cache:
/ipv6/nd/set [find where interface=all] dns="" advertise-dns=self
A DNS server list and advertise-dns=self cannot be set together, so the command clears the list. For the router to answer the DNS queries of the hosts, enable allow-remote-requests in /ip/dns.
When you advertise specific servers, every RA also carries the link-local address of the router as a DNS server, with a lifetime of 0, which means that it is no longer valid. If the router advertised itself earlier (advertise-dns=self), this tells the hosts to stop using it. A client that handles RA DNS options correctly ignores this server, or removes it if it was in use.
The hosts need software that supports DNS servers in router advertisements. On Ubuntu and Debian Linux, the rdnssd package receives the advertised DNS servers:
mrz@bumba:/$ sudo apt-get install rdnssd
mrz@bumba:/$ cat /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 2001:db8::2
mrz@bumba:/$ ping6 www.mikrotik.com
PING www.mikrotik.com(2a02:610:7501:1000::2) 56 data bytes
64 bytes from 2a02:610:7501:1000::2: icmp_seq=1 ttl=61 time=2.11 ms
64 bytes from 2a02:610:7501:1000::2: icmp_seq=2 ttl=61 time=1.33 ms
^C
--- www.mikrotik.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 1.334/1.725/2.117/0.393 ms
mrz@bumba:/$