Extract part of IP address

Hi, I’m working with DHCP device, so I configured routerboard for DHCP.
I obtain IP address such as “192.168.33.81”, then I have to set gateway (192.168.33.1) and dns (192.168.33.1).
So, how can I extract the “192.168.33” from IP address?
Thanks.

Hi ,
Can you try with PICK

Example:

: global ipaddress ;
: set ipaddress [ pick "192.168.33.1" 0 10 ] ;

Bye

Cris

Hi,

to parse IP from interface:

:local iface "pppoe-out1"
:local ip [ /ip address get [ find interface=$iface ] address ]
:set ip [:pick $ip 0 [:find $ip "/" -1 ] ]
:set ip [:pick $ip 0 [:find $ip "." [:find $ip "."  [:find $ip "."  -1 ] ] ] ]

note there is difference between find and :find

to set default gateway/DNS in DHCP:

/ip dhcp-client
add add-default-route=yes disabled=no interface=<iface> use-peer-dns=yes