I’m trying to add all non dynamic IP’s assigned to a RouterBOARD’s ether interfaces to an address list.
What do you mean by “non dynamic” ? do you mean Static ?
Static IP will add to Router interfaces by admin (who log on to Router)
Jip I want to add all the static IP’s to a list using a script, I could do this manually but we have a couple of RB’s in the field and I would like to automate it so I can just add one script that would then find and add all the IP’s to an address list
As an example on my RB at home I have.
Address - Interface
172.23.100.65/28 - bridge-network
192.168.57.1/30 - ether2-ipcop
10.10.10.102/30 - eoip-bandit
So the script should find those 3 ranges and add them to an address list which I can then use in a mangle rule.
I use this script to find dynamic IP. with this code I get my PPPoE IP and send it via Mail
Note : it can use when there is just one Dynamic IP.
{
local x;
set x [/ip address get [find dynamic] address];
}
but for Static. . . Hmmmmmm?!!
Let me think
Thanks for the help sadeghrafie, this works for me adding the static IP’s to an address list.
{
local x;
set x [/ip address find dynamic=no ];
:foreach i in=$x do={
/ip firewall address-list add list=static-ips address=[/ip address get $i address ];
}}
Good job ![]()
But, which version of ROS do you use?
v5.2 - v5.7
I need to now figure out how to get the script to check if the IP’s are already in the address list or not, at the moment it just adds a copy of the same address in the list every time it runs.
This code should work but …
{
:local x;
:local y;
:local z;
:set x [/ip address find dynamic=no ];
:foreach i in=$x do={
:set z [/ip address get $i address ];
:foreach j in=[/ip firewall address-list find] do={
:set y [/ip firewall address-list get number=$j address];
:if (z!=y) do={
/ip firewall address-list add list=static-ips address=z;
}
}
}
}
the result is
interrupted
value of address expects range of ip addresses
it goes wrong with this >>>> “/ip firewall address-list add list=static-ips address=z;”
Now we should do something that remove “/29” or … I mean Subnet
Neeeeeeeeeeeeeeeed Heeeeeeeeeeeeeeeeeeeeelp ![]()
Maybe needs a ‘$’ in front of the ‘z’?
Just guessin’
G
!dynamic = static