title: Finding the Physical port of an Ethernet device - OPENWRT
body: <p>I have exhausted all learnings here and I am still coming up stuck. </p>
  
  <p>Problem: I would like to find out which physical switch port a device is connected to and reference that against is MAC address. I have been able to find alot of information on wired devices but I cannot seem to find any command that will give me what I want. </p>
  
  <p>Below is what I have tried. </p>
  
  <p>Command:       BRCTL </p>
  
  <p>The default BRCTL in busy box doesn't have the 'showmacs' command. In order to get this you must install the bridge package and --force depends. </p>
  
  <p>This command I believe tells me which MAC addresses are talking to the bridge however the PORT value is only ever either 1 or 2. This seems to correlates to eth0 and wlan0 respectively as that is the order that they are assigned to the bridge. </p>
  
  <p>The problem is that this doesn't give me the physical port on the back of the router it is plugged into. ie. 1-4. So I keep looking. </p>
  
  <p>Output:</p>
  
  <pre><code>brctl showmacs br-lan&lt;br&gt;
  
  port no    mac addr        is local?    ageing timer &lt;br&gt;
    1    00:21:70:be:19:2b    no          17.34 &lt;br&gt;
    2    00:22:5f:28:64:54    no          11.16 &lt;br&gt;
    2    10:40:f3:af:ee:6a    no           0.05 &lt;br&gt;
    1    10:6f:3f:29:72:22    yes           0.00 &lt;br&gt;
    2    5c:0a:5b:84:27:8b    no           1.25 &lt;br&gt;
    1    5c:26:0a:7a:a7:60    no           0.00 &lt;br&gt;
  </code></pre>
  
  <p>Command: swconfig                 -note I have removed alot of the output of this command to make it neater. </p>
  
  <p>This command shows me some good information regarding ports. It tells which physical ports are connected and at what speed. However the problem is that none of the information provided by this command gives me the MAC addresses meaning I cannot work out which device is connected to which port. </p>
  
  <p>I cannot seem to find a way to match up a mac address to a port value. </p>
  
  <pre><code>root@OpenWrt:~# swconfig dev eth0 show
  Global attributes:
      enable_vlan: 1
  Port 0:
      mib: Port 0 MIB counters
  
  {deleted mib values}
  
      pvid: 1
      link: port:0 link:up speed:1000baseT full-duplex txflow rxflow 
  Port 1:
      mib: Port 1 MIB counters
  
  {deleted mib values}
  
      pvid: 1
      link: port:1 link:up speed:1000baseT full-duplex auto
  Port 2:
      mib: Port 2 MIB counters
  
  {deleted mib values}
  
      pvid: 1
      link: port:2 link:up speed:1000baseT full-duplex auto
  Port 3:
      mib: Port 3 MIB counters
  
  {deleted mib values}
  
      pvid: 1
      link: port:3 link:down
  Port 4:
      mib: Port 4 MIB counters
  
  {deleted mib values}
  
      pvid: 1
      link: port:4 link:down
  VLAN 1:
      vid: 1
      ports: 0 1 2 3 4 
  root@OpenWrt:~# 
  </code></pre>