LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to determine which physical interface corresonds to eth0, eth1, eth2, and eth3 (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-determine-which-physical-interface-corresonds-to-eth0-eth1-eth2-and-eth3-638984/)

karrj 04-30-2008 05:09 PM

How to determine which physical interface corresonds to eth0, eth1, eth2, and eth3
 
What is the best way to dermine which physical interface corresponds to eth0, eth1, eth2, and eth3 on a server with 4 ethernet ports? It seems like eth0 sometines refers to one interface and upon a reboot in conjunction with a cable swap eth0 now corresponds to another interface. Is there a command that will say eth0 is the Broadcom or eth0 is port 1 on the PCI dual NIC Intel card, etc.

Thanks - John

Brian1 04-30-2008 05:17 PM

I would somewhere there would be references to MAC addresses on the hardware and from that compare output to ifconfig -a. If say all on a single card normally I would say the docs of the hardware point out which port is first, second, thrid and so on. If MAC are sequencal then the lowest normally goes to eth0 and so on.

Brian

thveillon 04-30-2008 07:56 PM

I'm going to quote another thread on a similar subject :

Quote:

So network cards are managed by a helper program called "udev". Udev is great because it can managed dynamically the removal/addition of hardware, but it's attributing names to devices in it's own kind of way. For network cards names need to be consistent from one boot to the next, so udev is associating the conventional interface name (eth*) to it's unique MAC address (MAC address is build inside the device itself).

Those associations are stored in the folder /etc/udev/rules.d/ where you will find a "yx_persistent-net.rules" file ("yx" are random numbers, depends on your system).

The "rules" udev use to name the devices are of the form :

Code:

SUBSYSTEM=="net", DRIVERS=="?*", ATTR{address}=="xx:xx:xx:xx:xx:xx", NAME="eth0"
(the xx:xx:xx... pattern will be replaced by a MAC address)

All you need to do is reading your actual network card MAC address with :

Code:

sudo /sbin/ifconfig -a
("-a" option lists even non configured devices) , it will look like "HWaddr 00:1d:20:55:cf:67", and write this MAC address in the udev rule corresponding to the conventional name that suites you (eth0 for instance). You can delete old rules, add new ones for other cards.

You will need root privileges to edit the "yx_persistent-net.rules" file.

Reboot when done (restarting the network should be enough though...)
This way you will get consistent naming of the interfaces, and static one.

onebuck 04-30-2008 08:33 PM

Hi,

Quote:

Originally Posted by karrj (Post 3138128)
What is the best way to dermine which physical interface corresponds to eth0, eth1, eth2, and eth3 on a server with 4 ethernet ports? It seems like eth0 sometines refers to one interface and upon a reboot in conjunction with a cable swap eth0 now corresponds to another interface. Is there a command that will say eth0 is the Broadcom or eth0 is port 1 on the PCI dual NIC Intel card, etc.

Thanks - John

You can look at your '/etc/udev/rules.d/75-network-devices.rules'.

karrj 04-30-2008 09:15 PM

Thanks for the information
 
This helps - appreciate it.

A little more background as to what I was doing. I just installed Slakware 12 and I have 4 ethernet ports all connected to a switch. Let's say each port is in the same VLAN. Then I config eth0 and can ping it from a different host in the same subnet. Now I want to introduce VLANs into the scenario in order to put the other interfaces in different subnets for some testing with tcpreplay I plan to do. First I scratch my head and say okay which int is actually eth0. I figure I will do a continuous ping and pull each cable one at a time until the ping is interupted. This did not work as easily as I thought it would, as the ping would stop even when I pulled a cable on one of the other 3 unconfigured ports, and was slow to restart when I restored cables.????

The bottom line is it sounds like if I know what MAC address corresponds to each physical interface I can assign the label assigned to those ports, and this label is used in commands like ifconfig, etc. This assignment occurs in the file in the response to my initial post.
Those associations are stored in the folder /etc/udev/rules.d/ where you will find a "yx_persistent-net.rules" file ("yx" are random numbers, depends on your system).

Now getting the MAC address for each physical port and knowing which port it actually is may require an empirical approach if I do not have documentation on this. I could configure one at a time and determine the MAC address of each.

Once assigned does the label stay attached to the physical interface for subsequent boots? Even if I remove a cable or two and perhaps switch others? While I was testing it appeared eth0 was jumpoing around between the 4 interfaces.

Finally, can you tell me the command to stop and restart the network service?

Thanks - appreciate all the help.

onebuck 05-01-2008 07:44 AM

Hi,

The card will physically have the MAC address assignment indicated on the PCB. The MAC is assigned to the manufacture ID.

Your '/etc/udev/rules.d/75-network-devices.rules' will have the assignments for the kernel. Just pulling the cable will not get you anywhere, causes other problems.

You can use the '/etc/rc.d/rc.inet1 'start/restart/stop' to control the inet.


All times are GMT -5. The time now is 03:53 PM.