Status offered mikrotik что это
DHCP Client
Summary
The DHCP (Dynamic Host Configuration Protocol) is used for the 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 MikroTik RouterOS DHCP client may be enabled on any Ethernet-like interface at a time. The client will accept an address, netmask, default gateway, and two DNS server addresses. The received IP address will be added to the interface with the respective netmask. The default gateway will be added to the routing table as a dynamic entry. Should the DHCP client be disabled or not renew an address, the dynamic default route will be removed. If there is already a default route installed prior to the DHCP client obtaining one, the route obtained by the DHCP client would be shown as invalid.
RouterOS DHCP client asks for the following options:
Option
DHCP client has the possibility to set up options that are sent to the DHCP server. For example, hostname and MAC address. The syntax is the same as for DHCP server options.
Currently, there are three variables that can be used in options:
DHCP client default options include these default Options:
Name | code | value |
---|---|---|
clientid_duid | 61 | 0xff$(CLIENT_DUID) |
clientid | 61 | 0x01$(CLIENT_MAC) |
hostname | 12 | $(HOSTNAME) |
DHCP Client can receive delegated prefixes from the DHCPv6 server. The currently received prefix is added to the IPv6 pool, which later can be used for example in PPPoE server configuration. DHCPv6 client configuration can be found in the /ipv6 sub-menu
Setup example
Add a DHCP client on ether1 interface:
After the interface is added, you can use the «print» or «print detail» command to see what parameters the DHCP client acquired:
If the interface used by the DHCP client is part of the VRF configuration, then the default route and other received routes from the DHCP server will be added to the VRF routing table.
DHCP client status can be checked with:
Examples
Lease script example
It is possible to execute a script when a DHCP client obtains a new lease or loses an existing one. This is an example script that automatically adds a default route with routing-mark=WAN1 and removes it when the lease expires or is removed.
Resolve default gateway when ‘router’ (option3) is from a different subnet
In some cases, administrators tend to set the ‘router’ option which cannot be resolved with offered IP’s subnet. For example, the DHCP server offers 192.168.88.100/24 to the client, and option 3 is set to 172.16.1.1. This will result in an unresolved default route:
To fix this we need to add /32 route to resolve the gateway over ether1, which can be done by the running script below each time the DHCP client gets an address
Now we can further extend the script, to check if the address already exist, and remove the old one if changes are needed
DHCP Server
The DHCP (Dynamic Host Configuration Protocol) is used for the 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 for the DHCP server to work, IP pools must also be configured (do not include the DHCP server’s own IP address into the pool range) and the DHCP networks.
It is also possible to hand out leases for DHCP clients using the RADIUS server; the supported parameters for a RADIUS server are as follows:
DHCP server requires a real interface to receive raw ethernet packets. If the interface is a Bridge interface, then the Bridge must have a real interface attached as a port to that bridge which will receive the raw ethernet packets. It cannot function correctly on a dummy (empty bridge) interface.
Lease Store Configuration
This sub-menu allows the configuration of how often the DHCP leases will be stored on disk. If they would be saved on a disk on every lease change, a lot of disk writes would happen which 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. Additionally, leases are always stored on disk on graceful shutdown and reboot.
Leases
DHCP server lease submenu is used to monitor and manage server leases. The issued leases are shown here as dynamic entries. You can also add static leases to issue a specific IP address to a particular client (identified by MAC address).
Generally, the DHCP lease is allocated as follows:
A client may free the leased address. The dynamic lease is removed, and the allocated address is returned to the address pool. But the static lease becomes busy until the client reacquires the address.
IP addresses assigned statically are not probed!
Parameters
Properties
Network
Rate limiting
It is possible to set the bandwidth to a specific IPv4 address by using DHCPv4 leases. This can be done by setting a rate limit on the DHCPv4 lease itself, by doing this a dynamic simple queue rule will be added for the IPv4 address that corresponds to the DHCPv4 lease. By using the rate-limit parameter you can conveniently limit a user’s bandwidth.
For any queues to work properly, the traffic must not be FastTracked, make sure your Firewall does not FastTrack traffic that you want to limit.
First, make the DHCPv4 lease static, otherwise, it will not be possible to set a rate limit to a DHCPv4 lease:
Then you can set a rate to a DHCPv4 lease that will create a new dynamic simple queue entry:
By default allow-dual-stack-queue is enabled, this will add a single dynamic simple queue entry for both DCHPv6 binding and DHCPv4 lease, without this option enabled separate dynamic simple queue entries will be added for IPv6 and IPv4.
If allow-dual-stack-queue is enabled, then a single dynamic simple queue entry will be created containing both IPv4 and IPv6 addresses:
RADIUS Support
Since RouterOS v6.43 it is possible to use RADIUS to assign a rate limit per lease, to do so you need to pass the Mikrotik-Rate-Limit attribute from your RADIUS Server for your lease. To achieve this you first need to set your DHCPv4 Server to use RADIUS for assigning leases. Below is an example of how to set it up:
After that, you need to tell your RADIUS Server to pass the Mikrotik-Rate-Limit attribute. In case you are using FreeRADIUS with MySQL, then you need to add appropriate entries into radcheck and radreply tables for a MAC address, that is being used for your DHCPv4 Client. Below is an example for table entries:
Ошибка визуализации кода макроса: задано недействительное значение для параметра «com.atlassian.confluence.ext.code.render.InvalidValueException»
Alerts
To find any rogue DHCP servers as soon as they appear in your network, the DHCP Alert tool can be used. It will monitor the ethernet interface for all DHCP replies and check if this reply comes from a valid DHCP server. If a reply from an unknown DHCP server is detected, an alert gets triggered:
When the system alerts about a rogue DHCP server, it can execute a custom script.
DHCP Options
With the help of the DHCP Option list, it is possible to define additional custom options for DHCP Server to advertise. Option precedence is as follows:
This is the order in which the client option request will be filled in.
According to the DHCP protocol, a parameter is returned to the DHCP client only if it requests this parameter, specifying the respective code in the DHCP request Parameter-List (code 55) attribute. If the code is not included in the Parameter-List attribute, the DHCP server will not send it to the DHCP client, but since RouterOS v7.1rc5 it is possible to force the DHCP option from the server-side even if the DHCP-client does not request such parameter:
Properties
RouterOS has predefined variables that can be used:
Now it is also possible to combine data types into one, for example: «0x01’vards’$(HOSTNAME)»
For example if HOSTNAME is ‘kvm’, then raw value will be 0x0176617264736b766d.
Example
Classless Route
A classless route adds a specified route in the clients routing table. In our example, it will add
According to RFC 3442: The first part is the netmask («18» = netmask /24). Second part is significant part of destination network («A00000» = 160.0.0). Third part is IP address of gateway («0A016501» = 10.1.101.1). Then There are parts of the default route, destination netmask (0x00 = 0.0.0.0/0) followed by default route (0x0A016501 = 10.1.101.1)
Manual:IP/DHCP Server
Applies to RouterOS: v3, v4, v5+
Contents
Summary
Standards: RFC 2131, RFC 3315, RFC 3633
Package: dhcp
The DHCP (Dynamic Host Configuration Protocol) is used for the 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 for the DHCP server to work, IP pools must also be configured (do not include the DHCP server’s own IP address into the pool range) and the DHCP networks.
It is also possible to hand out leases for DHCP clients using the RADIUS server; the supported parameters for a RADIUS server is as follows:
Note: DHCP server requires a real interface to receive raw ethernet packets. If the interface is a Bridge interface, then the Bridge must have a real interface attached as a port to that bridge which will receive the raw ethernet packets. It cannot function correctly on a dummy (empty bridge) interface.
Quick Setup Guide
RouterOS has a built in command that lets you easily set up a DHCP server. Let’s say we want to configure DHCP server on ether1 interface to lease addresses from 192.168.0.2 to 192.168.0.254 which belong to the 192.168.0.0/24 network. The gateway and DNS server is 192.168.0.1.
From /ip dhcp-server menu run setup command and follow instructions:
The wizard has made the following configuration based on the answers above:
Starting from v5.8 RouterOS supports IPv6 prefix delegation according to RFC 3315 and RFC 3633.
Starting from v5.9, DHCPv6 server configuration was moved to /ipv6 sub-menu. Read-more >>
General
Sub-menu: /ip dhcp-server
Menu specific commands
Property | Description |
---|---|
setup ( ) | Start DHCP server setup wizard, which guides you through the steps to easily create all necessary configuration. Read more>> |
Lease Store Configuration
Sub-menu: /ip dhcp-server config
This sub-menu allows the configuration of how often the DHCP leases will be stored on disk. If they would be saved on disk on every lease change, a lot of disk writes would happen which 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. Additionally leases are always stored on disk on graceful shutdown and reboot.
This sub-menu has only one configurable property:
Property | Description |
---|---|
store-leases-disk (time | immediately | never; Default: 5m) | How frequently lease changes should be stored on disk |
Networks
Sub-menu: /ip dhcp-server network
Leases
Sub-menu: /ip dhcp-server lease
Generally, the DHCP lease it allocated as follows:
A client may free the leased address. The dynamic lease is removed, and the allocated address is returned to the address pool. But the static lease becomes busy until the client reacquires the address.
Note: IP addresses assigned statically are not probed!
Properties
Warning: The always-broadcast parameter will dynamically change. For the initial DHCP discover/offer/request/ack cycle a broadcast MAC address is going to be used, for lease renewal (request and ack) an unicast MAC address will be used. In case the DHCP Server keeps receiving DHCP requests while DHCP offer has been sent, then the always-broadcast parameter will be turned on dynamically until the DHCP lease has been renewed successfully.
Read only properties
Menu specific commands
Property | Description |
---|---|
check-status (id) | Check status of a given busy dynamic lease, and free it in case of no response |
make-static (id) | Convert a dynamic lease to a static one |
Rate limiting
It is possible to set a bandwidth to a specific IPv4 address by using DHCPv4 leases. This can be done by setting a rate limit on the DHCPv4 lease itself, by doing this a dynamic simple queue rule will be added for the IPv4 address that corresponds to the DHCPv4 lease. By using the rate-limit parameter you can conveniently limit a user’s bandwidth.
Note: For any queues to work properly, the traffic must not be FastTracked, make sure your Firewall does not FastTrack traffic that you want to limit.
First, make the DHCPv4 lease static, otherwise it will not be possible to set a rate limit to a DHCPv4 lease:
Then you can set a rate to a DHCPv4 lease that will create a new dynamic simple queue entry:
Note: By default allow-dual-stack-queue is enabled, this will add a single dynamic simple queue entry for both DCHPv6 binding and DHCPv4 lease, without this option enabled separate dynamic simple queue entries will be added for IPv6 and IPv4.
If allow-dual-stack-queue is enabled, then a single dynamic simple queue entry will be created containing both IPv4 and IPv6 addresses:
RADIUS Support
Since RouterOS v6.43 it is possible to use RADIUS to assign a rate-limit per lease, to do so you need to pass the Mikrotik-Rate-Limit attribute from your RADIUS Server for your lease. To achieve this you first need to set your DHCPv4 Server to use RADIUS for assigning leases. Below is an example how to set it up:
After that you need to tell your RADIUS Server to pass the Mikrotik-Rate-Limit attribute. In case you are using FreeRADIUS with MySQL, then you need to add appropriate entries into radcheck and radreply tables for a MAC address, that is being used for your DHCPv4 Client. Below is an example for table entries:
Alerts
Sub-menu: /ip dhcp-server alert
To find any rogue DHCP servers as soon as they appear in your network, DHCP Alert tool can be used. It will monitor the ethernet interface for all DHCP replies and check if this reply comes from a valid DHCP server. If a reply from an unknown DHCP server is detected, alert gets triggered:
When the system alerts about a rogue DHCP server, it can execute a custom script.
Properties
Property | Description |
---|---|
alert-timeout (none | time; Default: none) | Time after which alert will be forgotten. If after that time the same server is detected, new alert will be generated. If set to none timeout will never expire. |
interface (string; Default: ) | Interface, on which to run rogue DHCP server finder. |
on-alert (string; Default: ) | Script to run, when an unknown DHCP server is detected. |
valid-server (string; Default: ) | List of MAC addresses of valid DHCP servers. |
Read only properties
Property | Description |
---|---|
unknown-server (string) | List of MAC addresses of detected unknown DHCP servers. Server is removed from this list after alert-timeout |
Menu specific commands
DHCP Options
Sub-menu: /ip dhcp-server option
With the help of DHCP Option list, it is possible to define additional custom options for DHCP Server to advertise. Option precedence is as follows:
This is the order in which client option request will be filled in.
According to the DHCP protocol, a parameter is returned to the DHCP client only if it requests this parameter, specifying the respective code in DHCP request Parameter-List (code 55) attribute. If the code is not included in Parameter-List attribute, the DHCP server will not send it to the DHCP client.
Properties
Property | Description |
---|---|
code (integer:1..254; Default: ) | dhcp option code. All codes are available at http://www.iana.org/assignments/bootp-dhcp-parameters |
name (string; Default: ) | Descriptive name of the option |
value (string; Default: ) | Parameter’s value. |
Starting from v6.8 available data types for options are:
RouterOS has predefined variables that can be used:
Now it is also possible to combine data types into one, for example: «0x01’vards’$(HOSTNAME)»
For example if HOSTNAME is ‘kvm’, then raw value will be 0x0176617264736b766d.
Example
A classless route adds specified route in clients routing table. In our example, it will add
According to RFC 3442: The first part is the netmask («18» = netmask /24). Second part is significant part of destination network («A00000» = 160.0.0). Third part is IP address of gateway («0A016501» = 10.1.101.1). Then There are parts of the default route, destination netmask (0x00 = 0.0.0.0/0) followed by default route (0x0A016501 = 10.1.101.1)
Much more robust way would be to use built in variables, previous example can be rewritten as:
DHCP Option Sets
Sub-menu: /ip dhcp-server option sets
This menu allows combining multiple options in option sets, which later can be used to override default DHCP server option set.
Property | Description |
---|---|
name (string; Default: ) | Name of the option set. |
options (list; Default: ) | List of options defined in options menu. |
Vendor Classes
Since 6.45beta6 version RouterOS support vendor class id matcher. The vendor class is used by DHCP clients to optionally identify the vendor and configuration.
Property | Description |
---|---|
name (string; Default: ) | Self explained |
sever (string; Default: all) | Specific DHCP server to match |
address-pool (string; Default: ) | Address pool for a particular Vendor ID (VID) |
vid (string; Default: ) | Vendor Class ID matcher |
Example
In the following configuration example, we will give an IP address from a particular pool for an Android based mobile phone. We will use the RouterBOARD with a default configuration
Configure vendor-class-id matcher. DHCP servers configuration remains default
Connect your mobile phone to the device to receive an IP address from 172.16.16.0 network
Configuration Examples
To simply configure DHCP server you can use a setup command.
First, you configure IP address on the interface:
Then you use setup command which will automatically ask necessary parameters:
That is all. You have configured an active DHCP server.
Status offered mikrotik что это
Что можно делать встроенным DHCP сервером MikroTik? Вот не полный список того что он позволяет: осуществлять привязку MAC адреса узла к IP адресу, совместно с настройками ARP организовывать MAC фильтрацию пользователей, раздавать WINS, NTP, WEB, SMTP, IRC, POP3 сервера, индивидуально каждому клиенту устанавливать время ареды, выполнять скрипты при обнаружении не авторизованного DHCP в сети, выступать в сети авторизованным/дополнительным сервером раздачи адресов, раздавать параметры для компьютеров загружаемых с сети, добавлять IP пользователей в списки firewall, распространять статические маршруты, передавать многие другие настройки через Option. Сегодня раскажу на что влияют некоторые параметры в настройках DHCP сервера всеми нами любимого маршрутизатора Mikrotik.
Освоить MikroTik вы можете с помощью онлайн-курса «Настройка оборудования MikroTik». В курсе изучаются все темы из официальной программы MTCNA. Автор – официальный тренер MikroTik. Материал подходит и тем, кто уже давно работает с оборудованием MikroTik, и тем, кто еще не держал его в руках. В состав входят 162 видеоурока, 45 лабораторных работ, вопросы для самопроверки и конспект.
Для тех кто не хочет тратить своё дорогое время на изучение данного мануала предлагаем нашу платную помощь.
Итак произведём ручную настройку DHCP сервера Mikrotik и рассмотрим возможности заложенные в нём. Создадим пул IP адресов которые будут присваиваться клиентам, для этого зайдём в IP/Pool и плюсиком создадим интервал 10.24.3.162-10.24.3.190:
Создадим сам DHCP сервер AlenNet на интерфейсе AlenaNet нажав плюсик в окне IP/DHCP server/DHCP:
Authoritative может быть:
Перейдём на вкладку Networks и создадим список клиентов 10.24.3.160/27 для которого будут раздаваться все остальные настройки. Интересно то что вы можете отдельно каждому клиенту раздавать настройки указав его IP в строке Address:
Перейдём на вкладку Leases (Аренды)
Здесь можно сопоставить раздаваемые клиентам IP адреса с их MAC. Щёлкаем для этого по клиенту и нажимаем кнопку Make Static. Дополнительно можно выбрать список firewall в который нужно добавить клиента запросившего адрес у DHCP. Для этого выбираем в Address List нужный вам список IP адресов.
Отдельного внимания заслуживает наборы Options где вы можете указать дополнительные параметры раздаваемые c помощью DHCP:
Например 249 опция оформляется как в статье Настройка Option 249 на DHCP сервере Mikrotik. Передача по DHCP статичесих маршрутов., по остальным опциям ч итайте дополнительно это
В раделе Alerts указываются скрипты выполняемые микротиком в случае если в сети обнаружится неавторизованный DHCP
Освоить MikroTik вы можете с помощью онлайн-курса «Настройка оборудования MikroTik». В курсе изучаются все темы из официальной программы MTCNA. Автор – официальный тренер MikroTik. Материал подходит и тем, кто уже давно работает с оборудованием MikroTik, и тем, кто еще не держал его в руках. В состав входят 162 видеоурока, 45 лабораторных работ, вопросы для самопроверки и конспект.