LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-30-2008, 05:09 PM   #1
karrj
LQ Newbie
 
Registered: Apr 2008
Location: Illinois
Distribution: Slackware 12.0
Posts: 8

Rep: Reputation: 0
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
 
Old 04-30-2008, 05:17 PM   #2
Brian1
LQ Guru
 
Registered: Jan 2003
Location: Seymour, Indiana
Distribution: Distribution: RHEL 5 with Pieces of this and that. Kernel 2.6.23.1, KDE 3.5.8 and KDE 4.0 beta, Plu
Posts: 5,700

Rep: Reputation: 65
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
 
Old 04-30-2008, 07:56 PM   #3
thveillon
Member
 
Registered: Dec 2007
Posts: 59

Rep: Reputation: 16
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.
 
Old 04-30-2008, 08:33 PM   #4
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,949
Blog Entries: 46

Rep: Reputation: 3182Reputation: 3182Reputation: 3182Reputation: 3182Reputation: 3182Reputation: 3182Reputation: 3182Reputation: 3182Reputation: 3182Reputation: 3182Reputation: 3182
Hi,

Quote:
Originally Posted by karrj View Post
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'.
 
Old 04-30-2008, 09:15 PM   #5
karrj
LQ Newbie
 
Registered: Apr 2008
Location: Illinois
Distribution: Slackware 12.0
Posts: 8

Original Poster
Rep: Reputation: 0
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.
 
Old 05-01-2008, 07:44 AM   #6
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,949
Blog Entries: 46

Rep: Reputation: 3182Reputation: 3182Reputation: 3182Reputation: 3182Reputation: 3182Reputation: 3182Reputation: 3182Reputation: 3182Reputation: 3182Reputation: 3182Reputation: 3182
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Copying/routing data from eth0 to eth1 and eth2 theVOID Linux - Networking 3 04-14-2008 06:30 AM
Resetting network interface to eth1 & eth2 kushalkoolwal Debian 15 08-24-2007 10:01 AM
how to reset eth2 eth3 on SUSE ??? achulxp Linux - Hardware 2 12-31-2006 01:30 AM
eth0 - eth1 - eth2 and how to determine which driver they are using vharishankar Linux - Networking 7 06-02-2005 10:52 PM
eth0 eth1 and eth2 on boot sergiodemoura Linux - Newbie 4 12-03-2003 01:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:50 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration