command to match ethernet port to network card

hi I juts want to know if there is a command that checks if an ethernet port corresponds to a network card.

ex. I have 3 network cards, one is two ports, and the other two 8 ports.

How do I know that eth0 corresponds to the the two-port network card and eth9 corresponds to the first 8-port network card?

Thanks!!

On Linux you could use ethtool -p eth0 to have the port flash the lights for identification. Note that this is pretty much Linux only, and ethtool isn't installed by default.

hmmm but you check it manually, I was wondering if I can get the answer by script...

something like this....

eth=eth0
if eth correspond to nw_card1
  echo "${eth} is port of nw card 1"
elif eth correspond to nw_card2
  echo "${eth} is port of nw card 2"
elif eth correspond to nw_card3
  echo "${eth} is port of nw card 3"

I need the commands for the if statements if there are any.. :wall:

thanks!