Community discussions

MikroTik App
 
User avatar
senseivita
newbie
Topic Author
Posts: 35
Joined: Fri Jan 01, 2021 4:20 am

Network ID variable or similar

Fri Jan 27, 2023 11:33 am

I'm trying to set up DHCP's option 121. In the docs I learn about variable "NETWORK_GATEWAY", unfortunately it appears to not adapt itself to context/requesting subnet.

So the next best thing would be the subnet ID since the gateways are available on each of the subnets involved at the same respective address per subnet, e.g; x.x.x.2, x.x.x.4—none on the same device of the DHCP server. So according to the documentation it should be relatively easily to script it so it's adapter per subnet automatically removing a zero and adding a number in its place or if it happens to use only the significant bits of the addresss, even easier… something like
0x'8''10'$(SUBNET_ID)0200$(SUBNET_ID)4
               (     hopefully, it's not clear if "0x" is added automatically      )
# or:              or if it needs to be added at all or it's just indicating hex
10/8via10.0.0.2, 0/0via10.0.0.4 

# source: https://help.mikrotik.com/docs/display/ROS/DHCP#DHCP-DHCPOptions.1
Is there something like that?
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Network ID variable or similar

Fri Jan 27, 2023 3:27 pm

Option 121 is Classless Static Route Option...

You can not calculate "0A0000" part.

You need to set manually (or by script) all that:
0x080A0A000002000A000004
10.0.0.0/8->10.0.0.2,0.0.0.0/0->10.0.0.4

/ip dhcp-server option
add code=121 name=Classless-Route value=0x080A0A000002000A000004
/ip dhcp-server network
add […] dhcp-option=Classless-Route […]

Who is online

Users browsing this forum: Amazon [Bot], orionren and 68 guests