DHCP та DNS

Налаштування DHCP сервера та DNS на MikroTik.

DHCP Server

Швидке налаштування

/ip dhcp-server setup

Діалог запитає:
1. Інтерфейс
2. Мережу
3. Gateway
4. Пул адрес
5. DNS сервери

Ручне налаштування

1. Пул адрес

/ip pool add name=lan-pool ranges=192.168.1.100-192.168.1.254

2. Мережа DHCP

/ip dhcp-server network add address=192.168.1.0/24 gateway=192.168.1.1 dns-server=192.168.1.1,8.8.8.8

3. DHCP сервер

/ip dhcp-server add name=dhcp-lan interface=bridge1 address-pool=lan-pool disabled=no

Статичні lease

# Прив'язати MAC до IP
/ip dhcp-server lease add address=192.168.1.50 mac-address=AA:BB:CC:DD:EE:FF server=dhcp-lan

# З коментарем
/ip dhcp-server lease add address=192.168.1.51 mac-address=11:22:33:44:55:66 comment="Server1"

Перегляд lease

# Всі lease
/ip dhcp-server lease print

# Активні
/ip dhcp-server lease print where status=bound

Опції DHCP

# Додати опцію (наприклад, NTP сервер)
/ip dhcp-server option add name=ntp code=42 value="'192.168.1.1'"

# Застосувати до мережі
/ip dhcp-server network set 0 dhcp-option=ntp

Кілька пулів

# Пул для гостей
/ip pool add name=guest-pool ranges=192.168.2.100-192.168.2.254
/ip dhcp-server network add address=192.168.2.0/24 gateway=192.168.2.1 dns-server=8.8.8.8
/ip dhcp-server add name=dhcp-guest interface=vlan-guest address-pool=guest-pool

DHCP Client

Налаштування

# Отримати IP від провайдера
/ip dhcp-client add interface=ether1 disabled=no

# З кастомним hostname
/ip dhcp-client add interface=ether1 disabled=no add-default-route=yes use-peer-dns=yes host-name=myrouter

Статус

/ip dhcp-client print detail

DNS Server

Включити DNS

/ip dns set allow-remote-requests=yes servers=8.8.8.8,8.8.4.4

Статичні записи

# A запис
/ip dns static add name=server1.local address=192.168.1.10

# CNAME
/ip dns static add name=www.local cname=server1.local

# PTR (reverse)
/ip dns static add name=10.1.168.192.in-addr.arpa text=server1.local type=PTR

Перегляд записів

/ip dns static print

Кеш DNS

# Перегляд кешу
/ip dns cache print

# Очистити кеш
/ip dns cache flush

DNS over HTTPS (DoH)

/ip dns set use-doh-server=https://cloudflare-dns.com/dns-query verify-doh-cert=yes

DHCP Relay

Для мереж де DHCP сервер в іншому сегменті.

/ip dhcp-relay add name=relay1 interface=vlan100 dhcp-server=192.168.1.1 local-address=10.100.0.1 disabled=no

Приклади конфігурацій

Офісна мережа

# Три мережі: LAN, Servers, Guest
/ip pool add name=lan-pool ranges=192.168.10.100-192.168.10.254
/ip pool add name=srv-pool ranges=192.168.20.100-192.168.20.254
/ip pool add name=guest-pool ranges=192.168.30.100-192.168.30.254

/ip dhcp-server network add address=192.168.10.0/24 gateway=192.168.10.1 dns-server=192.168.10.1 domain=office.local
/ip dhcp-server network add address=192.168.20.0/24 gateway=192.168.20.1 dns-server=192.168.10.1
/ip dhcp-server network add address=192.168.30.0/24 gateway=192.168.30.1 dns-server=8.8.8.8

/ip dhcp-server add name=dhcp-lan interface=bridge-lan address-pool=lan-pool lease-time=1d
/ip dhcp-server add name=dhcp-srv interface=bridge-srv address-pool=srv-pool lease-time=7d
/ip dhcp-server add name=dhcp-guest interface=bridge-guest address-pool=guest-pool lease-time=1h

DNS з локальними записами

/ip dns set allow-remote-requests=yes servers=1.1.1.1,8.8.8.8

# Локальні сервіси
/ip dns static add name=router.local address=192.168.1.1
/ip dns static add name=nas.local address=192.168.1.10
/ip dns static add name=printer.local address=192.168.1.20
/ip dns static add name=camera.local address=192.168.1.30

Діагностика

DHCP проблеми

# Перевірити пул
/ip pool print
/ip pool used print

# Перевірити lease
/ip dhcp-server lease print

# Логи DHCP
/log print where topics~"dhcp"

DNS проблеми

# Перевірити налаштування
/ip dns print

# Тест резолвінгу
/ip dns print

# Перевірити кеш
/ip dns cache print where name~"example"

Типові помилки

Проблема Причина Рішення
Клієнт не отримує IP Пул вичерпано Збільшити пул або lease time
DNS не працює allow-remote-requests=no Увімкнути
Lease не зберігаються Reboot Зберегти backup
Конфлікт IP Статичний + DHCP Виключити з пулу

Безпека

DHCP Snooping (на Switch)

# Довіряти тільки порту до роутера
/interface bridge port set [find interface=ether1] trusted=yes

Rate limit для DHCP

/ip firewall filter add chain=input protocol=udp dst-port=67 limit=10/1s,5:packet action=accept
/ip firewall filter add chain=input protocol=udp dst-port=67 action=drop

Шлях: networking/mikrotik/dhcp-dns.md

UMTC Wiki © 2026 | Ukrainian Military Tactical Communications