Community discussions

MikroTik App
 
User avatar
luqasz
Member Candidate
Member Candidate
Topic Author
Posts: 101
Joined: Thu Aug 16, 2007 9:53 pm
Location: Poland

get uplink interface

Fri Jun 17, 2011 12:50 pm

hi

i want to get an uplink interface based on ip address of default route on bridged mikrotik.

i have solved this by doing:
:put [/interface bridge host get [find where mac-address=[/ip arp get [find where address=172.16.244.33] mac-address]] on-interface]
problems:
slower when more entries in bridge host table
:put [:time [/interface bridge host get [find mac-address=[/ip arp get [find address=[/ip route get [find dst-address=0.0.0.0/0] gateway]] mac-address]] on-interface]]
00:01:27.052851
interface bridge host print count-only 
434
if routerboard has less resources it works slower
system routerboard print 
       routerboard: yes
             model: "433"
     serial-number: "xxxxxxxxxxxx"
  current-firmware: "2.26"
  upgrade-firmware: "2.26"
i want to use output od this command in firewall rule.

do you have any better ideas ?
 
User avatar
luqasz
Member Candidate
Member Candidate
Topic Author
Posts: 101
Joined: Thu Aug 16, 2007 9:53 pm
Location: Poland

Re: get uplink interface

Mon Jun 20, 2011 4:02 pm

found something that works much faster.
{
:local gw [/ip route get [find where dst-address=0.0.0.0/0] gateway];
:local mac [/ip arp get [find address=$gw] mac-address ];
:put [/interface bridge host get [find mac-address=$mac] on-interface ];  
}
and something really interesting:
:put [:typeof [/ip route get [find where dst-address=0.0.0.0/0] gateway]]
array
system resource print 
                   uptime: 4d3h46m23s
                  version: 5.4
              free-memory: 51208KiB
             total-memory: 62196KiB
                      cpu: MIPS 24Kc V7.4
                cpu-count: 1
            cpu-frequency: 300MHz
                 cpu-load: 1%
           free-hdd-space: 32128KiB
          total-hdd-space: 61440KiB
  write-sect-since-reboot: 241
         write-sect-total: 9808
               bad-blocks: 0%
        architecture-name: mipsbe
               board-name: RB433
                 platform: MikroTik
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: get uplink interface

Mon Jun 20, 2011 4:23 pm


and something really interesting:
:put [:typeof [/ip route get [find where dst-address=0.0.0.0/0] gateway]]
array
gateway can contain many entries, hence result is array. (think ECMP routes)
 
User avatar
luqasz
Member Candidate
Member Candidate
Topic Author
Posts: 101
Joined: Thu Aug 16, 2007 9:53 pm
Location: Poland

Re: get uplink interface

Mon Jun 20, 2011 4:31 pm

ok thx for reply. my fault. thought it was a bug

Who is online

Users browsing this forum: No registered users and 71 guests