Page 1 of 1

set a dst-address from a variable

Posted: Wed May 26, 2010 2:17 pm
by smagumo
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.

Re: set a dst-address from a variable

Posted: Wed May 26, 2010 3:04 pm
by janisk
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.

Re: set a dst-address from a variable

Posted: Thu May 27, 2010 8:14 am
by smagumo
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.

Re: set a dst-address from a variable

Posted: Thu May 27, 2010 8:36 am
by mrz
/ip route add dst-address=$"new-vpn-ip" gateway=x.x.x.x

Re: set a dst-address from a variable

Posted: Thu May 27, 2010 8:47 am
by smagumo
/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?

Re: set a dst-address from a variable

Posted: Thu May 27, 2010 5:04 pm
by Chupaka
try something like
{
  :local t [find name=$"new-vpn-ip"]
  :set t $t."/32"
  /ip route set 2 dst-address=$t gateway=pppoe-out1
}