Page 1 of 1

DHCP server: Options

Posted: Fri Aug 16, 2019 8:00 pm
by SpongeB0B
Hi everyone,

I would like for a DHCP client to give it a specific DNS , so trough the DHCP server: Options.

Which code/tag is it for the DNS ?
https://www.iana.org/assignments/bootp- ... ters.xhtml

The 6 or 15 ? Thank you.

Re: DHCP server: Options

Posted: Fri Aug 16, 2019 8:14 pm
by SpongeB0B
Yes, I found ! the 6 work ! but the client receive only one DNS IP
Did you know how to pass the client two IP's ? (aka the Preferred and the Alternate )

Re: DHCP server: Options

Posted: Fri Aug 16, 2019 11:41 pm
by sindy
It is not clear from your question whether you want to set this up on a Mikrotik or on some other DHCP server. On Mikrotik, the embedded help tells you what to do:
[me@MyTik] > ip dhcp-server network add address=192.168.115.0/24 dns-server=[?]
Server ::= Address[,Server]    (max 100 times)
  Address ::= A.B.C.D    (IP address)
so the whole command to define 192.168.19.1 and 192.168.33.1 as primary and secondary DNS server would be
/ip dhcp-server network add address=reserved.ip.for.the.client/32 dns-server=192.168.19.1,192.168.33.1

If you are configuring some exotic DHCP server which doesn't recognize the DNS server option by name, RFC2302 has the answer:
3.7. Name Server Option
The name server option specifies a list of IEN 116 [7] name servers available to the client. Servers SHOULD be listed in order of preference.
The code for the name server option is 5. The minimum length for this option is 4 octets, and the length MUST always be a multiple of 4.
...
So using the RouterOS way of defining DHCP options, you would use /ip dhcp-server option add name=dns code=5 value=0xc0a81301c0a82101 to define primary server 192.168.19.1 and secondary server 192.168.33.1.

Re: DHCP server: Options

Posted: Sat Aug 17, 2019 12:58 am
by SpongeB0B
@Sindy Thbank you for your answer, yes I need to use the /ip dhcp-server option

Who do you get 0xc0a81301c0a82101 from 192.168.19.1 & 192.168.33.1 ?

Thank you

Re: DHCP server: Options

Posted: Sat Aug 17, 2019 1:13 am
by sindy
Who do you get 0xc0a81301c0a82101 from 192.168.19.1 & 192.168.33.1 ?
0x means that the rest is in hexadecimal
c0 = 192 in hexadecimal
a8 = 168 in hexadecimal
etc.
No separator is needed, as each address takes exactly 4 bytes.