Community discussions

MikroTik App
 
pike
just joined
Topic Author
Posts: 20
Joined: Mon Jun 07, 2004 11:02 pm
Location: Poland

Automatic exporting MAC address from ARP to /ip firewall rul

Tue Jul 20, 2004 6:18 pm

I've got two ideas:

1. Seraching for rules witch haven't got mac address and getting it from ARP.

2. For each item in ARP check ip and compare it with firewall rule.
 
pike
just joined
Topic Author
Posts: 20
Joined: Mon Jun 07, 2004 11:02 pm
Location: Poland

Wed Jul 21, 2004 12:13 pm

I've got list of IP's without MAC address:

:foreach i in=[/ip firewall dst-nat find src-mac-address=00:00:00:00:00:00 ] do={
:put [/ip firewall dst-nat get $i src-address]
}

But how can I convert it, ex.
192.168.0.222/32 -> 192.168.0.222
 
edzix
Member
Member
Posts: 335
Joined: Thu Jul 01, 2004 3:01 pm
Location: Latvia

Wed Jul 21, 2004 3:59 pm

at this moment you can't do it. There is no possibility to work with strings currently.

Edgars
 
pike
just joined
Topic Author
Posts: 20
Joined: Mon Jun 07, 2004 11:02 pm
Location: Poland

Wed Jul 21, 2004 4:05 pm

I think that this would be good

:global x
:global y
:foreach i in=[/ip arp find dynamic=yes ] do={
:set x [/ip arp get $i address ]
:set y [/ip arp get $i mac-address ]
:if([/ip firewall dst-nat find src-mac-address=00:00:00:00:00:00 src-address=$x ] != 0) do{
:put ($x . " -> " . $y)
/ip firewall dst-nat set [/ip firewall dst-nat find src-mac-address=00:00:00:00:00:00 src-address=$x ] src-mac-address=$y
}
:if([/ip firewall rule forward find src-mac-address=00:00:00:00:00:00 src-address=$x ] != 0) do{
:put ($x . " -> " . $y)
/ip firewall rule forward set [/ip firewall rule forward find src-mac-address=00:00:00:00:00:00 src-address=$x ] src-mac-address=$y
}
}
:unset x
:global y
 
edzix
Member
Member
Posts: 335
Joined: Thu Jul 01, 2004 3:01 pm
Location: Latvia

Thu Jul 22, 2004 12:10 pm

':put' command will not display anything on the screen if you write it in the script.

Edgars

Who is online

Users browsing this forum: Baidu [Spider] and 55 guests