Can anyone suggest how to create a link between option 60 and option 43 for each vendor separately in the Mikrotik DHCP server settings?
So that when Fanvil phones sent option 60 (Vendor class identifier) with their own value, for example - Fanvil (to be precise, Fanvil X7A phones send “Fanvil-X7A”), then the DHCP server would issue option 43 with a value specifically for Fanvil phones.
And for Yealink phones, the value of VID = yealink, then the same DHCP server gave them in option 43 the value specifically for Yealink phones.
Thanks for the advice.
And if I need to have all this in one addresses pool?
Is there a solution?
P.S.
Someone advised me to use Lease Script but I don’t know how to do it
P.P.S.
I know how to do this in the settings of the DHCP server deployed on MS Windows Server and in dhcpd (SUSE or Debian).
But, on my CRS326, on which my laboratory is deployed, this task baffled me
I know there are other DHCP servers that are more flexible, but I don’t think the MikroTik DHCP server can do what you want. Maybe in a future version?
However, note that having different pools and different networks does not mean you need to have different subnets on your LAN.
You can subdivide the address space in different blocks, make different pools to allocate addresses in those blocks, and use these in configuration.
This only means you need to estimate the number of devices in each vendor class beforehand.
A lease script cannot solve this problem. It is a script called when a lease has been issued, it cannot modify the lease itself.
Hi pe1chl!
Veru thanks for the help.
Dividing the address space into separate blocks of addresses is a very good idea
And why didn’t I figure it out myself
I’m sorry, but after thinking a little about the last idea, about different blocks of addresses, I don’t really understand how to set up several pools on one server.
In addition, I can assign a separate block to a separate vendor class. But how can I configure it so that option 43 with the appropriate value is sent to this separate block?
You need to subdivide the address space into 2^n sized blocks. E.g. you can divide a /24 (256 addresses) into a /23 (128 addresses) and two /25 (64 addresses).
The pools and configured networks in the DHCP server will be these 3 blocks, but all together they form a /24 on the network. So you use /24 as the netmask in the
network settings and they all use the same default gateway.
Read the wiki link to see how to configure it.
If I understand correctly, from your example, I have three blocks of addresses and, accordingly, three pools of addresses.
With a single mask (/24), these three blocks are combined into one network - this is also understandable.
But how can I specify the issuance of addresses from all these three pools on one DHCP server? (it’s I not understand)
As far as I understand, the address-pool parameter in the DHCP server settings has only one value.
P.S.
I periodically study the wiki for my understanding of the wisdom of Mikrotik.
But, unfortunately, I did not see anything similar to my first question there, nor a description of setting up a DHCP server with multiple pools.
The vid from the DHCPDISCOVER is used to choose the /ip dhcp-server vendor-class-id row, which indicates a pool to use; the single address drawn from that pool is used to choose the /ip dhcp-server network row, which indicates the list of options to use.
Hi sindy, thanks for help. I’ll try to test it in my lab when I get to it.
P.S.
When testing Fanvil SIP phones, model X7A, I encountered a problem in their FW.
They don’t ask for 66 option even though they have it by default
I want to try to Auto Provisioning them through the Vendor Class Identifier.
This model sends in 60 option id with value “Fanvil-X7A”.
But I already had it busy for Mitel IP-phones.
In my lab previously, I used a DHCP server on SUSE and this could be done in dhcpd config.
But now I use CRS326, which I got by chance, and I really like it for its rich functionality.
to sindy
I have tested idea and commands on my home Mikrotik.
Wow, I would never have thought of how to use it
it’s very nice, and I think it suits me.
Many thanks.
P.S.
Unfortunately, such a scenario is not described in the wiki, but this is a great example for some “how to”
Well yes the WiKi describes how to use vendor classes to select pools and how to use networks to select options, but there is no full example of the use case you have.
What sindy posted is the same as what I meant. It is difficult to know how much direction everyone requires to understand how to configure things.
In my opinion the WiKi could have more useful examples of complete setups, it generally only mentions the tools available but not how they are used together.
Hello pe1chl!
It was not completely obvious to me that a couple of pools can be picked up in this way through the network.
For some reason, I didn’t think that parameter pool could be omitted when adding the dhcp server.
Of course when you follow sindy’s example you still need to make sure you get no overlapping pools.
I tried to explain how you can split a /24 subnet in 3 non-overlapping subnets that still have valid subnet masks (/25 and /26) but sindy just showed two parts carved out of a larger network without this special layout, so you need to make sure the addresses in the two small networks are never assigned in the larger pool for the remainder of the devices.
Hi all!
In general, I succeeded, but I had to do a little magic with the routing between the blocks of addresses.
Here’s what happened, below are my commands: /ip dhcp-server option
add code=150 name=Cisco_TFTP_192.168.2.224 value=0xC0A802E0
add code=66 name=option66_TFTPserver_RTU value=“s’192.168.2.224’”
add code=132 name=option132_VLAN_ID value=“s’102’”
add code=2 name=“Time Offset” value=0x00002A30
add code=176 name=Avaya_TFTP_192.168.2.224 value=“s’TFTPSRVR=192.168.2.224’”
add code=43 name=FanvilX7A_TFTP_192.168.2.224 value=“s’tftp://192.168.2.224/$mac.cfg’”
/ip dhcp-server option sets
add name=“Cisco IP-Phones” options=Cisco_TFTP_192.168.2.224
add name=“IP-Phones RTU” options=“Time Offset,option66_TFTPserver_RTU,Cisco_TFTP_192.168.2.224,Avaya_TFTP_192.168.2.224”
add name=“IP-Phones RTU only FanvilX7A” options=“Time Offset,option66_TFTPserver_RTU,FanvilX7A_TFTP_192.168.2.224”
/ip pool
add name=YealinkPhones ranges=172.22.102.144/28
add name=RTU_OthersPhones ranges=172.22.102.0/25
add name=FanvilX7A ranges=172.22.102.128/28
/ip dhcp-server
add address-pool=RTU_OthersPhones disabled=no interface=vlan102 name=dhcp_IpPhones_102
/ip address
add address=172.22.102.254/30 interface=vlan102 network=172.22.102.252
add address=172.22.102.142/28 interface=vlan102 network=172.22.102.128
add address=172.22.102.126/25 interface=vlan102 network=172.22.102.0
add address=172.22.102.158/28 interface=vlan102 network=172.22.102.144
/ip dhcp-server network
add address=172.22.102.0/25 comment=“pool RTU_OtherPhones”
dhcp-option-set=“IP-Phones RTU” dns-server=172.22.102.253
gateway=172.22.102.126 ntp-server=172.22.102.254
add address=172.22.102.128/28 comment=“pool Fanvil X7A”
dhcp-option-set=“IP-Phones RTU only FanvilX7A” dns-server=172.22.102.253
gateway=172.22.102.142 ntp-server=172.22.102.254
add address=172.22.102.144/28 comment=“pool Yealink”
dhcp-option-set=“IP-Phones RTU” dns-server=172.22.102.253
gateway=172.22.102.158 ntp-server=172.22.102.254
/ip dhcp-server vendor-class-id
add address-pool=FanvilX7A name=“Fanvil X7A” server=dhcp_IpPhones_102 vid=Fanvil-X7A
add address-pool=YealinkPhones name=“Yealink” server=dhcp_IpPhones_102 vid=yealink
By the way, maybe I found a bug in dhcp-server.
When I tried to use the network 172.22.102.160/28 for Fanvil X7A phones, the dhcp-server gave the address 172.22.102.160 to the phone, i.e. network address, not first host address (172.22.102.161)
P.S.
And for some reason the idea proposed by pe1chl did not work out: “The pools and configured networks in the DHCP server will be these 3 blocks, but all together they form a /24 on the network. So you use /24 as the netmask in the network settings and they all use the same default gateway.”
It is not a bug. The address item on an /ip dhcp-server network row is a “prefix” (a way to express a range) rather than a “subnet”, so there’s nothing wrong about using the .160/28 address.
Maybe it is just a misunderstanding. The address field on the /ip dhcp-server network row is used to match against the actual address assigned to the client, but there is another parameter called netmask on the same row, which is an output one (same like gateway, dns-server etc.) specifying values to be sent to the client.
So if all phones are in the same (V)LAN, you assign a single address to that interface: /ip address add address=172.22.102.254/24 interface=vlan102 network=172.22.102.0
On all /ip dhcp-server network rows, you set gateway=172.22.102.254 netmask=24. So all the phones are in the same subnet, 172.22.102.0/24, except that all phones of the same type will get their addresses from a dedicated range within that subnet (as specified by the pool chosen according to the vendor-id).
Hi sindy!
I assume that this is the case. But then why in the block of addresses 172.22.102.144/28 for Yealink phones, the address 172.22.102.144 is not issued?
The first address given was 172.22.102.145.
Initially, I did, completely by analogy with your example. Before that, I had a network 172.22.102.0/24 in the VLAN102 interface. Separate address blocks were only mentioned in adding pools and in dhcp-server network. After that, the phones received addresses, but were unavailable, the addresses were not pinged, and there was no registration on the sip-server.
After that I tried to change the gateway address in dhcp-server network.
And also instead “add address=172.22.102.254/24 interface=vlan102 network=172.22.102.0” added lines:
add address=172.22.102.254/30 interface=vlan102 network=172.22.102.252
add address=172.22.102.142/28 interface=vlan102 network=172.22.102.128
add address=172.22.102.126/25 interface=vlan102 network=172.22.102.0
add address=172.22.102.158/28 interface=vlan102 network=172.22.102.144
After that, the phones became available, received registration on sip-server and the ability to make calls.
As @sindy indicated, there are 3 different places where you either set IP address, subnet mask or range of addresses … and they have very distinct meanings:
/ip/address add address=a.b.c.d/24 interface=
Without explicitly setting it, ROS will automatcally create vaue to property network=a.b.c.0 (value taken from IP address and subnet mask). And netmask, passed as part of IP address, should match subnet masks of all other devices in same LAN.
.
2. /ip/pool add name=name ranges=a.b.c.16/29
In this case CIDR notation is simply alternative of setting ranges=a.b.c.16-a.b.c.19 … as you can see, both “network” address and “broadcast address” are integral part of address range and DHCP server will issue any of them to DHCP clients.
IP address selection is not entirely up to DHCP server. If DHCP client has record of previously used IP address (e.g. when re-newing lease), it’ll ask for that same address and if certain criteria are met (it’s within permitted IP address range, it’s not being used by another device, …), DHCP server will offer it back to device. This might explain why the “special” addresses were not used initially.
.
3. /ip/dhcp-server/network add address=a.b.c.16/29 gateway=a.b.c.254 netmask=24
/ip/dhcp-server add address-pool=name interface= name=dhcp-name1
This tells that if it receives DHCP request via and it decides to give out address from pool with name=name, it’ll send out gateway IP address a.b.c.254 and instruct DHCP client to use netmask of 24 bits. Netmask part of CIDR assigned to address property is not sent to DHCP client.
So at the end DHCP client will only receive netmask 24 (configured in bullet #3), other masks are not relevant to DHCP client. Of course combination of gateway and netmask should match settings on router (incidentally in this case it’s the same device as running DHCP server) LAN interface, set in bullet #1.
Hi mkx!
Thank you very much for the detailed explanation.
I’ll try to rethink everything and check.
By the way, I forgot to add something else at the beginning of my post #17.
Initially, when I made the changes, exactly as sindy suggested.
When sindy adds a dhcp-server he doesn’t specify a pool.
As a result, value = static-only and in this case, no addresses were given to the phones.
So I used the RTU_OthersPhones pool there.