Community discussions

MikroTik App
 
auxmtik
just joined
Topic Author
Posts: 11
Joined: Fri Nov 11, 2022 11:31 am

Read DHCP option 43 being sent to a MikroTik client

Fri Nov 11, 2022 11:41 am

Good morning.

I have recently set up a DHCP server in my MikroTik routerboard. Said server is configured so that it sends a certain value in the DHCP option 43 to the clients. At the same time, I can see through WireShark that the option is actually being sent, but the client seems to be discarding this value -as it does nothing with it-. Therefore, I wanted to ask whether there is a way in which I could check the value of option 43 in the client. If it's not possible, is there a way I could send certain data -the ACS server, in this case- through DHCP and that the client can see this information, maybe in a certain variable? I need this information to be accessible in the client device.

Thanks for your attention.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Read DHCP option 43 being sent to a MikroTik client

Fri Nov 11, 2022 3:56 pm

I have recently set up a DHCP server in my MikroTik routerboard.

If you don't write us what this "client" will be, how should we answer you?
Press the blue button under the client chassis and the read value appears in the display on the right.

On DHCP Client / Advanced / Script and you see the result on log
:if ($bound=1) do={
    :local LOVendorSpecific ($"lease-options"->"43")
    :log info "Lease Option 43 (Vendor-Specific) is $LOVendorSpecific"
}
 
auxmtik
just joined
Topic Author
Posts: 11
Joined: Fri Nov 11, 2022 11:31 am

Re: Read DHCP option 43 being sent to a MikroTik client

Mon Nov 14, 2022 10:25 am

Hi, thank you for your answer.

Both the DHCP server and client have been configured by means of the Mikrotik RouterOS implementation. The client is a Mikrotik mAP.
If I set up the script you specified, it logs a message in the system, but the variable $LoVendorSpecific appears to be null -it prints a blank space-: "Lease Option 43 (Vendor Specific) is ".

I was therefore wondering if there could be an issue with the way I computed the option 43, although WireShark does see the String I'm trying to send in a DHCPOFFER message.

Thanks again.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Read DHCP option 43 being sent to a MikroTik client

Mon Nov 14, 2022 12:04 pm

one export of dhcp-server and dhcp-client can help
# on server
/ip dhcp-server export

# on client
/ip dhcp-client export
 
auxmtik
just joined
Topic Author
Posts: 11
Joined: Fri Nov 11, 2022 11:31 am

Re: Read DHCP option 43 being sent to a MikroTik client

Mon Nov 14, 2022 2:25 pm

Thanks again for your reply and for your time.

The server has the following configuration
/ip dhcp-server
add address-pool=pool1 interface=bridge1 name=testMS
/ip dhcp-server option
add code=43 force=yes name=acs value=\
    0x0119687474703a2f2f31302e3130302e3130302e32363a37343537
add code=82 name=acs_plain value="'http://192.168.1.26:7547'"
/ip dhcp-server option sets
add name=set1 options=acs
/ip dhcp-server network
add address=10.100.1.0/24 dhcp-option=acs dns-server=8.8.8.8 gateway=\
    192.168.1.200
I tried sending the option in both plain format and hex-coded, but it's still not working.
On the other hand, the client:
/ip dhcp-client option
add code=55 name=receive_opt_43 value=0x0103062b
/ip dhcp-client
add dhcp-options=hostname,clientid,clientid_duid,receive_opt_43 disabled=no \
    interface=ether2 script=":if (\$bound=1) do={\r\
    \n    :local LOVendorSpecific (\$\"lease-options\"->\"43\")\r\
    \n    :log info \"Lease Option 43 (Vendor-Specific) is \$LOVendorSpecific\"\r\
    \n}"
Last edited by auxmtik on Thu Nov 17, 2022 2:02 pm, edited 2 times in total.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Read DHCP option 43 being sent to a MikroTik client  [SOLVED]

Mon Nov 14, 2022 3:26 pm

try to remove both
forced=yes on dhcp server
and remove option 55 "receive_opt_43" and "clientid_duid" on dhcp client.

I receive \01\19http://10.100.100.26:7457 instead of only http://10.100.100.26:7457 is wanted the hex 0x01 and 0x19 at the start???
RouterOS can not print 0x01 and 0x19
If not wanted must be 0x687474703a2f2f31302e3130302e3130302e32363a37343537 but is equal to 'http://10.100.100.26:7547' (quoted with ' )

(offtopic: client and clientid_duid use same 61 code, one are the alternative of the other, must not be used at the same time)

(offtopic: the default options-request (the client option 55) is 0x01798A03212A2B33353606 and are the options 1, 121, 138, 3, 33, 42, 43, 51, 53, 54, 6)
 
auxmtik
just joined
Topic Author
Posts: 11
Joined: Fri Nov 11, 2022 11:31 am

Re: Read DHCP option 43 being sent to a MikroTik client

Tue Nov 15, 2022 1:24 pm

Thanks again for your answer, rextended:
I originally thought that the prefix "0119" had to be added for Mikrotik to understand that the option 43 (19 bytes of length) was being sent.

I tried removing the "force" option on the server, and ralso emoved client_duid and req_opt_43. The code is now the following:

The client side:
/ip dhcp-client option
add code=55 name=req_opts value=0x01798A03212A2B33353606
/ip dhcp-client
add dhcp-options=hostname,clientid,req_opts disabled=no interface=ether2 script="\
    :if (\$bound=1) do={\r\
    \n    :local LOVendorSpecific (\$\"lease-options\"->\"43\")\r\
    \n    :log info \"Lease Option 43 (Vendor-Specific) is \$LOVendorSpecific\"\r\
    \n}"
On the other hand, the server:
/ip dhcp-server
add address-pool=pool1 interface=bridge1 name=dhcp-server
/ip dhcp-server option
add code=43 name=acs_plain value="'http://192.168.1.26:7547'"
add code=43 name=acs_noforce value=\
    0x687474303a2f2345302e3130302e3130302e32363a37343537
/ip dhcp-server option sets
add name=set1 options=acs
/ip dhcp-server network
add address=10.100.1.0/24 dhcp-option=acs_noforce dns-server=8.8.8.8 gateway=\
    10.100.1.200
Unfortunately, the log still registers a blank space in the variable "$LOVendorSpecific". I tried sending both acs_noforce and acs_plain -and I also tried removing req_opts on the client-.
Do you happen to see anything when you print the variable on your side?

Greetings.
Last edited by auxmtik on Thu Nov 17, 2022 2:01 pm, edited 1 time in total.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Read DHCP option 43 being sent to a MikroTik client

Tue Nov 15, 2022 3:18 pm

I see http://10.100.100.26:7547 but I use v6, this is a bug on v7???
 
auxmtik
just joined
Topic Author
Posts: 11
Joined: Fri Nov 11, 2022 11:31 am

Re: Read DHCP option 43 being sent to a MikroTik client

Wed Nov 16, 2022 11:17 am

Good morning,
After rebooting both the client and the server everything works as expected now: the variable shows the right value instead of just blank.

Thank you so much again for all your help, rextended. Have a great day.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Read DHCP option 43 being sent to a MikroTik client

Wed Nov 16, 2022 11:56 am

Thanks, also you.
👍👍👍

Who is online

Users browsing this forum: bp0, miks, rplant, Victoravv and 89 guests