Community discussions

MikroTik App
 
smagumo
just joined
Topic Author
Posts: 17
Joined: Mon Dec 15, 2008 2:52 pm

set a dst-address from a variable

Wed May 26, 2010 2:17 pm

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.
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: set a dst-address from a variable

Wed May 26, 2010 3:04 pm

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.
 
smagumo
just joined
Topic Author
Posts: 17
Joined: Mon Dec 15, 2008 2:52 pm

Re: set a dst-address from a variable

Thu May 27, 2010 8:14 am

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.
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7195
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: set a dst-address from a variable

Thu May 27, 2010 8:36 am

/ip route add dst-address=$"new-vpn-ip" gateway=x.x.x.x
 
smagumo
just joined
Topic Author
Posts: 17
Joined: Mon Dec 15, 2008 2:52 pm

Re: set a dst-address from a variable

Thu May 27, 2010 8:47 am

/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?
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8712
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: set a dst-address from a variable

Thu May 27, 2010 5:04 pm

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