I am new to Mikrotik, i am using LINUX as my GATEWAY acting as DHCP, PROXY. Now i want to shift to Mikrotik.
My DHCP Setup on my Linux Server is as follows.
I have a file in which i enter all the MAC and IP Addresses of my Clients. Only the MAC Address which are present in this file are Allotted the IP’s which i enter in front of them in this file. Format of the File is
name one 172 and add the range 172.16.10.1-172.16.10.x
then name one 192 and add the range 192.168.100.1-192.168.200.254
then go into the dhcp server setup.
once you’ve configured the options like dns and gateway etc, go to the ‘Leases’ tab
there you can click the plus (+) sign and add addresses manually. Once you’ve added the address with the appropriate MAC, you can click the ‘make static’ button.
so obviously you need to only have the 172 address range equal to the number of static addresses you want to have which will then force dynamic clients to obtain a lease from the 192 pool.
You should just make a DHCP server and a Pool “192.168.100.1 to 192.168.200.1”. Tell the server to use that pool. Then add static entries to the Leases table.
The ones in that table will get the addresses that you specify. the rest will get addresses from that pool
Ah sorry, the manual just mentioned that dhcp wont work unless there is a pool so I wasn’t sure if this applied to manually created address leases.
Normis, can you confirm that that by adding IPs manually to the lease table, this effectively makes them static? Or is it only when you specify the MAC address?
well you do have to specify a pool - for the non-static guys.
yes, if you just want to use static leases - add them by hand, and set the DHCP server “pool” parameter to “static only”. hand-made leases ARE static leases. But the original poster doesn’t need to select this, he has to select the pool for the other guys.
Thank you very much for your quick and kind response. Now i understand the Method how it can be done. However i have one problem, i have approximately 300 Cleints and I manage everything on my Linux Gateway machine with BASH Scripts. Is there any script that can read a FILE containing MAC And IP Addresses and make static entries in the DHCP Lease Section.
One more question, can i create a FILE that will contain MAC and IP Addresses of my Clients, if YES then please let me know how it can be done.
you can make the setup without static leases, and then select-all → make static. and after that, change the setup to what we described earlier.
yes, you can also make a file. the file must contain routerOS commands, so you have to use some kind of text editor with search+replace to add necessary command in front of your Ip/Mac. something like this:
Thank you very much.
Can you please guide me how will i be able to make a text file in MIKROTIK…and which Search and Replace Tools are available in MIKROTIK which i can use to do what you have stated…
You need to use notepad or something similar to prep your data first. So export your DHCP script/db into notepad, then clean it up by adding ‘/ip dhcp-server lease add address=’ in front of every address.
Then add ‘mac-address=’ in front of every MAC address.
You may optionally add at the end of every line this ‘comment=personX’ to identify each client.
yes, just as Hilton said - you should make a text file in your PC with all this stuff, then save it as a .RSC file and use the IMPORT command in RouterOS to get those commands executed in RouterOS.
Just one little question, how to BIND IP Address in Lease To a MAC address and can i set GATEWAY and DNS Server individually with /ip dhcp-server lease add command.
you also have to make an entry in “/ip dhcp-server networks” for this specific IP address. There you can set DNS and Gateway.
As far as I understand - you will need to use for example .2-.100 for the static guys with the custom Network entries, and then there will be a Pool from .101-.254 for the rest of the guys, that will use the default Network entry.
I appreciate all the help provided by Mr.Normis and Mr.Hilton. I really thank you guyz. I have learned alot about DHCP Server, and i have practiced how to setup DHCP Server according to needs and have also learned that setting up a DHCP server in MIKROTIK is much easier than in LINUX.