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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
04-30-2008, 05:09 PM
|
#1
|
LQ Newbie
Registered: Apr 2008
Location: Illinois
Distribution: Slackware 12.0
Posts: 8
Rep:
|
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
|
|
|
04-30-2008, 05:17 PM
|
#2
|
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:
|
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
|
|
|
04-30-2008, 07:56 PM
|
#3
|
Member
Registered: Dec 2007
Posts: 59
Rep:
|
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.
|
|
|
04-30-2008, 08:33 PM
|
#4
|
Moderator
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,949
|
Hi,
Quote:
Originally Posted by karrj
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'.
|
|
|
04-30-2008, 09:15 PM
|
#5
|
LQ Newbie
Registered: Apr 2008
Location: Illinois
Distribution: Slackware 12.0
Posts: 8
Original Poster
Rep:
|
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.
|
|
|
05-01-2008, 07:44 AM
|
#6
|
Moderator
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,949
|
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 04:50 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|