Przejdź do głównej zawartości

Konfiguracja DHCP i DNS w RouterOS (MikroTik)

Cel

Po wykonaniu kroków gw01 przydziela adresy IP przez DHCP i rozwiązuje nazwy DNS dla całej domeny cyfra.local. Serwery i urządzenia sieciowe mają stałe adresy przypisane na podstawie adresów MAC.


Wymagania wstępne

  • Skonfigurowany router gw01 z adresem 192.168.50.1/24 na ether2 (A-01)
  • Dostęp do RouterOS przez SSH lub Winbox: login cyfra-admin / Cyfra@MTK2026

Kroki

1. Pula adresów DHCP (zakres dynamiczny)

/ip pool add name=biuro-lan ranges=192.168.50.100-192.168.50.200

2. Serwer DHCP

/ip dhcp-server add name=biuro-lan interface=ether2 address-pool=biuro-lan disabled=no
/ip dhcp-server network add address=192.168.50.0/24 gateway=192.168.50.1 dns-server=192.168.50.1

3. Statyczne przypisania DHCP (dla serwerów i urządzeń sieciowych)

Urządzenia z fixowanym IP muszą zawsze otrzymywać ten sam adres. Używamy przypisań po adresie MAC:

# Routery i kontrolery
/ip dhcp-server lease add mac-address=08:00:27:AA:01:02 address=192.168.50.2 comment=gw02
/ip dhcp-server lease add mac-address=08:00:27:AA:01:05 address=192.168.50.5 comment=unifi01

# Punkty dostępowe Ubiquiti U6 Mesh
/ip dhcp-server lease add mac-address=DC:9F:DB:AA:01:06 address=192.168.50.6 comment=ap01
/ip dhcp-server lease add mac-address=DC:9F:DB:AA:01:07 address=192.168.50.7 comment=ap02
/ip dhcp-server lease add mac-address=DC:9F:DB:AA:01:08 address=192.168.50.8 comment=ap03

# Serwery
/ip dhcp-server lease add mac-address=08:00:27:AA:02:10 address=192.168.50.10 comment=srv01
/ip dhcp-server lease add mac-address=08:00:27:AA:02:11 address=192.168.50.11 comment=srv02
/ip dhcp-server lease add mac-address=08:00:27:AA:02:12 address=192.168.50.12 comment=nas01

4. Resolver DNS – forwardy do zewnętrznych serwerów

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

5. Statyczne wpisy DNS dla domeny cyfra.local

/ip dns static add name=gw01.cyfra.local address=192.168.50.1
/ip dns static add name=gw02.cyfra.local address=192.168.50.2
/ip dns static add name=unifi01.cyfra.local address=192.168.50.5
/ip dns static add name=ap01.cyfra.local address=192.168.50.6
/ip dns static add name=ap02.cyfra.local address=192.168.50.7
/ip dns static add name=ap03.cyfra.local address=192.168.50.8
/ip dns static add name=srv01.cyfra.local address=192.168.50.10
/ip dns static add name=srv02.cyfra.local address=192.168.50.11
/ip dns static add name=nas01.cyfra.local address=192.168.50.12

6. Weryfikacja konfiguracji

# Lista serwerów DHCP
/ip dhcp-server print

# Sieć DHCP (gateway + DNS)
/ip dhcp-server network print

# Lista statycznych przypisań
/ip dhcp-server lease print

# Konfiguracja DNS
/ip dns print

# Statyczne wpisy DNS
/ip dns static print

Weryfikacja

Na stacji Windows w sieci biuro-lan:

ipconfig /all

Oczekiwane:

  • Adres IP: 192.168.50.1xx (zakres dynamiczny) lub przypisany statycznie
  • Brama domyślna: 192.168.50.1
  • Serwer DNS: 192.168.50.1

Test DNS:

nslookup srv01.cyfra.local
# Oczekiwany wynik: Address: 192.168.50.10

nslookup unifi01.cyfra.local
# Oczekiwany wynik: Address: 192.168.50.5

Typowe błędy i rozwiązania

ObjawPrzyczynaRozwiązanie
Stacja nie dostaje adresu DHCPDHCP serwer nieaktywny lub zły interfejs/ip dhcp-server print – sprawdź kolumnę DISABLED; upewnij się, że interface = ether2
DNS nie rozwiązuje lokalnych nazwBrak flagi allow-remote-requests=yes/ip dns set allow-remote-requests=yes
Statyczne przypisanie nie działaBłędny adres MACSprawdź MAC w VirtualBox (VM → Ustawienia → Sieć → Adapter 2 → Advanced) i popraw wpis
nslookup zwraca błądDNS serwer stacji nie wskazuje na 192.168.50.1Sprawdź /ip dhcp-server network print – dns-server musi być 192.168.50.1

Powiązane artykuły