Community discussions

MikroTik App
 
atheros
just joined
Topic Author
Posts: 22
Joined: Thu Feb 23, 2006 10:23 am
Location: BALI - INDONESIA

Static route for dinamic ip address

Sun Feb 10, 2008 2:09 am

somebody can help to make script for my case,
I am really newbie in this scripting case,

I have one router with 2 gateway,
1 already fine becouse just put the default route like ussuall,

but I have aproblem with the 2nd gateway, becouse using dinamic ip address and dinamic gateway also
I am use it only for spesific network destenation,
basicly the gateway is always the same like the network address of "/ip address print"

is it possible to make script
/ip router (on interface x) gateway=(network address(on ip address on interface x))

this is a scripter newbie
please help,
help please... :lol:
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7169
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: Static route for dinamic ip address

Mon Feb 11, 2008 11:27 am

for example address vlan1
{
# get ip address
:local myIP [/ip address get [/ip address find interface="vlan1"] address ];

# get rid of netmask
:for i from=( [:len $myIP] - 1) to=0 do={ 
	:if ( [:pick $myIP $i] = "/") do={ 
		:set myIP [:pick $myIP 0 $i] ;
	} 
}

:put $myIP;
# now you can set gateway

/ip route add gateway=$myIP

}
But if you have two gateways, you also have to use poicy routing:
http://www.mikrotik.com/testdocs/ros/2. ... 3467819404

Who is online

Users browsing this forum: No registered users and 6 guests