How to find out the PCI address for a given ethernet device

This is something I was looking for since ages, because it could be useful for automating deployiments on bare metal.

When building bond interfaces, something you really want is to bond devices on different hardware paths, for example one embedded ethernet and one from a PCI lane.

On recent Linux systems (CentOS 6.x), you can use udevadm info to find out the PCI address for your interfaces:

# for E in eth{0..3} ; do echo $E ; udevadm info --query=path --path=/sys/class/net/${E} ; done
eth0
/devices/pci0000:00/0000:00:01.1/0000:02:00.0/net/eth0
eth1
/devices/pci0000:00/0000:00:01.1/0000:02:00.1/net/eth1
eth2
/devices/pci0000:00/0000:00:02.0/0000:04:00.0/net/eth2
eth3
/devices/pci0000:00/0000:00:02.0/0000:04:00.1/net/eth3

So on this system I want to bind eth0+2 and eth1+3.

For reference, I found the original info on this (outdated) Linux Questions post.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s