Page 1 of 1
DHCP-OPTIONS example.
Posted: Mon Oct 15, 2007 12:11 pm
by mangust
Hello ALL.
Have anybody real life example with dhcp-option? I mean that example that I’ve check (
http://www.mikrotik.com/testdocs/ros/2.9/ip/dhcp.php ) is not work for me.
I’ve get info from Mikrotic that “You have to set DHCP option settings in HEX form.”
How I can do that? Which tool is better to use for that?
Should I Use “” on the begin and end in value?
Should I use 0xSOME_HEX or just SOME_HEX.
Values for some VOip device should have something like “TFTP=192.168.100.1, HTTP=192.168.100.2”. How I can setup such value?
For example: I’ve try to setup dhcp-option domain-name (code 15) like mydomain.com
add name=domain-option code=15 value=6D79646F6D61696E2E636F6D
add name=domain-option code=15 value=”6D79646F6D61696E2E636F6D”
add name=domain-option code=15 value=0x6D79646F6D61696E2E636F6D
add name=domain-option code=15 value=”0x6D79646F6D61696E2E636F6D”
All examples are not working ;(.
Re: DHCP-OPTIONS example.
Posted: Wed Oct 17, 2007 10:50 am
by mangust
Anyone ?
May anybody give me exapmle how to setup in dhcp "domain-name mydomain.com" ?
Next example do not work: (
add name=domain-option code=15 value=mydomain.com
add name=domain-option code=15 value="mydomain.com"
add name=domain-option code=15 value=6D79646F6D61696E2E636F6D
add name=domain-option code=15 value=”6D79646F6D61696E2E636F6D”
add name=domain-option code=15 value=0x6D79646F6D61696E2E636F6D
add name=domain-option code=15 value=”0x6D79646F6D61696E2E636F6D”
Re: DHCP-OPTIONS example.
Posted: Wed Oct 17, 2007 2:37 pm
by mrz
I suppose you need to add option value in hex only for those options that are not listed in IANA list:
http://www.iana.org/assignments/bootp-dhcp-parameters
Re: DHCP-OPTIONS example.
Posted: Wed Oct 17, 2007 6:07 pm
by tgrand
Be sure and add the option to the DHCP Server.
Defining the option alone is not enough...
Re: DHCP-OPTIONS example.
Posted: Thu Oct 18, 2007 5:02 pm
by pedja
How about real examples?
I want to set dHCP to do two things:
1) to turn NETBOIS off on client and
2) to set specific static route (for example: to set default gateway 10.50.0.1 for network 10.50.0.0/16).
I've been searching for something that works for a long time, but all I get is bunch of documents that list DHCP parameters and no Mikrotik example how to use them
Re: DHCP-OPTIONS example.
Posted: Thu Oct 18, 2007 5:43 pm
by mrz
ok here is working example.
Assume that you already have created working dhcp server.
add an option:
/ip dhcp-server option
add code=66 name="option1" value="10.10.1.1"
after that set option to use on dhcp network:
/ip dhcp-server network set <id> dhcp-option=option1
Now dhcp client will receive TFTP Server Name. Thats it.
Note, that dhcp server sends this option to client only if client is requesting for it.
Re: DHCP-OPTIONS example.
Posted: Thu Oct 18, 2007 10:27 pm
by BrianHiggins
/ ip dhcp-server option
add name="TFTP" code=66 value="10.120.10.10"
/ ip dhcp-server network
add address=10.120.21.0/24 gateway=10.120.21.1 netmask=24 \
dns-server=206.246.134.233,10.120.10.10 wins-server=10.120.10.10 \
ntp-server=206.246.134.2,206.246.134.66,206.246.134.1 domain="asc.local" \
dhcp-option=TFTP comment=""
this is essentially the same as what was posted by mrz, just has a few more parameters defined... we set the TFTP option for our VoIP phones to connect back to our asterisk server at our main office.
Re: DHCP-OPTIONS example.
Posted: Fri Oct 19, 2007 12:03 pm
by mangust
[quote="ForePoint]
this is essentially the same as what was posted by mrz, just has a few more parameters defined... we set the TFTP option for our VoIP phones to connect back to our asterisk server at our main office.[/quote]
How about next ??
option option-242 code 242 = string ;
option option-242 "MCIPADD=192.168.1.254,MCPORT=1719,HTTPSRVR=192.168.1.253";
Re: DHCP-OPTIONS example.
Posted: Fri Oct 19, 2007 12:06 pm
by mangust
/ ip dhcp-server option
add name[color=#FF0000]="TFTP"[/color] code=66 value="10.120.10.10"
/ ip dhcp-server network
add address=10.120.21.0/24 gateway=10.120.21.1 netmask=24 \
dns-server=206.246.134.233,10.120.10.10 wins-server=10.120.10.10 \
ntp-server=206.246.134.2,206.246.134.66,206.246.134.1 domain="asc.local" \
[color=#FF0000]dhcp-option=TFTP comment="" [/color]
Is it cirrect ???
Re: DHCP-OPTIONS example.
Posted: Sat Oct 20, 2007 12:08 am
by BrianHiggins
first:
/ ip dhcp-server option
add name="option-242" code=242 value="MCIPADD=192.168.1.254,MCPORT=1719,HTTPSRVR=192.168.1.253"
then :
/ ip dhcp-server network
add [insert your dhcp values here followed by] dhcp-option=option-242
Re: DHCP-OPTIONS example.
Posted: Sat Oct 20, 2007 3:57 pm
by snark
How about real examples?
I want to set dHCP to do two things:
1) to turn NETBOIS off on client and
2) to set specific static route (for example: to set default gateway 10.50.0.1 for network 10.50.0.0/16).
I've been searching for something that works for a long time, but all I get is bunch of documents that list DHCP parameters and no Mikrotik example how to use them
i want it too ...
on my ISC DHCPD i do following:
- to disable NetBIOS:
option space Microsoft;
option Microsoft.disable-netbios-over-tcpip code 1 = unsigned integer 32;
option Microsoft.release-on-shutdown code 2 = unsigned integer 32;
option Microsoft.default-router-metric code 3 = unsigned integer 32;
if substring(option vendor-class-identifier, 0, 4) = "MSFT" {
vendor-option-space Microsoft;
option Microsoft.disable-netbios-over-tcpip 2; # disable
option Microsoft.release-on-shutdown 1;
}
- for RFC 3442 aka "Classless Static Route":
# for Windows Vista and other non Windows DHCP clients
option classless-static-route code 121 = array of unsigned integer 8;
# for Windows 2000 and XP DHCP clients
option classless-static-route-ms code 249 = array of unsigned integer 8;
and then, for examplesubnet 192.168.0.0 netmask 255.255.255.0 {
option routers 192.168.0.1;
option domain-name-servers 192.168.0.1;
option classless-static-route 24,192,168,1, 192,168,1,1, 24,192,168,2, 192,168,2,1;
option classless-static-route-ms 24,192,168,1, 192,168,1,1, 24,192,168,2, 192,168,2,1;
}
how i can do it on MT?
Re: DHCP-OPTIONS example.
Posted: Sun Oct 21, 2007 5:05 am
by tgrand
Do a google search on dhcp options.
Options 44 - 46 pertain to netbios.
Option 121 pertains to classless-static-route.
You can not expect to not try on your own first, and have others do the work for you.
Please research for yourself, then ask for further detail.
You will ultimately walk away knowing more, in the end.
Re: DHCP-OPTIONS example.
Posted: Mon Oct 22, 2007 2:19 pm
by mangust
first:
/ ip dhcp-server option
add name="option-242" code=242 value="MCIPADD=192.168.1.254,MCPORT=1719,HTTPSRVR=192.168.1.253"
then :
/ ip dhcp-server network
add [insert your dhcp values here followed by] dhcp-option=option-242
I'm sure that this not work. I've tried to setup that a lot of times. After that I've create ticket and answer from MT was
"You have to set DHCP option settings in HEX form".
Has anybody test dhcp option code>224? (
http://www.iana.org/assignments/bootp-dhcp-parameters - >> (224-254 Private Use ))
Re: DHCP-OPTIONS example.
Posted: Mon Oct 22, 2007 2:58 pm
by tgrand
Create a text file (MCI.TXT) containing only the following:
MCIPADD=192.168.1.254,MCPORT=1719,HTTPSRVR=192.168.1.253
Open a command prompt and type:
debug MCI.TXT > MCIHEX.TXT
You will not see any output on the display.
type d<enter> for dump
type q<enter> for quit
Now close the dos prompt and edit the MCIHEX.TXT
Remove what is not required and add the 0x in front of every byte, then add a 0x00 at the end.
Paste it into the Option.
Re: DHCP-OPTIONS example.
Posted: Mon Oct 22, 2007 3:09 pm
by mrz
Re: DHCP-OPTIONS example.
Posted: Mon Oct 22, 2007 3:32 pm
by tgrand
Fare enough..
I've used debug for various things for over 20 years.
It has always remained the same.
Re: DHCP-OPTIONS example.
Posted: Mon Oct 22, 2007 11:24 pm
by BrianHiggins
I'm sure that this not work. I've tried to setup that a lot of times. After that I've create ticket and answer from MT was...
odd, because it is working for me. that code was copied directly out of a working dhcp server running on 2.9.38
edit: I was referring to my TFTP option 66 example is working, the option 242 I am unfamiliar with, I was just using the provided text example...
Re: DHCP-OPTIONS example.
Posted: Tue Oct 23, 2007 6:42 am
by tgrand
That is because option 66 is clearly defined.
Option 242, on the other hand, is not clearly defined (reserved status).
Re: DHCP-OPTIONS example.
Posted: Fri Jan 11, 2008 9:20 am
by mangust
That is because option 66 is clearly defined.
Option 242, on the other hand, is not clearly defined (reserved status).
Just for Info:
What's new in 3.0rc14:
...
*) fixed bug - dhcp server failed to give out options with code > 127;
...
Re: DHCP-OPTIONS example.
Posted: Tue Feb 12, 2008 5:30 pm
by thavinci
Looks like nobody did find a way to get this working...
Or the later part at least..
I desperately need to set my clients mikrotiks routes from the dhcp server. (Also running MT)
Anybody have a working example? Ive tried and failed...
Thanks
Marcel Grandemange
Re: DHCP-OPTIONS example.
Posted: Tue Feb 12, 2008 6:19 pm
by pedja
It seems you will not get it.
I've tried this:
I want to add static route for 10.80.0.0/24 with 10.80.0.1 as gateway.
According to the
http://www.iana.org/assignments/bootp-dhcp-parameters option code for Classless Static Route Option is 121. That option is explained in
http://www.ietf.org/rfc/rfc3442.txt.
So i have network 10.80.0.0 with subnet mask with 24. Destination descriptor is then 24.10.80.0.
Router is 10.80.0.1. Destination descriptor is four bytes and rouer is four bytes. So total option value length is 8. This means that I have to define option with values (LEN | DESCRIPTOR | ROUTER):
08 | 24 10 80 0 | 10 80 0 1
Convered to hex that is: 0x08180a50000a500001
So I have to submit commands:
/ip dhcp-server option add name="staticroute" code=121 value="0x08180a50000a500001"
/ip dhcp-server add address=10.10.10.0/24 gateway=10.10.10.1 netmask=24 \
dns-server=10.10.10.1 dhcp-option=staticroute comment=""
Well, it doesn't work...
Re: DHCP-OPTIONS example.
Posted: Tue Feb 12, 2008 8:22 pm
by thavinci
Well im so desperate on this i even mailed the mikrotik support email.
But im sure other people have tried this aswell.
Re: DHCP-OPTIONS example.
Posted: Tue Feb 12, 2008 8:27 pm
by changeip
Im guessing RouterOS dhcp-client hasn't implemented these options... or are you trying with Windows clients ?
Sam
Re: DHCP-OPTIONS example.
Posted: Tue Feb 12, 2008 9:03 pm
by thavinci
No the clients all use routerboards with v3.2 on.
Hope thats not the case, would rather be proved stupid than told i can't do it... ;p
Re: DHCP-OPTIONS example.
Posted: Tue Feb 12, 2008 10:17 pm
by mrz
ROuterOS DHCP client doesn't recognize those options. Use linux box to test if you set everything correctly.
Re: DHCP-OPTIONS example.
Posted: Fri Feb 15, 2008 4:59 pm
by thavinci
Doesn't i test it on linux im afraid, as all clients will be using MT.
Did get the official answer...
Hello Marcel,
Yes, you are correct static route could be assigned with DHCP-option.
Currently DHCP-Option 121 is not supported by RouterOS DHCP server, but we have plans to add support for this DHCP-Option.
Regards,
Sergejs
Re: DHCP-OPTIONS example.
Posted: Wed Feb 20, 2008 12:03 pm
by redkurawa
still waiting the progress
Re: DHCP-OPTIONS example.
Posted: Wed Feb 20, 2008 12:14 pm
by thavinci
you telling me? :p
I simply can't wait for another release, and then work through the bugs it will introduce....
Made another plan ;>
Good luck on the wait!
Re: DHCP-OPTIONS example.
Posted: Sun Mar 09, 2008 10:03 pm
by thavinci
Well the conclusion here is i found another way of doing what i needed without using the options as i intended before.
Pity, but progress cannot be halted.
Re: DHCP-OPTIONS example.
Posted: Tue Jun 09, 2009 1:52 pm
by LZiX
Have any progress ? I need using 121 option
Re: DHCP-OPTIONS example.
Posted: Tue Jun 09, 2009 2:04 pm
by mrz
for example
192.168.1.0/24 gw=192.168.9.212
is
0x18C0A801C0A809D4
More details in RFC
http://www.faqs.org/rfcs/rfc3442.html
Re: DHCP-OPTIONS example.
Posted: Thu Aug 13, 2009 1:27 am
by dssmiktik
the reason you're not getting options to work is because the client requesting dhcp has to request the options it wants to receive specifically.
however, most dhcp servers will push dhcp options you configure to clients automatically.
as of this post (routeros 3.28) the dhcp-option specified in /ip dhcp-server network are only "access-control" values meaning the options you set in there are "allowed" to be given to a client, but not automatically pushed to the client.
I've sent a support ticket to add the "push" functionality to the dhcp server, as this is what most dhcp servers do.
Re: DHCP-OPTIONS example.
Posted: Tue Oct 06, 2009 12:50 pm
by sunshine
anyone got a answer from MT regarding the netbios disabling (option 46)
i wan to disable netbios so that my clients are not allowed to talk to each other
Re: DHCP-OPTIONS example.
Posted: Tue Oct 06, 2009 1:16 pm
by dssmiktik
anyone got a answer from MT regarding the netbios disabling (option 46)
i wan to disable netbios so that my clients are not allowed to talk to each other
Is the client receiving dhcp specifically requesting option 46?
You can confirm this by doing a simple packet sniff of the dhcp traffic.
Most dhcp servers can be given a list of dhcp options that will be sent as part of the dhcp lease being obtained.
Mikrotik has said they will not support this, so the client must specify the exact options it needs. If it doesn't you're out of luck, as it's not going to work at all.
The /ip dhcp-server network dhcp-options setting is merely an access-control setting, specifying whether or not a client is "allowed" to receive that dhcp option. The client still has to request dhcp options it's dhcp lease negotiation.
Re: DHCP-OPTIONS example.
Posted: Wed Oct 07, 2009 6:50 am
by sunshine
So if there is noway ?
i am trying to do this because i got lot of clients connected on my AP and they are sharing files using netbios. Because of this my AP bandwidth also get slower.
any idea how i can achieve this
Re: DHCP-OPTIONS example.
Posted: Wed Oct 07, 2009 7:12 am
by changeip
jsut block tcp/135-139, udp/135-139, and tcp/445. That should be standard practice nowdays anyhow.
Sam
Re: DHCP-OPTIONS example.
Posted: Wed Oct 07, 2009 7:48 am
by dssmiktik
So if there is noway ?
i am trying to do this because i got lot of clients connected on my AP and they are sharing files using netbios. Because of this my AP bandwidth also get slower.
any idea how i can achieve this
setting dhcp options to give a client doesn't guarantee the client won't manually set them on their computer. a firewall as changeip mentioned would be a much better way to go since you have 100% control of it.
Re: DHCP-OPTIONS example.
Posted: Wed Mar 03, 2010 12:48 am
by bigchirv
These are my results after experimenting with this. The network I tried to configure is described below:
network: 10.100.0.0/23
default-route: 10.100.0.1, hotspot, internet and stuff.
destination-route: 10.100.1.254
destination-network: 172.16.184.0/28, servers network.
The format of the hex chain varies a little from the spec in the RFC 3442. It doesn't need, for example, the hex chain length:
|Mask|d1|...|dn|r1|r2|r3|r4|(?)|dr1|dr2|dr3|dr4|
Mask: the mask of the destination network, according to RFC 3442
d(1...n): Destination network significant octets, according to RFC 3442. In my case they where four.
(?): I suppose this is the route cost. Anyone please confirm.
dr(1...4): Octets of the default dhcp client route. This overrides the configuration made before when creating the dhcp-server.
So, for my network the thing worked this way:
Option: 121,249
chain components, dec: 28,172,16,184,0,10,100,1,254,0,10,100,0,1
hex chain: 0x1CAC10B8000A6401FE000A640001
And finally, this is my /ip dhcp-server export:
# mar/02/2010 18:11:45 by RouterOS 4.5
# software id = H3LP-H3R3
#
/ip dhcp-server
add address-pool=pool1 authoritative=yes bootp-support=static \
disabled=no interface=ether3 lease-time=1d name=dhcp1
/ip dhcp-server option
add code=121 name=static-route value=0x1CAC10B8000A6401FE000A640001
add code=249 name=static-alternative value=0x1CAC10B8000A6401FE000A640001
/ip dhcp-server config
set store-leases-disk=5m
/ip dhcp-server network
add address=10.100.0.0/23 comment="" dhcp-option=\
static-alternative,static-route dns-server=172.16.184.132 domain=\
int.example.com gateway=10.100.0.1 wins-server=172.16.184.165
I hope this helps. I spent almost an entire day figuring out how to make this thing work.
Re: DHCP-OPTIONS example.
Posted: Sat Jul 21, 2018 10:55 pm
by nikolas22t
I am trying to give default gateway via dhcp-option but doesn't seem to work , can someone give me an example how i can give the default gateway
192.168.51.1 ?
(for some clients connecting to my wifi i will give an ip from another range using a different gateway)
UPDATE: Found it. need ' instead of "
Re: DHCP-OPTIONS example.
Posted: Fri Dec 14, 2018 2:43 pm
by sayanrc1986
Hi,
I am using the Mikrotik Router Board as a DHCP server. Is any way of disabling check for Option 55 (Parameter request List) on the router ? So our expectation is that if client is only sending Option-60 (vendor identifier) and not option 55 still the dhcp server should send back the configured options viz. Option 42, Option 43 or option 6 etc.
Thanks,
Sayan
Re: DHCP-OPTIONS example. Option 242
Posted: Sat Mar 20, 2021 6:06 am
by jerryroy1
tried the following. It failed. Anyone with a working example?
/ip dhcp-server option> add name="option-242" code=242 value="MCIPADD=192.168.2.15,MCPORT=1719,HTTPSRVR=192.168.2.15,L2QVLAN=11"
failure: Unknown data type!
/ip dhcp-server option>
Re: DHCP-OPTIONS example.
Posted: Sat Mar 20, 2021 6:09 am
by jerryroy1
Converted the string to hex and then appended 0x to the front. Does this make sense?
http://string-functions.com/string-hex.aspx
/ip dhcp-server option> add name="option-242" code=242 value=0x4d4349504144443d3139322e3136382e322e31352c4d43504f52543d313731392c48545450535256523d3139322e3136382e322
e31352c4c3251564c414e3d3131
Re: DHCP-OPTIONS example.
Posted: Sat Mar 20, 2021 10:30 am
by che
I haven't checked your values and conversion, but if it doesn't work you could try specifying data type to be string by adding quotes:
/ip dhcp-server option
add code=242 name=option-242 value="'MCIPADD=192.168.2.15,MCPORT=1719,HTTPSRVR=192.168.2.15,L2QVLAN=11'"
That should have the same effect as explicitly declaring string type with
s'VALUE' shown below:
/ip dhcp-server option
add code=242 name=option-242 value="s'MCIPADD=192.168.2.15,MCPORT=1719,HTTPSRVR=192.168.2.15,L2QVLAN=11'"
Re: DHCP-OPTIONS example.
Posted: Mon Sep 05, 2022 7:27 pm
by bee
Hello,
I want my hexs to be dhcp server, and it is also my internet gateway. the hexs is represented as 192.168.2.3 as IP for the network 192.168.2.0/24. My default route should be that ip, 192.168.2.3.
It works with the default dhcp server configuration.
But now I want to add a static route to all dhcp clients for my vpn to my openvpn server 192.168.2.102.
I can successfully add static routes with the option 121, e.g. 10.8.0.0 via 192.168.2.102.. I add the options to the dchp network.
But with the static route, the default route is no longer present at the dhcp clients. I tried with a code=3 option, but this does not do anything on client-side.
/ip dhcp-server option
add code=121 name="VPN Static route" value=0x180A0800C0A80266
add code=3 name=default-route value=0xC0A80203
does anyone know how to enforce the default route on the clients when pushing also a static route?
thanks a lot,
Re: DHCP-OPTIONS example.
Posted: Mon Sep 05, 2022 8:35 pm
by sindy
does anyone know how to enforce the default route on the clients when pushing also a static route?
Add the default route to the Option 121, this is how it is standardized (the client must ignore Option 3 if Option 121 is present). This is the reason why Microsoft has defined Option 249, the only difference between Option 121 and Option 249 is this behavior.
0x0000C0A80203180A0800C0A80266
Re: DHCP-OPTIONS example.
Posted: Mon Sep 05, 2022 10:45 pm
by bee
Add the default route to the Option 121, this is how it is standardized (the client must ignore Option 3 if Option 121 is present). This is the reason why Microsoft has defined Option 249, the only difference between Option 121 and Option 249 is this behavior.
0x0000C0A80203180A0800C0A80266
thanks a lot, this put some light to it.
In fact, it is 0x00C0A80203180A0800C0A80266 which worked finally for me:
00 - default route via C0A80203 = 192.168.2.3
180A0800 - 10.8.0.0/24 via C0A80266 = 192.168.2.102
It works now!
Re: DHCP-OPTIONS example.
Posted: Mon Sep 05, 2022 11:20 pm
by sindy
In fact, it is 0x00C0A80203180A0800C0A80266
Sorry, indeed the prefix length of 0 means that 0 bytes of prefix follow.