Mikrotik 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.

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:
[admin@MikroTik] ip dhcp-server> setup
Select interface to run DHCP server on

dhcp server interface: ether1
Select network for DHCP addresses

dhcp address space: 192.168.0.0/24
Select gateway for given network

gateway for dhcp network: 192.168.0.1
Select pool of ip addresses given out by DHCP server

addresses to give out: 192.168.0.2-192.168.0.254
Select DNS servers

dns servers: 192.168.0.1
Select lease time

lease time: 3d
[admin@MikroTik] ip dhcp-server>
      

The wizard has made the following configuration based on the answers above:
[admin@MikroTik] ip dhcp-server> print
Flags: X - disabled, I - invalid
  #   NAME            INTERFACE RELAY           ADDRESS-POOL LEASE-TIME ADD-ARP
  0   dhcp1           ether1    0.0.0.0         dhcp_pool1   3d         no

[admin@MikroTik] ip dhcp-server> network print
  # ADDRESS            GATEWAY         DNS-SERVER      WINS-SERVER     DOMAIN
  0 192.168.0.0/24        192.168.0.1        192.168.0.1

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

[admin@MikroTik] ip dhcp-server>
 

Example

Classless Route
A classless route adds specified route in clients routing table. In our example, it will add
  • dst-address=160.0.0.0/24 gateway=10.1.101.1
  • dst-address=0.0.0.0/0 gaateway=10.1.101.1

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)
/ip dhcp-server option add code=121 name=classless value=0x18A000000A016501000A016501 /ip dhcp-server network set 0 dhcp-option=classless Result:
[admin@MikroTik] /ip route> print Flags: X - disabled, A - active, D - dynamic, C - connect, S - static, r - rip, b - bgp, o - ospf, m - mme, B - blackhole, U - unreachable, P - prohibit # DST-ADDRESS PREF-SRC GATEWAY DISTANCE 0 ADS 0.0.0.0/0 10.1.101.1 0 1 ADS 160.0.0.0/24 10.1.101.1 0

Auto Proxy Config
/ip dhcp-server option add code=252 name=auto-proxy-config value="'http://autoconfig.something.lv/wpad.dat'"

reff : http://wiki.mikrotik.com/wiki/Manual:IP/DHCP_Server
 
SHARE

About Unknown

    Blogger Comment
    Facebook Comment