DHCP Client and Server Document revision 2.8 (December 12, 2007, 11:43 GMT) This document applies to V3.0

Table of Contents Table of Contents Summary Quick Setup Guide Specifications Description Additional Documents DHCP Client Setup Description Property Description Command Description Notes Example DHCP Server Setup Description Property Description Notes Example Store Leases on Disk Description Property Description DHCP Networks Property Description Notes DHCP Server Leases Description Property Description Command Description Notes Example DHCP Alert Description Property Description Notes DHCP Option Description Property Description Notes Example DHCP Relay Description Property Description

Page 1 of 18 Copyright 1999-2007, MikroTik. All rights reserved. Mikrotik, RouterOS and RouterBOARD are trademarks of Mikrotikls SIA. Other trademarks and registred trademarks mentioned herein are properties of their respective owners.

Notes Example Question&Answer-Based Setup Command Description Notes Example Dynamic Addressing, using DHCP-Relay IP Address assignment, using FreeRADIUS Server

General Information Summary                  

  ! "#$ %     &     %    %   "' ()*) +     ,



     -./0 10     



#       1  

       !.        &     ! "#$ $%            $  $% !     

Quick Setup Guide  2%      %  1$&    1    ! "#$



$%    $&,

1.

    %

/ip pool add name=dhcp-pool ranges=172.16.0.10-172.16.0.20

2.

.                            ,

/ip dhcp-server network add address=172.16.0.0/12 gateway=172.16.0.1

3.

'  0    &,

/ip dhcp-server add interface=wlan1 address-pool=dhcp-pool



$%              &0   &

1.

.    ,

/ip dhcp-client add interface=wlan1 use-peer-dns=yes \ add-default-route=yes disabled=no

2.

   &    ,

Page 2 of 18 Copyright 1999-2007, MikroTik. All rights reserved. Mikrotik, RouterOS and RouterBOARD are trademarks of Mikrotikls SIA. Other trademarks and registred trademarks mentioned herein are properties of their respective owners.

[admin@Server] ip dhcp-client> print detail Flags: X - disabled, I - invalid 0 interface=wlan1 add-default-route=yes use-peer-dns=yes status=bound address=172.16.0.20/12 gateway=172.16.0.1 dhcp-server=192.168.0.1 primary-dns=159.148.147.194 expires-after=2d23:58:52 [admin@Server] ip dhcp-client>

Specifications Packages required: dhcp License required: level1 Home menu level: /ip dhcp-client, /ip dhcp-server, /ip dhcp-relay Standards and Technologies: DHCP

Description   % &                           &      3 45 %0    1  3 46 %      &&        %            7          8         

Additional Documents •

$        



  1#9#



$  '.:

DHCP Client Setup Home menu level: /ip dhcp-client

Description  ! "#$          ; 1          &    %       %  0 0   0  /$ &     / &  .        &     %&       %                      $            0        &          %        0               &

Property Description add-default-route (yes | no; default: yes) - whether to add the default route to the gateway specified by the DHCP server address (read-only: IP addressnetmask) - IP address and netmask, which is assigned to DHCP Client from the Server Page 3 of 18 Copyright 1999-2007, MikroTik. All rights reserved. Mikrotik, RouterOS and RouterBOARD are trademarks of Mikrotikls SIA. Other trademarks and registred trademarks mentioned herein are properties of their respective owners.

client-id (text) - corresponds to the settings suggested by the network administrator or ISP. Commonly it is set to the client's MAC address, but it may as well be any text string dhcp-server (read-only: IP address) - IP address of the DHCP server expires-after (read-only: time) - time, when the lease expires (specified by the DHCP server) gateway (read-only: IP address) - IP address of the gateway which is assigned by DHCP server host-name (text) - the host name of the client as sent to a DHCP server interface (name) - any Ethernet-like interface (this includes wireless and EoIP tunnels) on which the client searches for a DHCP server primary-dns (read-only: IP address) - IP address of the primary DNS server, assigned by the DHCP server primary-ntp (read-only: IP address) - IP address of the primary NTP server, assigned by the DHCP server secondary-dns (read-only: IP address) - IP address of the secondary DNS server, assigned by the DHCP server secondary-ntp (read-only: IP address) - IP address of the secondary NTP server, assigned by the DHCP server status (read-only: bound | error | rebinding... | renewing... | requesting... | searching... | stopped) shows the status of DHCP slient use-peer-dns (yes | no; default: yes) - whether to accept the DNS settings advertized by DHCP server (they will override the settings put in the /ip dns submenu) use-peer-ntp (yes | no; default: yes) - whether to accept the NTP settings advertized by DHCP server (they will override the settings put in the /system ntp client submenu)

Command Description release - release current binding and restart DHCP client renew - 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)

Notes   %%   %0  

DHCP Server Setup Home menu level: /ip dhcp-server

Description   %%   & &   ; 1    ! "#$ 

& %%       &   =      7  0   0  0 /$1&    9/$1&   9       %          &  0    %   %       &  %2     &   =          &

Property Description delay-threshold (time; default: none) - if secs field in DHCP packet is smaller than delay-threshold, then this packet is ignored dhcp-server (text) - list of DHCP servers' IP addresses which should the DHCP requests be forwarded to interface (name) - interface name the DHCP relay will be working on local-address (IP address; default: 0.0.0.0) - the unique IP address of this DHCP relay needed for DHCP server to distinguish relays: • 0.0.0.0 - the IP address will be chosen automatically name (name) - descriptive name for relay

Notes       %  &   %1& 0  >       =     &

Example                 & =        &, [admin@MikroTik] ip dhcp-relay> add name=relay interface=ether1 \ \... dhcp-server=10.0.0.1 disabled=no [admin@MikroTik] ip dhcp-relay> print Flags: X - disabled, I - invalid # NAME INTERFACE DHCP-SERVER LOCAL-ADDRESS 0 relay ether1 10.0.0.1 0.0.0.0 [admin@MikroTik] ip dhcp-relay>

Question&Answer-Based Setup Command name: /ip dhcp-server setup

Questions

Page 13 of 18 Copyright 1999-2007, MikroTik. All rights reserved. Mikrotik, RouterOS and RouterBOARD are trademarks of Mikrotikls SIA. Other trademarks and registred trademarks mentioned herein are properties of their respective owners.

addresses to give out (text) - the pool of IP addresses DHCP server should lease to the clients dhcp address space (IP addressnetmask; default: 192.168.0.0/24) - network the DHCP server will lease to the clients dhcp relay (IP address; default: 0.0.0.0) - the IP address of the DHCP relay between the DHCP server and the DHCP clients dhcp server interface (name) - interface to run DHCP server on dns servers (IP address) - IP address of the appropriate DNS server to be propagated to the DHCP clients gateway (IP address; default: 0.0.0.0) - the default gateway of the leased network lease time (time; default: 3d) - the time the lease will be valid

Notes %              %& = 0  &    =      $ =   %%        2%0         setup Select interface to run DHCP server on dhcp server interface: ether1 Select network for DHCP addresses dhcp address space: 10.0.0.0/24 Select gateway for given network gateway for dhcp network: 10.0.0.1 Select pool of ip addresses given out by DHCP server addresses to give out: 10.0.0.2-10.0.0.254 Select DNS servers dns servers: 159.148.60.20 Select lease time lease time: 3d [admin@MikroTik] ip dhcp-server>

 ?             &, [admin@MikroTik] ip dhcp-server> print Flags: X - disabled, I - invalid # NAME INTERFACE RELAY 0 dhcp1 ether1 0.0.0.0

ADDRESS-POOL LEASE-TIME ADD-ARP dhcp_pool1 3d no

[admin@MikroTik] ip dhcp-server> network print # ADDRESS GATEWAY DNS-SERVER 0 10.0.0.0/24 10.0.0.1 159.148.60.20

WINS-SERVER

DOMAIN

[admin@MikroTik] ip dhcp-server> /ip pool print # NAME RANGES

Page 14 of 18 Copyright 1999-2007, MikroTik. All rights reserved. Mikrotik, RouterOS and RouterBOARD are trademarks of Mikrotikls SIA. Other trademarks and registred trademarks mentioned herein are properties of their respective owners.

0 dhcp_pool1

10.0.0.2-10.0.0.254

[admin@MikroTik] ip dhcp-server>

Application Examples Dynamic Addressing, using DHCP-Relay -      & &   print Flags: X - disabled, I - invalid, D - dynamic # ADDRESS NETWORK BROADCAST 0 192.168.0.1/24 192.168.0.0 192.168.0.255 1 10.1.0.2/24 10.1.0.0 10.1.0.255 Public [admin@DHCP-Server] ip address>

INTERFACE To-DHCP-Relay

   ,&-./, [admin@DHCP-Relay] ip address> print Flags: X - disabled, I - invalid, D - dynamic # ADDRESS NETWORK BROADCAST 0 192.168.0.1/24 192.168.0.0 192.168.0.255 1 192.168.1.1/24 192.168.1.0 192.168.1.255 2 192.168.2.1/24 192.168.2.0 192.168.2.255 [admin@DHCP-Relay] ip address>

INTERFACE To-DHCP-Server Local1 Local2

 % (  $&  ,&-.0   ( % '  *+ )   *+ , /ip pool add name=Local1-Pool ranges=192.168.1.11-192.168.1.100 /ip pool add name=Local1-Pool ranges=192.168.2.11-192.168.2.100 [admin@DHCP-Server] ip pool> print # NAME 0 Local1-Pool 1 Local2-Pool [admin@DHCP-Server] ip pool>

RANGES 192.168.1.11-192.168.1.100 192.168.2.11-192.168.2.100

  $&, /ip dhcp-server add interface=To-DHCP-Relay relay=192.168.1.1 \ address-pool=Local1-Pool name=DHCP-1 disabled=no /ip dhcp-server add interface=To-DHCP-Relay relay=192.168.2.1 \ address-pool=Local2-Pool name=DHCP-2 disabled=no [admin@DHCP-Server] ip dhcp-server> print Flags: X - disabled, I - invalid # NAME INTERFACE RELAY 0 DHCP-1 To-DHCP-Relay 192.168.1.1 1 DHCP-2 To-DHCP-Relay 192.168.2.1 [admin@DHCP-Server] ip dhcp-server>

ADDRESS-POOL LEASE-TIME ADD-ARP Local1-Pool 3d00:00:00 Local2-Pool 3d00:00:00

  %& , /ip dhcp-server network add address=192.168.1.0/24 gateway=192.168.1.1 \ dns-server=159.148.60.20 /ip dhcp-server network add address=192.168.2.0/24 gateway=192.168.2.1 \ dns-server 159.148.60.20 [admin@DHCP-Server] ip dhcp-server network> print # ADDRESS GATEWAY DNS-SERVER 0 192.168.1.0/24 192.168.1.1 159.148.60.20 1 192.168.2.0/24 192.168.2.1 159.148.60.20 [admin@DHCP-Server] ip dhcp-server network>

WINS-SERVER

DOMAIN

   ,&-.0    /  print Flags: X - disabled, I - invalid # NAME INTERFACE

DHCP-SERVER

LOCAL-ADDRESS

Page 16 of 18 Copyright 1999-2007, MikroTik. All rights reserved. Mikrotik, RouterOS and RouterBOARD are trademarks of Mikrotikls SIA. Other trademarks and registred trademarks mentioned herein are properties of their respective owners.

0 Local1-Relay Local1 1 Local2-Relay Local2 [admin@DHCP-Relay] ip dhcp-relay>

192.168.0.1 192.168.0.1

192.168.1.1 192.168.2.1

IP Address assignment, using FreeRADIUS Server -              0    ".3$ &

9     &   '".3$ F      % ,  , 00:0B:6B:31:02:4B Auth-Type := Local, Password == "" Framed-IP-Address = 192.168.0.55

     client 172.16.0.1 { secret = MySecret shortname = Server }

  "    "#$, /radius add service=dhcp address=172.16.0.2 secret=MySecret [admin@DHCP-Server] radius> print detail Flags: X - disabled 0 service=dhcp called-id="" domain="" address=172.16.0.2 secret="MySecret" authentication-port=1812 accounting-port=1813 timeout=00:00:00.300 accounting-backup=no realm="" [admin@DHCP-Server] radius>

$%  $&,

1.

   %, Page 17 of 18 Copyright 1999-2007, MikroTik. All rights reserved. Mikrotik, RouterOS and RouterBOARD are trademarks of Mikrotikls SIA. Other trademarks and registred trademarks mentioned herein are properties of their respective owners.

/ip pool add name=Radius-Clients ranges=192.168.0.11-192.168.0.100

2.

.   &,

/ip dhcp-server add address-pool=Radius-Clients use-radius=yes interface=Local \ disabled=no

3.

   ,

/ip dhcp-server network add address=192.168.0.0/24 gateway=192.168.0.1 \ dns-server=159.148.147.194,159.148.60.20

/     !.  1 212131 1)2    &   *+ 

Page 18 of 18 Copyright 1999-2007, MikroTik. All rights reserved. Mikrotik, RouterOS and RouterBOARD are trademarks of Mikrotikls SIA. Other trademarks and registred trademarks mentioned herein are properties of their respective owners.