Unlike IPv4, which uses DHCP for configuration, IPv6 uses the Neighbor Discovery Protocol to configure addresses and gateways. Unfortunately, originally the protocol had no means of providing addresses of DNS servers to clients, making it necessary to use
DHCPv6 for that purpose. Modern Linux and Mac OS X machines are able to use the IPv6 Router Advertisement Options for DNS Configuration (RFC 6106), but to my knowledge, Windows clients are not able at the moment. Here’s how to configure a Linux router using
radvd and the ISC DHCP daemon.
Network Configuration and Packet Forwarding
The following configuration has been tested with Ubuntu Server 12.04.2 LTS. For the purposes of this article, the /etc/network/interfaces file looks like this:
# eth0 to Internet iface eth0 inet6 static address 2001:db8:0:1::2 netmask 64 gateway 2001:db8:0:1::1 # eth1 to internal network iface eth1 inet6 static address 2001:db8:0:2::1 netmask 64
Outbound interface is eth0, and inbound interface eth1.
First, to enable IPv6 packet forwarding, put this in your /etc/sysctl.conf:
net.ipv6.conf.all.forwarding=1And run this to make the change in the running kernel:
sudo sysctl -w net.ipv6.conf.all.forwarding=1
IPv6 Router Advertisement Daemon
Install the router advertisement daemon or radvd with:
sudo apt-get install radvd
Create file /etc/radvd.conf and put your internal interface and prefix there:
interface eth1 { AdvSendAdvert on; prefix 2001:db8:0:2::/64 { }; };
You can now start the daemon with
sudo service radvd start
That will enable router advertisements on the internal interface. See example configuration files under /usr/share/doc/radvd/examples. See also manual pages for radvd(8) and radvd.conf(5) for more information. The radvdump(8) is a useful tool for watching
live router advertisement traffic.
The RDNSS and DNSSL Options
Below is an example radvd.conf which also advertises DNS servers with RDNSS and DNS search path with DNSSL, both of which are specified in RFC 6106. This will work with Linux and Mac OS X clients, but unfortunately Windows does not seem to support it.
interface eth1 { AdvSendAdvert on; MinRtrAdvInterval 3; MaxRtrAdvInterval 10; prefix 2001:db8:0:1::/64 { }; RDNSS 2001:db8:0:1::a 2001:db8:0:1::b { AdvRDNSSLifetime 10; }; DNSSL koo.fi { AdvDNSSLLifetime 10; }; };
Restart radvd.
DHCPv6
To support Windows, we must install a DHCPv6 compliant DHCP server, such as a recent version of the ISC DHCP daemon:
sudo apt-get install isc-dhcp-server
Create file /etc/dhcp/dhcpd6.conf and put something like this in there:
ddns-update-style none; default-lease-time 7200; max-lease-time 86400; subnet6 2001:db8:0:2::/64 { range6 2001:db8:0:2::1000 2001:db8:0:2::1fff; option dhcp6.name-servers 2001:db8:0:1::a, 2001:db8:0:1::b; option dhcp6.domain-search "koo.fi"; }
We configured a pool of 4096 addresses here (::1000-1fff), plus DNS servers and search path.
Start the dhcpv6 server:
sudo service isc-dhcp-server6 start
If it fails, see /var/log/syslog for error messages. Finally, if everything went ok, add to default runlevels:
sudo update-rc.d isc-dhcp-server6 defaults
Now you should be able to get an IPv6 address and DNS servers with a DHCP client.
原文地址:
http://koo.fi/blog/2013/03/20/linux-ipv6-router-radvd-dhcpv6/