Manual:IPv6/DHCP Client

From MikroTik Wiki
Jump to navigation Jump to search

Applies to RouterOS: v5.9 +


DHCP-client in RouterOS is capable of being a DHCPv6-client and DHCP-PD client. So it is able to get a prefix from DHCP-PD server as well as DHCPv6 stateful address from DHCPv6 server.

Quick setup example

This simple example demonstrates how to enable dhcp client to receive IPv6 prefix and add it to the pool.

/ipv6 dhcp-client add request=prefix pool-name=test-ipv6 pool-prefix-length=64 interface=ether13 

Detailed print should show status of the client and we can verify if prefix is received

[admin@x86-test] /ipv6 dhcp-client> print detail 
Flags: D - dynamic, X - disabled, I - invalid 
 0    interface=bypass pool-name="test-ipv6" pool-prefix-length=64 status=bound 
      prefix=2001:db8:7501:ff04::/62  expires-after=2d23h11m53s request=prefix

Notice that server gave us prefix 2a02:610:7501:ff04::/62 . And it should be also added to ipv6 pools

[admin@MikroTik] /ipv6 pool> print 
Flags: D - dynamic 
 #   NAME                         PREFIX                     REQUEST          PREFIX-LENGTH
 0 D test-ipv6                    2001:db8:7501:ff04::/62     prefix                     64

It works! Now you can use this pool, for example, for pppoe clients.


Sub-menu: /ipv6 dhcp-client

Property Description
add-default-route (yes | no; Default: no) Whether to add default IPv6 route after client connects.
comment (string; Default: ) Short description of the client
disabled (yes | no; Default: no)
interface (string; Default: ) Interface on which DHCPv6 client will be running.
pool-name (string; Default: ) Name of the IPv6 pool in which received IPv6 prefix will be added
pool-prefix-length (string; Default: ) Prefix length parameter that will be set for IPv6 pool in which received IPv6 prefix is added. Prefix length must be greater than the length of received prefix, otherwise prefix-length will be set to received prefix length + 8 bits.
prefix-hint (string; Default: ) Include a preferred prefix length.
request (prefix, address; Default: ) to choose if the DHCPv6 request will ask for the address or the IPv6 prefix, or both.
script (string; Default: ) Run this script on the dhcp-client status change. Available variables:
  • pd-valid - if the prefix is acquired by the client;
  • pd-prefix - the prefix acquired by the client if any;
  • na-valid - if the address is acquired by the client;
  • na-address - the address acquired by the client if any.
  • options - array of received options (only ROSv7)
use-peer-dns (yes | no; Default: yes) Whether to accept the DNS settings advertised by the IPv6 DHCP Server.


It is possible to add a script that will be executed when a prefix or an address is acquired and applied or expires and is removed using DHCP client. There are separated sets of variables that will have the value set by the client depending on prefix or address status change as the client can acquire both and each of them can have a different effect on the router configuration.

Available variables for dhcp-client

  • pd-valid - value - 1 or 0 - if prefix is acquired and it is applied or not
  • pd-prefix - value ipv6/num (ipv6 prefix with mask) - the prefix inself
  • na-valid - value - 1 or 0 - if address is acquired and it is applied or not
  • na-address - value - ipv6 address - the address


Command /ipv6 dhcp-client print detail will show current status of dhcp client and read-only properties listed in table below:

Property Description
duid (string) Auto generated DUID that is sent to the server. DUID is generated using one of the MAC addresses available on the router.
request (list) specifies what was requested - prefix, address or both.
dynamic (yes | no)
expires-after (time) Time when the IPv6 prefix expires (specified by the DHCPv6 server).
invalid (yes | no) Shows whether configuration is invalid.
prefix (IPv6 prefix) Shows received IPv6 prefix from DHCPv6-PD server
status (stopped | searching | requesting... | bound | renewing | rebinding | error | stopping) Shows the status of DHCPv6 Client:
  • stopped - dhcpv6 client is stopped
  • searching - sending "solicit" and trying to get "advertise"
  • requesting - sent "request" waiting for "reply"
  • bound - received "reply". Prefix assigned.
  • renewing - sent "renew", waiting for "reply"
  • rebinding - sent "rebind", waiting for "reply"
  • error - reply was not received in time or some other error ocurred.
  • stopping - sent "release"

To determine what IAID will be used, convert internal ID of an interface on which DHCP client is running from hex to decimal.

For example, DHCP client is running on interface pppoe-out1. To get internal ID use following command

[admin@t36] /interface> :put [find name="pppoe-out1"]

Now convert hex value 15 to decimal and you get IAID=21

Menu specific commands

Property Description
release (numbers) Release current binding and restart DHCPv6 client
renew (numbers) Renew current leases. If the renew operation was not successful, client tries to reinitialize lease (i.e. it starts lease request procedure (rebind) as if it had not received an IP address yet)

Application Examples

Use received prefix for local RA

Consider following setup:


  • ISP is routing prefix 2001:DB8::/62 to the router R1
  • Router R1 runs DHCPv6 server to delegate /64 prefixes to the customer routers CE1 CE2
  • DHCP client on routers CE1 and CE2 receives delegated /64 prefix from the DHCP server (R1).
  • Client routers uses received prefix to set up RA on the local interface



/ipv6 route 
add gateway=fe80::1:1%to-ISP

/ipv6 pool
add name=myPool prefix=2001:db8::/62 prefix-length=64

/ipv6 dhcp-server
add address-pool=myPool disabled=no interface=to-CE-routers lease-time=3m name=server1


/ipv6 dhcp-client
add interface=to-R1 request=prefix pool-name=my-ipv6

/ipv6 address
add address=::1/64 from-pool=my-ipv6 interface=to-clients advertise=yes


/ipv6 dhcp-client
add interface=to-R1 request=prefix pool-name=my-ipv6

/ipv6 address
add address=::1/64 from-pool=my-ipv6 interface=to-clients advertise=yes

Check the status

After configuration is complete we can verify that each CE router received its own prefix

On server:

[admin@R1] /ipv6 dhcp-server binding> print 
Flags: X - disabled, D - dynamic 
 #   ADDRESS                                     DUID               IAID SERVER         STATUS 
 1 D 2001:db8:1::/64                             0019d1393536        566 server1        bound
 2 D 2001:db8:2::/64                             0019d1393535        565 server1        bound 

On client:

[admin@CE1] /ipv6 dhcp-client> print 
Flags: D - dynamic, X - disabled, I - invalid 
 #    INTERFACE           STATUS        REQUEST       PREFIX                                     
 0    to-R1               bound         prefix        2001:db8:1::/64  

[admin@CE1] /ipv6 dhcp-client> /ipv6 pool print 
Flags: D - dynamic 
 #   NAME                 PREFIX                              PREFIX-LENGTH
 0 D my-ipv6              2001:db8:1::/64                                64

We can also see that IPv6 address was automatically added from the prefix pool:

[admin@CE1] /ipv6 address> print 
Flags: X - disabled, I - invalid, D - dynamic, G - global, L - link-local 
 #    ADDRESS                                     FROM-POOL INTERFACE     ADVERTISE
 0  G 2001:db8:1::1/64                                      to-clients         yes      

And pool usage shows that 'Address' is allocating the pool

[admin@CE1] /ipv6 pool used> print 
POOL         PREFIX                                      OWNER         INFO        
my-ipv6      2001:db8:1::/64                             Address       to-clients   

[ Top | Back to Content ]