Community discussions

MikroTik App
 
User avatar
pnajm
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 94
Joined: Thu Nov 21, 2013 6:54 pm

DHCP Options

Sun Sep 28, 2014 4:24 am

Hello,
I have grandstream phones in my network and i want them to grab dhcp option 2 and 42 automatically from mikrotik dhcp.
can someone please clarify in details on how to configure?
what is the pattern when adding the value ?
also, is hex always used for dhcp options ?


Thanks a lot.
 
SurferTim
Forum Guru
Forum Guru
Posts: 4636
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: DHCP Options

Sun Sep 28, 2014 4:29 am

You can set those in /ip dhcp-server option. I don't use it but I know where to set it.
http://wiki.mikrotik.com/wiki/Manual:IP ... CP_Options
 
User avatar
pnajm
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 94
Joined: Thu Nov 21, 2013 6:54 pm

Re: DHCP Options

Sun Sep 28, 2014 4:32 am

You can set those in /ip dhcp-server option. I don't use it but I know where to set it.
http://wiki.mikrotik.com/wiki/Manual:IP ... CP_Options
I have read the wiki many times but it does not provide good information.
please i want details.
 
SurferTim
Forum Guru
Forum Guru
Posts: 4636
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: DHCP Options

Sun Sep 28, 2014 4:52 am

Are these the options you wanted?
/ip dhcp-server option
add name="Time Zone Offset" code=2 value="'-28800'"
add name="NTP Server" code=42 value="'1.2.3.4'"
The value is a bit odd. It requires a double and single quote on each end of the value if not a hex value.
 
User avatar
pnajm
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 94
Joined: Thu Nov 21, 2013 6:54 pm

Re: DHCP Options

Sun Sep 28, 2014 11:32 pm

Are these the options you wanted?
/ip dhcp-server option
add name="Time Zone Offset" code=2 value="'-28800'"
add name="NTP Server" code=42 value="'1.2.3.4'"
The value is a bit odd. It requires a double and single quote on each end of the value if not a hex value.
Thanks SurferTim.
what is the difference between the dhcp option 42 and the ntp server option in dhcp networks.
 
SurferTim
Forum Guru
Forum Guru
Posts: 4636
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: DHCP Options

Sun Sep 28, 2014 11:40 pm

what is the difference between the dhcp option 42 and the ntp server option in dhcp networks.
Probably nothing different. Just a different way of sending option 42. I have not tested it, but I don't see another way using dhcp to send the NTP server IP.
 
User avatar
pnajm
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 94
Joined: Thu Nov 21, 2013 6:54 pm

Re: DHCP Options

Thu Oct 02, 2014 11:26 am

what is the difference between the dhcp option 42 and the ntp server option in dhcp networks.
Probably nothing different. Just a different way of sending option 42. I have not tested it, but I don't see another way using dhcp to send the NTP server IP.
SurferTim, i tried the options but for some reason it is not working correctly, i have around 10 grandstream telephones and the options 2 and 42 are enabled on the phones.
could there be something wrong?
please help.

many thanks :)
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: DHCP Options

Thu Oct 02, 2014 3:15 pm

you can check frc for each DHCP option and what it accepts as value. In RouterOS dhcp value length is calculated automatically, so you have to only provide actual value.

if you want to give ip address as an value you can use 0x0a0a0a0a or '10.10.10.10' and set in as a value. Since initial construct is value="" when you place '10.10.10.10' in it you get value="'10.10.10.10'" alternative to value="0x0a0a0a0a".

Of course, you can always use HEX value to set anything. However, use of special parsing of the value argument in dhcp options is suggested behaviour to improve readability.
 
User avatar
pnajm
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 94
Joined: Thu Nov 21, 2013 6:54 pm

Re: DHCP Options

Thu Oct 02, 2014 9:10 pm

you can check frc for each DHCP option and what it accepts as value. In RouterOS dhcp value length is calculated automatically, so you have to only provide actual value.

if you want to give ip address as an value you can use 0x0a0a0a0a or '10.10.10.10' and set in as a value. Since initial construct is value="" when you place '10.10.10.10' in it you get value="'10.10.10.10'" alternative to value="0x0a0a0a0a".

Of course, you can always use HEX value to set anything. However, use of special parsing of the value argument in dhcp options is suggested behaviour to improve readability.
can you tell me how to use the HEX method to calculate the ip address or a string for example?
 
tippenring
Member
Member
Posts: 304
Joined: Thu Oct 02, 2014 8:54 pm
Location: St Louis MO
Contact:

Re: DHCP Options

Thu Oct 02, 2014 9:52 pm

Here is my code for IP phones that use option 66.

ros code

/ip dhcp-client option
 add code=66 name="tftp server" value=0xc0a8040a
I use http://paulschou.com/tools/xlate/ to convert between hex, text, base64 and other formats.
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: DHCP Options

Fri Oct 03, 2014 11:22 am

can you tell me how to use the HEX method to calculate the ip address or a string for example?
string conversion happens liek this - get char -> look up ASCII code for it -> file it in.

so 10.11.12.13 becomes 0x31302e31312e31322e3133 so you get 11 hex numbers in a row

if you wanted ip address, you convert each section of ip address to hex. Example address - 10.11.12.13

10 = a; 11 = b; 12 = c; 13 = d.

now, it has to be double digit hex since ip address goes to FF or 255, so you get 0x0a0b0c0d

or just enter value="'10.11.12.13'" and see raw value of the option. when printing

/ip dhcp-server option print
1 test 43 s'10.11.12.13' 31302e31312e31322e3133
1 test 43 '10.11.12.13' 0a0b0c0d
 
mfowler
newbie
Posts: 30
Joined: Tue Dec 15, 2009 4:02 am

Re: DHCP Options

Wed Oct 08, 2014 11:30 pm

I used to use option 66 for provisioning VOIP phones before I updated my router OS. Now no matter what method I try, my phones will not pull the option 66 configuration. I'm running 6.19 router OS and have tried setting the value in hex, decimal, and string. Previously, I would just put the value as this 'IP adresss'. Then of course setting the next server and option in the network.

Any help is much appreciated.
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: DHCP Options

Thu Oct 09, 2014 10:09 am

try to set s'ip.add.ress.here' as a value if you set option 66 yourself as it seem from RFC, that it expects host-name not an ip address. if you give 'ip.add.re.ss' then it is interpreted as an ip address and you get hex string os in length of 4.

If you enter next server, it should accept ip address as a value.

Who is online

Users browsing this forum: Ahrefs [Bot], Amazon [Bot], bertus, Bing [Bot], hatred, NetTecture, onnyloh and 95 guests