$Id: INTRO,v 1.2 1997/01/16 22:28:54 lf Exp $

This is a small introduction to automatic address configuration with radvd
I wrote for the IPv6 FAQ/HOWTO.


IPv6 has a lot more support for autoconfiguration than IPv4. But
for this autoconfiguration to work on the hosts of a network, the
routers of the local network have to run a program which answers
the autoconfiguration requests of the hosts.

On Linux this program is called radvd, which stands for Router
ADVertisement Daemon. This daemon listens to router solicitations (RS) 
and answers with router advertisement (RA). Furthermore unsolicited
RAs are also send from time to time.

These RAs contain information, which is used by hosts to configure
their interfaces. This information includes address prefixes, the MTU of 
the link and information about default routers.

Of course the routers can't autoconfigure themself, so the information
on the routers has to be provided by the administrator of the system.
This is done by manually configuring the interfaces and routes and by
configuring the router advertisement daemon.

A small and simple configuration file for radvd might look like this:

---8<-------------------------------------------------------------------- 
interface eth0 {
        AdvSendAdvert on;
        prefix 5f04:f900:c2dd:1400:8000::0/80 {
                AdvOnLink on;
                AdvAutonomous on;
        };
};
---8<-------------------------------------------------------------------- 

It says that radvd should advertise (AdvSendAdvert on;) the prefix
5f04:f900:c2dd:1400:8000::0 which has a lenght of 80 on the interface eth0.
Also the prefix should be marked as autonomous (AdvAutonomous on;) and as
on-link (AdvOnLink on;). All the other options are left on their default
values.

Autonomous means that the prefix can be used for automatic address
configuration and on-link means that the hosts can assume that all the hosts
which use this prefix are reachable via the interface on which the host
received this RA.

The prefix wasn't choosen randomly for this example, but was determined
according to the rules outlined in RFC 1897 (IPv6 Testing Address
Allocation). Furthermore the prefix length is also not freely choosen but is
determined by the network media used.
For ethernet the prefix lenght is 80 because the prefix combined with the
ethernet hardware address, which is 48 bit long, yields a full 128 bit IPv6
address. See RFC 1971 (IPv6 Stateless Address Autoconfiguration) and RFC 
1972 (A Method for the Transmission of IPv6 Packets over Ethernet Networks)
for details.

For more information on configuring radvd please look at the documentation
which is included in the radvd distribution.

So when an interface on a hosts is UPed and a RA is received, the host 
can configure an address on the interface by using the prefix and 
appending the ethernet hardware address (also called link-layer token),
for example:

  announced prefix:   5f04:f900:c2dd:1400:8000:0000:0000:0000
  link-layer token:                            0800:0040:1726
  configured address: 5f04:f900:c2dd:1400:8000:0800:0040:1726

The host can also choose a default router by examining the RA.
This means that an IPv6-only host merely has to UP its interfaces and
the rest works automatically.

So now we've configured radvd, but we still need to configure the interfaces
and set the routes (on the router). For simplicities sake we'll assume
that there's only one interface and that the router communicates via
tunnels with the "outer world".

Below is an example shell script which sets up IPv6 on a router. It's
actually identical to the file I use on my router... :)

As you can see it adds the address and the route manually and also
configures a IPv6-over-IPv4 tunnel. 

/etc/init.d/functions is a small collection of helper functions and is only
needed for the killproc function which kills radvd on "stop". The
directory /usr/ipv6/sbin is where I've installed the new IPv6 capable
net-tools and radvd. It is added to the beginning of the PATH, so that the
IPv6 capable tools are found before the old ones.

The script assumes that the "normal" interfaces (e.g. eth0) are already
configured and UP (most certainly for IPv4). 

---8<-------------------------------------------------------------------- 
#! /bin/sh

PATH=/usr/ipv6/sbin:/usr/ipv6/bin:/bin:/usr/bin:/sbin:/usr/sbin
export PATH

. /etc/init.d/functions

case "$1" in
  start)
        # enable forwarding (this makes us a router)
        echo 1 >/proc/sys/net/ipv6/ipv6_forwarding 
        # get IPv6-over-IPv4 tunnel up (enables automatic
        # tunneling to 0::0/96)
        ifconfig sit0 up
        # configure the local interface
        ifconfig eth0  add 5f04:f900:c2dd:1400:8000:0080:ad1c:22ca/80
        route -A inet6 add 5f04:f900:c2dd:1400:8000::0/80 dev eth0
        # setup a tunnel to UL
	# (if you have a tunnel to the 6bone or another IPv6 capable
	# host, configure it here...)
        ifconfig sit0 tunnel 0::192.67.76.128
	# ^--- this command creates sit1
        ifconfig sit1 up
        route -A inet6 add 5f00::0/8 gw 0::192.67.76.128 dev sit1
	# start router advertisement daemon
	radvd
    ;;
  stop)
	# terminate radvd
	killproc radvd
	# down sit0
        ifconfig sit0 down
    ;;
  *)
    echo "Usage: /etc/init.d/ipv6 {start|stop}"
    exit 1
esac

exit 0
---8<-------------------------------------------------------------------- 
