質問

I have exhausted all learnings here and I am still coming up stuck.

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.

Below is what I have tried.

Command: BRCTL

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.

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.

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.

Output:

brctl showmacs br-lan<br>

port no    mac addr        is local?    ageing timer <br>
  1    00:21:70:be:19:2b    no          17.34 <br>
  2    00:22:5f:28:64:54    no          11.16 <br>
  2    10:40:f3:af:ee:6a    no           0.05 <br>
  1    10:6f:3f:29:72:22    yes           0.00 <br>
  2    5c:0a:5b:84:27:8b    no           1.25 <br>
  1    5c:26:0a:7a:a7:60    no           0.00 <br>

Command: swconfig -note I have removed alot of the output of this command to make it neater.

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.

I cannot seem to find a way to match up a mac address to a port value.

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:~# 
役に立ちましたか?

解決

There is a switch between the router and the physical ports. swconfig interfaces to that switch. If you have the default config the router does not know about each physical port, it only sees one connection to the switch. You have two possible options to progress, configure different interfaces for each physical port, so that the router can distinguish them, or get an enhanced version of swconfig which can query the internals of the switch chip, which should have a list of MACs per port. See http://wiki.openwrt.org/doc/uci/network/switch.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top