Configuring DHCP for IPv6

Configuring DHCP for IPv6

Problem

You want to use the DHCP services built into IOS for distributing IPv6 address information.

Solution

Just as you can configure a router to act as a DHCP server for IPv4 addresses, Cisco's IOS also includes an IPv6 DHCP server function:

Router1#configure terminal 
Enter configuration commands, one per line. End with CNTL/Z.
Router1(config)#ipv6 dhcp database flash:/DHCPv6-db
Router1(config)#ipv6 local pool VLAN10-pool AAAA:1::/48 64
Router1(config)#ipv6 local pool VLAN11-pool AAAA:11::/48 64
Router1(config)#ipv6 dhcp pool DHCPv6POOL
Router1(config-dhcp)#prefix-delegation AAAA:1::23F6:33BA/64 00030001000E84244E70
Router1(config-dhcp)#prefix-delegation pool VLAN10-pool
Router1(config-dhcp)#dns-server AAAA:1::19
Router1(config-dhcp)#domain-name oreilly.com
Router1(config-dhcp)#exit
Router1(config)#interface FastEthernet0/0
Router1(config-if)#ipv6 address AAAA:1::1/64
Router1(config-if)#ipv6 address FE80::1 link-local
Router1(config-if)#ipv6 nd managed-config-flag
Router1(config-if)#ipv6 nd other-config-flag
Router1(config-if)#ipv6 dhcp server DHCPv6POOL rapid-commit preference 1 allow-hint
Router1(config-if)#exit
Router1(config)#end
Router1#

Discussion

DHCP is currently available only on certain higher end routers. The rationale is probably that DHCP for IPv6 will be used primarily for WAN or wireless links in service provider networks, and that customers will continue to use IPv4 internally. However, experience with IPv4 shows that most large networks prefer to deploy DHCP services on dedicated servers because they have more user-friendly management tools and because the memory demands of maintaining dynamic addressing tables for a very large network are rather onerous for a router. Further, dedicated commercial DHCP servers tend to be deployed in clusters to ensure that a failure of any single server will not cause a loss of dynamic address information.

In IPv4 environments, DHCP servers tend to be deployed on routers only for smaller sites where a dedicated server was considered overkill. If a small network wants to deploy IPv6 with DHCP internally, it would be far more convenient to be able to run it on an existing integrated services router. So it is unfortunate that Cisco has opted to only provide DHCP server functionality on higher end routers, where we believe it is less likely to be required.

In our configuration example, the first DHCP command just defines where the router will hold its DHCP database:

Router1(config)#ipv6 dhcp database flash:/DHCPv6-db

In this case, we have opted to put this database into the named file on the flash partition. However, we could have also opted to store this information on a server as follows:

Router1(config)#ipv6 dhcp database tftp://192.168.100.15/DHCPv6-db

Next we defined an address pool called VLAN10-pool and assigned it to a DHCP pool:

Router1(config)#ipv6 local pool VLAN10-pool AAAA:1::/48 64
Router1(config)#ipv6 dhcp pool DHCPv6POOL
Router1(config-dhcp)#prefix-delegation pool VLAN10-pool
Router1(config-dhcp)#dns-server AAAA:1::19
Router1(config-dhcp)#domain-name oreilly.com
Router1(config-dhcp)#exit

You can only assign one address pool to each DHCP pool. So if you intend to support several different networks with your router's DHCP server, you will need to create a distinct DHCP pool for each one.

In this example, all addresses are assigned dynamically from this local pool prefix. However, you can also assign addresses statically by associating the IPv6 address with the DHCP Unique Identifier (DUID), as follows:

Router1(config)#ipv6 dhcp pool DHCPv6POOL
Router1(config-dhcp)#prefix-delegation AAAA:1::23F6:33BA/64 00030001000E84244E70

The DUID value for a device is a global value for the entire device that is uniquely derived from its first MAC address on the device:

Router1#show ipv6 dhcp
This device's DHCPv6 unique identifier(DUID): 00030001000E84244E70
Router1#show interface FastEthernet0/0 | include Hardware
Hardware is Gt96k FE, address is 000e.8424.4e70 (bia 000e.8424.4e70)
Router1#

You can then look at your DHCP pools by using the following command:

Router1#show ipv6 dhcp pool DHCPv6POOL
DHCPv6 pool: DHCPv6POOL
Static bindings:
Binding for client 00030001000E84244E70
IA PD: IA ID not specified
Prefix: AAAA:1::23F6:33BA/64
preferred lifetime 604800, valid lifetime 2592000
Prefix pool: VLAN10-pool
preferred lifetime 604800, valid lifetime 2592000
DNS server: AAAA:1::19
Domain name: oreilly.com
Active clients: 0
Router1#

This output shows a single static binding in the pool as well as a dynamic prefix pool. It also shows any additional DHCP options that are being set; in this case, you can see the DNS server address and the domain name.

Finally, the last step in setting up IPv6 DHCP on a router is to associate a DHCP pool with an interface:

Router1(config)#interface FastEthernet0/0
Router1(config-if)#ipv6 nd managed-config-flag
Router1(config-if)#ipv6 nd other-config-flag
Router1(config-if)#ipv6 dhcp server DHCPv6POOL rapid-commit preference 1 allow-hint
Router1(config-if)#exit

There are three important commands here. First, when you set the ipv6 nd managed-config-flag command, the router sends its IPv6 Router Advertisement (RA) packets with a bit that tells any connected devices to use DHCP for dynamic address configuration. Similarly, the ipv6 nd other-config-flag command sets another flag in the RA packet that tells devices to get other information besides the address via DHCP. This includes things like DNS server and domain name.

Finally, we associate the DHCP server pool with the interface by using the ipv6 dhcp server command.

See Also