Manual:IP/DHCP Server: Difference between revisions

From MikroTik Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 145: Line 145:
<p><b>Sub-menu:</b> <code>/ip dhcp-server config</code></p>
<p><b>Sub-menu:</b> <code>/ip dhcp-server config</code></p>
<p>
<p>
Leases are always stored on disk on graceful shutdown and reboot. If they would be saved on disk on every lease change, a lot of disk writes would happen. There are no problems if it happens on a hard drive, but is very bad for Compact Flash (especially, if lease times are very short). To minimize writes on disk, all changes are saved on disk every store-leases-disk seconds. If this time will be very short (immediately), then no changes will be lost even in case of hard reboots and power losts. But, on CF there may be too many writes in case of short lease times (as in case of hotspot). If this time will be very long (never), then there will be no writes on disk, but information about active leases may be lost in case of power loss. In these cases dhcp server may give out the same ip address to another client, if first one will not respond to ping requests.
<table class="styled_table">
<tr>
    <td><var><b>store-leases-disk</b></var> (<em>time | immediately | never</em>; Default: <b>5min</b>)</td>
    <td>How frequently lease changes should be stored on disk</td>
</tr>
</table>
</p>
</p>


Line 150: Line 158:
<p><b>Sub-menu:</b> <code>/ip dhcp-server network</code></p>
<p><b>Sub-menu:</b> <code>/ip dhcp-server network</code></p>
<p>
<p>
<table class="styled_table">
<tr>
  <th width="40%">Property</th>
  <th >Description</th>
</tr>
<tr>
    <td><var><b>address</b></var> (<em>IP/netmask</em>; Default: <b></b>)</td>
    <td>the network DHCP server(s) will lend addresses from</td>
</tr>
<tr>
    <td><var><b>boot-file-name</b></var> (<em>string</em>; Default: <b></b>)</td>
    <td>Boot file name</td>
</tr>
<tr>
    <td><var><b>dhcp-option</b></var> (<em>string</em>; Default: <b></b>)</td>
    <td>Add additional DHCP options from [[#Options | option list]].</td>
</tr>
<tr>
    <td><var><b>dns-server</b></var> (<em>string</em>; Default: <b></b>)</td>
    <td>the DHCP client will use these as the default DNS servers. Two comma-separated DNS servers can be specified to be used by DHCP client as primary and secondary DNS servers</td>
</tr>
<tr>
    <td><var><b>domain</b></var> (<em>string</em>; Default: <b></b>)</td>
    <td>The DHCP client will use this as the 'DNS domain' setting for the network adapter.</td>
</tr>
<tr>
    <td><var><b>gateway</b></var> (<em>IP</em>; Default: <b>0.0.0.0</b>)</td>
    <td>The default gateway to be used by [[DHCP Client]].</td>
</tr>
<tr>
    <td><var><b>netmask</b></var> (<em>integer: 0..32</em>; Default: <b>0</b>)</td>
    <td>The actual network mask to be used by DHCP client. If set to '0' - netmask from network address will be used.</td>
</tr>
<tr>
    <td><var><b>next-server</b></var> (<em>IP</em>; Default: <b></b>)</td>
    <td>IP address of next server to use in bootstrap.</td>
</tr>
<tr>
    <td><var><b>ntp-server</b></var> (<em>IP</em>; Default: <b></b>)</td>
    <td>the DHCP client will use these as the default NTP servers. Two comma-separated NTP servers can be specified to be used by DHCP client as primary and secondary NTP servers</td>
</tr>
<tr>
    <td><var><b>wins-server</b></var> (<em>IP</em>; Default: <b></b>)</td>
    <td>The Windows DHCP client will use these as the default WINS servers. Two comma-separated WINS servers can be specified to be used by DHCP client as primary and secondary WINS servers</td>
</tr>
</table>
</p>
</p>



Revision as of 08:24, 23 October 2009

Version.png

Applies to RouterOS: v3, v4

Summary

The DHCP (Dynamic Host Configuration Protocol) is needed for easy distribution of IP addresses in a network. The MikroTik RouterOS implementation includes both server and client parts and is compliant with RFC 2131.

The router supports an individual server for each Ethernet-like interface. The MikroTik RouterOS DHCP server supports the basic functions of giving each requesting client an IP address/netmask lease, default gateway, domain name, DNS-server(s) and WINS-server(s) (for Windows clients) information (set up in the DHCP networks submenu)

In order DHCP server to work, you must set up also IP pools (do not include the DHCP server's own IP address into the pool range) and DHCP networks.

It is also possible to hand out leases for DHCP clients using the RADIUS server, here are listed the parameters for used in RADIUS server.

Access-Request:

  • NAS-Identifier - router identity
  • NAS-IP-Address - IP address of the router itself
  • NAS-Port - unique session ID
  • NAS-Port-Type - Ethernet
  • Calling-Station-Id - client identifier (active-client-id)
  • Framed-IP-Address - IP address of the client (active-address)
  • Called-Station-Id - name of DHCP server
  • User-Name - MAC address of the client (active-mac-address)
  • Password - ""

Access-Accept:

  • Framed-IP-Address - IP address that will be assigned to client
  • Framed-Pool - ip pool from which to assign ip address to client
  • Rate-Limit - Datarate limitation for DHCP clients. Format is: rx-rate[/tx-rate] [rx-burst-rate[/tx-burst-rate] [rx-burst-threshold[/tx-burst-threshold] [rx-burst-time[/tx-burst-time][priority] [rx-rate-min[/tx-rate-min]]]]. All rates should be numbers with optional 'k' (1,000s) or 'M' (1,000,000s). If tx-rate is not specified, rx-rate is as tx-rate too. Same goes for tx-burst-rate and tx-burst-threshold and tx-burst-time. If both rx-burst-threshold and tx-burst-threshold are not specified (but burst-rate is specified), rx-rate and tx-rate are used as burst thresholds. If both rx-burst-time and tx-burst-time are not specified, 1s is used as default. Priority takes values 1..8, where 1 implies the highest priority, but 8 - the lowest. If rx-rate-min and tx-rate-min are not specified rx-rate and tx-rate values are used. The rx-rate-min and tx-rate-min values can not exceed rx-rate and tx-rate values.
  • Ascend-Data-Rate - tx/rx data rate limitation if multiple attributes are provided, first limits tx data rate, second - rx data rate. If used together with Ascend-Xmit-Rate, specifies rx rate. 0 if unlimited
  • Ascend-Xmit-Rate - tx data rate limitation. It may be used to specify tx limit only instead of sending two sequential Ascend-Data-Rate attributes (in that case Ascend-Data-Rate will specify the receive rate). 0 if unlimited
  • Session-Timeout - max lease time (lease-time)


General

Sub-menu: /ip dhcp-server

Property Description
add-arp (yes | no; Default: no) Whether to add dynamic ARP entry. If set to no either ARP mode should be enabled on that interface or static ARP entries should be administratively defined in /ip arp submenu
address-pool (string | static-only; Default: static-only) IP pool, from which to take IP addresses for clients. If set to static-only, then only the clients that have a static lease (i.e. no dynamic addresses will be given to clients, only the ones added in lease submenu) will be allowed
always-broadcast (yes | no; Default: no) Always send replies as broadcasts
authoritative (after-10sec-delay | after-2sec-delay | no | yes; Default: after-2sec-delay) Whether the DHCP server is the only one DHCP server for the network:
  • after-10sec-delay - to clients request for an address, dhcp server will wait 10 seconds and if there is another request from the client after this period of time, then dhcp server will offer the address to the client or will send DHCPNAK, if the requested address is not available from this server
  • after-2sec-delay - to clients request for an address, dhcp server will wait 2 seconds and if there is another request from the client after this period of time, then dhcp server will offer the address to the client or will send DHCPNAK, if the requested address is not available from this server
  • yes - to clients request for an address that is not available from this server, dhcp server will send negative acknowledgment (DHCPNAK)
  • no - dhcp server ignores clients requests for addresses that are not available from this server
boot-support (none | static | dynamic; Default: static) Support for BOOTP clients
  • none - do not respond to BOOTP requests
  • static - offer only static leases to BOOTP clients
  • dynamic - offer static and dynamic leases for BOOTP clients
delay-threshold (time; Default: none) If secs field in DHCP packet is smaller than delay-threshold, then this packet is ignored. If set to none - there is no threshold (all DHCP packets are processed)
interface (string; Default: ) Interface on which server will be running
lease-time (time; Default: 72h) the time that a client may use the assigned address. The client will try to renew this address after a half of this time and will request a new address after time limit expires
name (string; Default: ) Reference name
relay (IP; Default: 0.0.0.0) the IP address of the relay this DHCP server should process requests from:
  • 0.0.0.0 - the DHCP server will be used only for direct requests from clients (no DHCP really allowed)
  • 255.255.255.255 - the DHCP server should be used for any incomming request from a DHCP relay except for those, which are processed by another DHCP server that exists in the /ip dhcp-server submenu
src-address (IP; Default: 0.0.0.0) The address which the DHCP client must send requests to in order to renew an IP address lease. If there is only one static address on the DHCP server interface and the source-address is left as 0.0.0.0, then the static address will be used. If there are multiple addresses on the interface, an address in the same subnet as the range of given addresses should be used
use-radius (yes | no; Default: no) Whether to use RADIUS server for dynamic leases

Menu specific commands

Property Description
setup () Release current binding and restart DHCP client


Server configuration

Sub-menu: /ip dhcp-server config

Leases are always stored on disk on graceful shutdown and reboot. If they would be saved on disk on every lease change, a lot of disk writes would happen. There are no problems if it happens on a hard drive, but is very bad for Compact Flash (especially, if lease times are very short). To minimize writes on disk, all changes are saved on disk every store-leases-disk seconds. If this time will be very short (immediately), then no changes will be lost even in case of hard reboots and power losts. But, on CF there may be too many writes in case of short lease times (as in case of hotspot). If this time will be very long (never), then there will be no writes on disk, but information about active leases may be lost in case of power loss. In these cases dhcp server may give out the same ip address to another client, if first one will not respond to ping requests.

store-leases-disk (time | immediately | never; Default: 5min) How frequently lease changes should be stored on disk

Networks

Sub-menu: /ip dhcp-server network

Property Description
address (IP/netmask; Default: ) the network DHCP server(s) will lend addresses from
boot-file-name (string; Default: ) Boot file name
dhcp-option (string; Default: ) Add additional DHCP options from option list.
dns-server (string; Default: ) the DHCP client will use these as the default DNS servers. Two comma-separated DNS servers can be specified to be used by DHCP client as primary and secondary DNS servers
domain (string; Default: ) The DHCP client will use this as the 'DNS domain' setting for the network adapter.
gateway (IP; Default: 0.0.0.0) The default gateway to be used by DHCP Client.
netmask (integer: 0..32; Default: 0) The actual network mask to be used by DHCP client. If set to '0' - netmask from network address will be used.
next-server (IP; Default: ) IP address of next server to use in bootstrap.
ntp-server (IP; Default: ) the DHCP client will use these as the default NTP servers. Two comma-separated NTP servers can be specified to be used by DHCP client as primary and secondary NTP servers
wins-server (IP; Default: ) The Windows DHCP client will use these as the default WINS servers. Two comma-separated WINS servers can be specified to be used by DHCP client as primary and secondary WINS servers

Leases

Sub-menu: /ip dhcp-server lease

Alerts

Sub-menu: /ip dhcp-server alert

DHCP Options

Sub-menu: /ip dhcp-server option


Basic examples


[Back to Content]