set a dst-address from a variable

Good day,

How do I set a dst-address from a variable in a script. Below is the command that I am trying on the command line and the result is in red.

[admin@Test1] > /ip route set 2 dst-address=[find name=$“new-vpn-ip”]
value of dst-address must contain ‘/’

Please help.

yes, you have to add network mask it is done either setting address=10.0.0.1/24 or by netmask=255.255.255.0 attribute.

these values are just an examples but is the same mask.

I am running routerOS 3.23 and If I type n [TAB], there is no netmask option. My variable $new-vpn-ip is generated elsewhere and all I want is to add a route to that IP via a script.

[admin@Test1] > /ip route set 2 dst-address=[find name=$“new-vpn-ip”] n
bgp-communities bgp-origin bgp-prepend comment distance routing-mark

Please help.

/ip route add dst-address=$"new-vpn-ip" gateway=x.x.x.x

The error is complaining about the subnet, gateway is not the problem:

[admin@Test1] > /ip route set 2 dst-address=[find name=$“new-vpn-ip”] gateway=pppoe-out1
value of dst-address must contain ‘/’

How do I set a new dst-address from a variable into the route number 2?

try something like

{
  :local t [find name=$"new-vpn-ip"]
  :set t $t."/32"
  /ip route set 2 dst-address=$t gateway=pppoe-out1
}