Community discussions

MikroTik App
 
User avatar
mutluit
Forum Veteran
Forum Veteran
Topic Author
Posts: 843
Joined: Wed Mar 25, 2020 4:04 am

How to get IP, MAC, EtherPort for all currently active EtherPorts?

Fri May 15, 2020 8:09 pm

How to get IP, MAC, EtherPort for all currently active EtherPorts?
Ie. for ports of router/switch that have active/alive devices attached? I of course mean the IP and MAC of the attached device, and the EtherPort of the router/switch.
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3343
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: How to get IP, MAC, EtherPort for all currently active EtherPorts?

Sat May 16, 2020 9:15 am

/ip arp print
or
/ip arp print detail
 
accarda
Member Candidate
Member Candidate
Posts: 214
Joined: Fri Apr 05, 2019 4:06 pm
Location: Italy

Re: How to get IP, MAC, EtherPort for all currently active EtherPorts?

Sat May 16, 2020 9:33 am

How to get IP, MAC, EtherPort for all currently active EtherPorts?
Ie. for ports of router/switch that have active/alive devices attached? I of course mean the IP and MAC of the attached device, and the EtherPort of the router/switch.
You can try this script which will list all needed data into a file.
{
:local ethlist {"ether1-WAN1";"ether2-WAN2";"ether3-LAN1";"ether4-LAN2"};
:local buffer;
:local fileName "address-list";

:foreach a in=$ethlist do={
	:if ([/interface ethernet print as-value where name=$a && running=yes]) do={
		:foreach i in=[/ip arp print as-value where interface=$a] do={
			:set $buffer ($buffer." address=".$i->"address"." - mac-address=".$i->"mac-address"." - ETH=".$a."\n");
		}
	}
}

/file print file=$fileName where name="";
delay 1s;
/file set $fileName contents=$buffer;
}
You need to set your values for variable ethlist (this is an example), adding all of your ETH interfaces; the script will list only addresses from those that are running.

Armando.
 
User avatar
mutluit
Forum Veteran
Forum Veteran
Topic Author
Posts: 843
Joined: Wed Mar 25, 2020 4:04 am

Re: How to get IP, MAC, EtherPort for all currently active EtherPorts?

Sat May 16, 2020 11:12 am

/ip arp print
or
/ip arp print detail
Hi @Jotne, thanks. This is indeed good, but it says for all active interfaces just "interface=bridge".
I need also the name of the raw interface, ie. "etherX".
 
User avatar
mutluit
Forum Veteran
Forum Veteran
Topic Author
Posts: 843
Joined: Wed Mar 25, 2020 4:04 am

Re: How to get IP, MAC, EtherPort for all currently active EtherPorts?

Sat May 16, 2020 11:23 am

How to get IP, MAC, EtherPort for all currently active EtherPorts?
Ie. for ports of router/switch that have active/alive devices attached? I of course mean the IP and MAC of the attached device, and the EtherPort of the router/switch.
You can try this script which will list all needed data into a file.
{
:local ethlist {"ether1-WAN1";"ether2-WAN2";"ether3-LAN1";"ether4-LAN2"};
:local buffer;
:local fileName "address-list";

:foreach a in=$ethlist do={
	:if ([/interface ethernet print as-value where name=$a && running=yes]) do={
		:foreach i in=[/ip arp print as-value where interface=$a] do={
			:set $buffer ($buffer." address=".$i->"address"." - mac-address=".$i->"mac-address"." - ETH=".$a."\n");
		}
	}
}

/file print file=$fileName where name="";
delay 1s;
/file set $fileName contents=$buffer;
}
You need to set your values for variable ethlist (this is an example), adding all of your ETH interfaces; the script will list only addresses from those that are running.

Armando.
Hi @accarda, thanks for the script.
But I need this on CRS switch devices.These devices have 24+ or even 48+ interfaces (aka ports), so it is impractical to define all the interfaces manually. Isn't there a method to get all the interfaces as a list or as an array and put it programmatically into your "ethlist" above?
Other than that I just need the output to be printed, ie. putting the result into a file is not required. But this is no problem as I can replace that by a ":put ..."
 
accarda
Member Candidate
Member Candidate
Posts: 214
Joined: Fri Apr 05, 2019 4:06 pm
Location: Italy

Re: How to get IP, MAC, EtherPort for all currently active EtherPorts?

Sat May 16, 2020 12:10 pm


Hi @accarda, thanks for the script.
But I need this on CRS switch devices.These devices have 24+ or even 48+ interfaces (aka ports), so it is impractical to define all the interfaces manually. Isn't there a method to get all the interfaces as a list or as an array and put it programmatically into your "ethlist" above?
Other than that I just need the output to be printed, ie. putting the result into a file is not required. But this is no problem as I can replace that by a ":put ..."
You can try in this way.
{
:local ethlist;
:local buffer;
:local fileName "address-list";

:foreach i1 in [/interface ethernet find where running=yes] do={
	:set $ethlist [/interface ethernet get $i1 name];
	:foreach i2 in=$ethlist do={
		:foreach i3 in=[/ip arp print as-value where interface=$i2] do={
			:set $buffer ($buffer." address=".$i3->"address"." - mac-address=".$i3->"mac-address"." - ETH=".$i2."\n");
		}
	}
}

/file print file=$fileName where name="";
delay 1s;
/file set $fileName contents=$buffer;
}
Armando
 
User avatar
mutluit
Forum Veteran
Forum Veteran
Topic Author
Posts: 843
Joined: Wed Mar 25, 2020 4:04 am

Re: How to get IP, MAC, EtherPort for all currently active EtherPorts?

Sat May 16, 2020 1:46 pm

@Armando, thx, but something isn't working here as the output is empty, s.b.
I added it to "/system script" under the name "myTest2". The editor in RouterOS said that there is a missing "=" in the first foreach line, I fixed it, and let it run, but the result is an empty output file:
[admin2@CRS326] /system/script> print       
Flags: I - invalid 
 0   name="myTest1" owner="admin2" policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon dont-require-permissions=no last-started=may/09/2020 10:54:53 run-count=6 
 ...
 1   name="myTest2" owner="admin2" policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon dont-require-permissions=no run-count=0 source=
       {
         :local ethlist;
         :local buffer;
         :local fileName "address-list";
       
         :foreach i1 in=[/interface ethernet find where running=yes] do={
           :set $ethlist [/interface ethernet get $i1 name];
           :foreach i2 in=$ethlist do={
               :foreach i3 in=[/ip arp print as-value where interface=$i2] do={
                       :set $buffer ($buffer." address=".$i3->"address"." - mac-address=".$i3->"mac-address"." - ETH=".$i2."\n");
               }
           }
         }
       
       /file print file=$fileName where name="";
       delay 1s;
       /file set $fileName contents=$buffer;
       }
[admin2@CRS326] /system/script> run myTest2
[admin2@CRS326] /system/script> /file/print 
Columns: NAME, TYPE, SIZE, CREATION-TIME
  #  NAME              TYPE       SIZE     CREATION-TIME       
  ...
  1  address-list.txt  .txt file  0        may/16/2020 12:40:26
  ... 
 
accarda
Member Candidate
Member Candidate
Posts: 214
Joined: Fri Apr 05, 2019 4:06 pm
Location: Italy

Re: How to get IP, MAC, EtherPort for all currently active EtherPorts?

Sat May 16, 2020 1:53 pm

@Armando, thx, but something isn't working here as the output is empty, s.b.
I added it to "/system script" under the name "myTest2". The editor in RouterOS said that there is a missing "=" in the first foreach line, I fixed it, and let it run, but the result is an empty output file:
I don't know if it's about some wrong character during copy/past into this forum.
However I have tried it again on my router directly from the terminal.

So let me past it again without using the code tag and see if you can copy/paste it on the terminal (and hit return to apply last curly bracket) to see that it creates a file with those info in there.
I know you don't need to write to file, but that was just a simple output to test it out.

------------------------------ COPY / PASTE ---------------------------
{
:local ethlist;
:local buffer;
:local fileName "address-list";

:foreach i1 in [/interface ethernet find where running=yes] do={
:set $ethlist [/interface ethernet get $i1 name];
:foreach i2 in=$ethlist do={
:foreach i3 in=[/ip arp print as-value where interface=$i2] do={
:set $buffer ($buffer." address=".$i3->"address"." - mac-address=".$i3->"mac-address"." - ETH=".$i2."\n");
}
}
}

/file print file=$fileName where name="";
delay 1s;
/file set $fileName contents=$buffer;
}

--------------------------------------

Armando
 
User avatar
mutluit
Forum Veteran
Forum Veteran
Topic Author
Posts: 843
Joined: Wed Mar 25, 2020 4:04 am

Re: How to get IP, MAC, EtherPort for all currently active EtherPorts?

Sat May 16, 2020 2:03 pm

It seems it's supposed to work also without "=":
[admin2@CRS326] /system/script> :foreach i1 in [/interface ethernet find where running=yes] do={ :put $i1; }
*1
*f
[admin2@CRS326] /system/script> :foreach i1 in=[/interface ethernet find where running=yes] do={ :put $i1; }
*1
*f

But, the error must be somewhere else as it does not print any final results.
Ok, I'll try to debug the script.
Thx for your help.

Btw, I'm using the 7.0beta5, maybe an issue it?...

Update:
Tried the code in your last posting, but unfortunately the address-list.txt file is still empty :-(
Last edited by mutluit on Sat May 16, 2020 2:12 pm, edited 1 time in total.
 
accarda
Member Candidate
Member Candidate
Posts: 214
Joined: Fri Apr 05, 2019 4:06 pm
Location: Italy

Re: How to get IP, MAC, EtherPort for all currently active EtherPorts?

Sat May 16, 2020 2:05 pm

It seems it's supposed to work also without "=":
[admin2@CRS326] /system/script> :foreach i1 in [/interface ethernet find where running=yes] do={ :put $i1; }
*1
*f
[admin2@CRS326] /system/script> :foreach i1 in=[/interface ethernet find where running=yes] do={ :put $i1; }
*1
*f

But, the error must be somewhere else as it does not print any final results.
Ok, I'll try to debug the script.
Thx for your help.
Ok, no problem.
I 'm running it on a RB4011 with ROS 6.46.6 and it works fine, it creates all those info based on each ETH.

Armando
 
accarda
Member Candidate
Member Candidate
Posts: 214
Joined: Fri Apr 05, 2019 4:06 pm
Location: Italy

Re: How to get IP, MAC, EtherPort for all currently active EtherPorts?

Sat May 16, 2020 2:43 pm

just FYI, I have tried to add the = sign in the first couple of foreach and I have got the same syntax error even with ROS 6.46.6.
So I don't think it's about the beta that you are using.

Armando
 
User avatar
mutluit
Forum Veteran
Forum Veteran
Topic Author
Posts: 843
Joined: Wed Mar 25, 2020 4:04 am

Re: How to get IP, MAC, EtherPort for all currently active EtherPorts?

Sat May 16, 2020 3:07 pm

just FYI, I have tried to add the = sign in the first couple of foreach and I have got the same syntax error even with ROS 6.46.6.
So I don't think it's about the beta that you are using.

Armando
Thx, but there seems to be the following bug in this beta:
[admin2@CRS326] /system/script> /ip arp print                                  
Flags: D - DYNAMIC, P - PUBLISHED; C - COMPLETE
Columns: ADDRESS, MAC-ADDRESS, INTERFACE
  #      ADDRESS          MAC-ADDRESS        INTERF
  0  DC  192.168.20.1     20:1A:06:5F:C0:3D  bridge
  1  DC  192.168.127.254  24:A4:3C:06:6C:2D  bridge
  2  DC  192.168.90.1     00:40:F4:A6:CE:E2  bridge
[admin2@CRS326] /system/script> /ip arp print as-value where interface="bridge"
[admin2@CRS326] /system/script> /ip arp print as-value where address="192.168.90.1"
[admin2@CRS326] /system/script> /ip arp print as-value where address=192.168.90.1
Ie. it prints nothing. Why not I wonder. A bug in this 7.0beta5 ?

Oops, I think I'll have to embed this in a ":put ..." :-)
Ok, now this works, for example:
:put [/ip arp print as-value where address "192.168.90.1"]                     
.id=*1;address=192.168.20.1;comment=;interface=bridge;mac-address=20:1A:06:5F:C0:3D;.id=*2;address=192.168.127.254;comment=;interface=bridge;mac-address=24:A4:3C:06:6C:2D;.id=*3;address=192.168.90.1;comment=;interface=bridge;mac-address=00:40:F4:A6:CE:E2
Hmm. this can't be true, as it prints all, not the just selected one with "where"... Funny & Possibly Buggy :-)

Ok, the following works:
:put [/ip arp print as-value where address="192.168.90.1"] 
.id=*3;address=192.168.90.1;comment=;interface=bridge;mac-address=00:40:F4:A6:CE:E2
The minor difference is, again, the "=" :-)
Ok, I think this result should help me to get the script fixed to be run in this beta.
 
accarda
Member Candidate
Member Candidate
Posts: 214
Joined: Fri Apr 05, 2019 4:06 pm
Location: Italy

Re: How to get IP, MAC, EtherPort for all currently active EtherPorts?

Sat May 16, 2020 3:23 pm

Actually I have just tried here from the terminal as well, adding the equal sign and I get only one record, as expected.
[user@rb0] > :put [/ip arp print as-value where address="192.168.0.1"]
.id=*10;address=192.168.0.1;comment=;interface=ether2-;mac-address=A8:7D:10:21:FB:2A
[user@rb0] >
Do you get the same ?
This is done with 6.46.6. So that will work also in your beta.
At this point if you try the script that I have sent you (last one), I guess it should work to print out all fields, or do you still get syntax error ?
 
User avatar
mutluit
Forum Veteran
Forum Veteran
Topic Author
Posts: 843
Joined: Wed Mar 25, 2020 4:04 am

Re: How to get IP, MAC, EtherPort for all currently active EtherPorts?

Sat May 16, 2020 3:40 pm

Actually I have just tried here from the terminal as well, adding the equal sign and I get only one record, as expected.
[user@rb0] > :put [/ip arp print as-value where address="192.168.0.1"]
.id=*10;address=192.168.0.1;comment=;interface=ether2-;mac-address=A8:7D:10:21:FB:2A
[user@rb0] >
Do you get the same ?
This is done with 6.46.6. So that will work also in your beta.
At this point if you try the script that I have sent you (last one), I guess it should work to print out all fields, or do you still get syntax error ?
It accepts it with or without the said "=", but here in this beta the result is an empty file.
I'm at the moment trying to figure out the cause, ie. trying to get it working by finding a workaround for this beta.
Regarding ":put [/ip arp print ..." : I had already posted my output in prev posting. Yes they look similar in both versions.
 
User avatar
mutluit
Forum Veteran
Forum Veteran
Topic Author
Posts: 843
Joined: Wed Mar 25, 2020 4:04 am

Re: How to get IP, MAC, EtherPort for all currently active EtherPorts?

Sat May 16, 2020 4:11 pm

Armando, my debug analysis indicates that "/ip arp" does not have a unique (ie. common in both) key/value pair for lookup in "/interface ethernet",
so then it seems it can't be done with "/interface ethernet".
There must be some other location like bridge or switch ...

Update:
see also this related new feature request I just made: viewtopic.php?f=1&t=161253
 
2frogs
Forum Veteran
Forum Veteran
Posts: 713
Joined: Fri Dec 03, 2010 1:38 am

Re: How to get IP, MAC, EtherPort for all currently active EtherPorts?

Sat May 16, 2020 7:09 pm

Since all your ethernet port are slaved to the bridge, only the bridge will show as the interface. You can change the script to:
{
:local ethlist;
:local buffer;
:local fileName "address-list";
:foreach i1 in=[/interface find running=yes] do={:set $ethlist [/interface get $i1 value-name=name];
:foreach i2 in=$ethlist do={:foreach i3 in=[/ip arp print as-value where interface=$i2] do={:set $buffer ($buffer." address=".$i3->"address"." - mac-address=".$i3->"mac-address"." - interface=".$i2."\n")}}};
/file print file=$fileName where name="";
delay 1s;
/file set $fileName contents=$buffer;
}
And it will output a populated file, but the result will not be what you are originally asked for. It will not show what devices are connected to each ether port.
 
2frogs
Forum Veteran
Forum Veteran
Posts: 713
Joined: Fri Dec 03, 2010 1:38 am

Re: How to get IP, MAC, EtherPort for all currently active EtherPorts?

Sat May 16, 2020 7:24 pm

An alternate would be to use something like:
/interface bridge host print
:D

It won't get you the address, but it will get you mac-address and interface it is on. You could then combine this with data from the /ip dhcp-server lease of your router.
 
User avatar
mutluit
Forum Veteran
Forum Veteran
Topic Author
Posts: 843
Joined: Wed Mar 25, 2020 4:04 am

Re: How to get IP, MAC, EtherPort for all currently active EtherPorts?

Sat May 16, 2020 10:19 pm

An alternate would be to use something like:
/interface bridge host print
:D

It won't get you the address, but it will get you mac-address and interface it is on. You could then combine this with data from the /ip dhcp-server lease of your router.
I don't use DHCP, but this still looks very interesting! I've an idea: with a little bit tricky programming this could serve as the basis for the solution... Will try it out. Thx!

Update:
/interface bridge host print
Flags: D - DYNAMIC; L - LOCAL; E - EXTERNAL
Columns: MAC-ADDRESS, ON-INTERFACE, BRIDGE
# MAC-ADDRESS ON-INTE BRIDGE
0 D E 20:1A:06:5F:C0:3D ether15 bridge
1 D E 24:A4:3C:06:6C:2D ether1 bridge
2 DL C4:AD:34:78:E1:88 bridge bridge
3 DL C4:AD:34:78:E1:96 ether15 bridge

Why does the below command not print the above Flags? It is the key for the solution!
/system/script> :foreach i in=[/interface/bridge/host print detail as-value show-ids ] do={ :put $i; }
.id=*38;bridge=bridge;comment=;interface=ether15;mac-address=20:1A:06:5F:C0:3D;on-interface=ether15
.id=*36;bridge=bridge;comment=;interface=ether1;mac-address=24:A4:3C:06:6C:2D;on-interface=ether1
.id=*39;bridge=bridge;comment=;interface=bridge;mac-address=C4:AD:34:78:E1:88;on-interface=bridge
.id=*37;bridge=bridge;comment=;interface=ether15;mac-address=C4:AD:34:78:E1:96;on-interface=ether15

Anybody know how to get also the Flags? (ie. especially the L und E flags)
Then combining that with the "/ip arp" values would be the solution!

Update-2:
I've another new idea based on this... :-)
 
# Algorithm (pseudo code):
 
foreach i in /interface/bridge/host
  f1  = is $i->MAC in /ip/arp ?
  f2  = is $i->MAC not in /interface/ethernet ?
  fOk = f1 AND f2
  if fOK print IP, MAC, interface
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3343
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: How to get IP, MAC, EtherPort for all currently active EtherPorts?  [SOLVED]

Sun May 17, 2020 12:29 am

This seems to work:
{
	:local ip
	/interface bridge host 
	:foreach ID in=[find] do={
		:local inf [get $ID interface]
		:local mac [get $ID mac-address]
		:local idmac [/ip arp find mac-address="$mac"]
		:if ([:len $idmac] > 0) do={
			:set ip [/ip arp get $idmac address]
		}
		:put "interface=$inf mac=$mac ip=$ip"
	}
}
It does get all mac address and what interface they are connected to on the router using /interface bridge host
Then using /ip arp to find what IP the mac-address do belongs to.

If you do not like to show lines where there are no IP, this will do:
{
	:local ip
	/interface bridge host 
	:foreach ID in=[find] do={
		:local inf [get $ID interface]
		:local mac [get $ID mac-address]
		:local idmac [/ip arp find mac-address="$mac"]
		:if ([:len $idmac] > 0) do={
			:set ip [/ip arp get $idmac address]
			:put "interface=$inf mac=$mac ip=$ip"
		}
	}
}
PS I guess you need to use some form of bridge for this to work.
 
accarda
Member Candidate
Member Candidate
Posts: 214
Joined: Fri Apr 05, 2019 4:06 pm
Location: Italy

Re: How to get IP, MAC, EtherPort for all currently active EtherPorts?

Sun May 17, 2020 7:36 am

Armando, my debug analysis indicates that "/ip arp" does not have a unique (ie. common in both) key/value pair for lookup in "/interface ethernet",
so then it seems it can't be done with "/interface ethernet".
There must be some other location like bridge or switch ...

Update:
see also this related new feature request I just made: viewtopic.php?f=1&t=161253
Actually in my case I don't use the bridge (each port is an independed interface), so what I tested was based on that.
Now I see all these differences that you have seen so far, beside the initial errors.
 
User avatar
mutluit
Forum Veteran
Forum Veteran
Topic Author
Posts: 843
Joined: Wed Mar 25, 2020 4:04 am

Re: How to get IP, MAC, EtherPort for all currently active EtherPorts?

Sun May 17, 2020 9:51 am

@Jotne, thank you very much. Your solution works perfectly! :
[admin2@CRS326] /system/script> print where name="myTest3"
Flags: I - invalid 
 2   name="myTest3" owner="admin2" policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon dont-require-permissions=no run-count=0 source=
       {
         :local ip
         /interface bridge host 
         :foreach ID in=[find] do={
           :local inf [get $ID interface]
           :local mac [get $ID mac-address]
           :local idmac [/ip arp find mac-address="$mac"]
           :if ([:len $idmac] > 0) do={
             :set ip [/ip arp get $idmac address]
             :put "interface=$inf mac=$mac ip=$ip"
           }
         }
       }

[admin2@CRS326] /system/script> run myTest3
interface=ether15 mac=20:1A:06:5F:C0:3D ip=192.168.20.1
interface=ether1 mac=24:A4:3C:06:6C:2D ip=192.168.127.254

 
User avatar
mutluit
Forum Veteran
Forum Veteran
Topic Author
Posts: 843
Joined: Wed Mar 25, 2020 4:04 am

Re: How to get IP, MAC, EtherPort for all currently active EtherPorts?

Sun May 17, 2020 10:07 am

Armando, my debug analysis indicates that "/ip arp" does not have a unique (ie. common in both) key/value pair for lookup in "/interface ethernet",
so then it seems it can't be done with "/interface ethernet".
There must be some other location like bridge or switch ...

Update:
see also this related new feature request I just made: viewtopic.php?f=1&t=161253
Actually in my case I don't use the bridge (each port is an independed interface), so what I tested was based on that.
Now I see all these differences that you have seen so far, beside the initial errors.
Thank you all; it was IMO a very fruitful discussion; I as a newbie to MT/ROS-scripting learned much.
Yes, in my case it was needed for the CRS devices with RouterOS in their default factory setup as a switch (Bridge Mode as opposed to Router Mode).
Maybe @Jotne can improve/extend the script to automatically detect the router or switch/bridge environment, then it would be useful also on router devices.

The primary use-case for this script is of course to quickly detect to which port (imagine 48 ports :-)) a specific device with IP is plugged. /ip/arp gives only if=bridge for all, but this script gives the real interface name like "ether15"... :-)
Last edited by mutluit on Sun May 17, 2020 11:05 am, edited 2 times in total.
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3343
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: How to get IP, MAC, EtherPort for all currently active EtherPorts?

Sun May 17, 2020 10:20 am

I did try to see if it was possible to get the mac from all interface, not just bridge, but still no luck.
But if there are some I do miss and its possible, it should be possible to make a script that covers both bridges and ports.

Mye ethernet1 is connected to the wan and do not have any bridge.
This does not give any info:
/interface ethernet switch host print
Last edited by Jotne on Sun May 17, 2020 10:27 am, edited 1 time in total.
 
User avatar
mutluit
Forum Veteran
Forum Veteran
Topic Author
Posts: 843
Joined: Wed Mar 25, 2020 4:04 am

Re: How to get IP, MAC, EtherPort for all currently active EtherPorts?

Sun May 17, 2020 10:24 am

I did try to see if it was possible to get the mac from all interface, not just bridge, but still no luck.
But if there are some I do miss and its possible, it should be possible to make a script that covers both bridges and ports.
I think you can get that from "/interface/ethernet/print"
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3343
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: How to get IP, MAC, EtherPort for all currently active EtherPorts?

Sun May 17, 2020 10:28 am

This:
/interface ethernet print
give only information about the interface it self and its mac address. Not mac-address that ar connected to it.
[xxx] > /interface ethernet print 
Flags: X - disabled, R - running, S - slave 
 #    NAME                                                MTU MAC-ADDRESS       ARP            
 0 RS ether1                                            1500 00:50:5A:AA:5F:75 enabled        
[xxxx] > /interface ethernet print detail 
Flags: X - disabled, R - running, S - slave 
 0 RS name="ether1" default-name="ether1" mtu=1500 mac-address=00:50:5A:AA:5F:75 orig-mac-address=00:50:5A:AA:5F:75 arp=enabled arp-timeout=auto 
      loop-protect=default loop-protect-status=off loop-protect-send-interval=5s loop-protect-disable-time=5m disable-running-check=yes auto-negotiation=yes 
      advertise=10M-half,10M-full,100M-half,100M-full,1000M-full full-duplex=yes tx-flow-control=off rx-flow-control=off cable-settings=default speed=1Gbps 
 
User avatar
mutluit
Forum Veteran
Forum Veteran
Topic Author
Posts: 843
Joined: Wed Mar 25, 2020 4:04 am

Re: How to get IP, MAC, EtherPort for all currently active EtherPorts?

Sun May 17, 2020 10:42 am

This:
/interface ethernet print
give only information about the interface it self and its mac address. Not mac-address that ar connected to it.
[xxx] > /interface ethernet print 
Flags: X - disabled, R - running, S - slave 
 #    NAME                                                MTU MAC-ADDRESS       ARP            
 0 RS ether1                                            1500 00:50:5A:AA:5F:75 enabled        
[xxxx] > /interface ethernet print detail 
Flags: X - disabled, R - running, S - slave 
 0 RS name="ether1" default-name="ether1" mtu=1500 mac-address=00:50:5A:AA:5F:75 orig-mac-address=00:50:5A:AA:5F:75 arp=enabled arp-timeout=auto 
      loop-protect=default loop-protect-status=off loop-protect-send-interval=5s loop-protect-disable-time=5m disable-running-check=yes auto-negotiation=yes 
      advertise=10M-half,10M-full,100M-half,100M-full,1000M-full full-duplex=yes tx-flow-control=off rx-flow-control=off cable-settings=default speed=1Gbps 
Ah, ok, I see: you are looking for a location similar to "/interface bridge host" that gives the currently attached devices, for ROS environments where no bridge is defined.

Update: does the following exist on a router? It too shows the attached devices, plus the "CPU device" :
/interface ethernet switch host print
Flags: D - DYNAMIC, I - INVALID
Columns: SWITCH, MAC-ADDRESS, PORTS, TIMEOUT, DROP, MIRROR, VLAN-ID
  #     SWITCH   MAC-ADDRESS        PORTS        TI  DR  MI  V
  0  D  switch1  20:1A:06:5F:C0:3D  ether15      0s  no  no  1
  1  D  switch1  C4:AD:34:78:E1:88  switch1-cpu  0s  no  no  1
  2  D  switch1  24:A4:3C:06:6C:2D  ether1       0s  no  no  1

Who is online

Users browsing this forum: No registered users and 5 guests