LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
Search this Thread
Old 03-30-2005, 07:59 PM   #1
the-sloth
LQ Newbie
 
Registered: Mar 2005
Posts: 6

Rep: Reputation: 0
how do i assign/switch eth0 & eth1


running slack 10.1 on my thinkpad and after install the ethernet card worked.... a couple days later i got the wireless card working and they were both fighting over eth0. i did a

ifconfig eth1 up

and it looks like the ethernet card is now eth1 instead of eth0. how can i make sure all this is set up right and they aren't fighting with each other.
 
Old 03-31-2005, 06:30 AM   #2
keefaz
Senior Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 4,444

Rep: Reputation: 94
Edit /etc/modprobe.conf (for 2.6 kernel) or /etc/modules.conf (for 2.4 kernel)

and add something like
alias eth0 <your module name>
 
Old 07-22-2006, 05:35 PM   #3
Liefmans
LQ Newbie
 
Registered: Oct 2005
Location: Germany & Belgium
Distribution: debian
Posts: 24

Rep: Reputation: 15
I had the same problem on my debian machine (kernel 2.6) and the solution is slightly different:

there is no file /etc/modprobe.conf and creating one doesn't help. You should use a file under the /etc/modprobe.d directory or create a new one.

Anyway, thanks for the tip.
 
Old 07-23-2006, 04:17 AM   #4
Liefmans
LQ Newbie
 
Registered: Oct 2005
Location: Germany & Belgium
Distribution: debian
Posts: 24

Rep: Reputation: 15
alias eth0 <module name> didn't work . My cards swapped today!

I added now:

Code:
options <module name> index=0
Currently, it works but I don't know if it stays like that because I couldn't find back the meaning of the index option. I used the analogy for loading the sound .
 
Old 07-23-2006, 09:42 AM   #5
peter_robb
Senior Member
 
Registered: Feb 2002
Location: Szczecin, Poland
Distribution: Gentoo, Debian
Posts: 2,458

Rep: Reputation: 47
The first module to load gets to be eth0..
So the trick is to make sure your eth nic module loads before the wireless nic module.
This order is handled by hotplug and the order of lines in /etc/rc.d/rc.modules

Make sure your eth nic module is specified earlier than your wireless module.

This thread explains.. http://www.linuxquestions.org/questi...d.php?t=376429

Last edited by peter_robb; 07-23-2006 at 09:54 AM.
 
Old 07-23-2006, 09:58 AM   #6
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 70
If you wanted, another solution involves using udev rules to assign interface names based on MAC addresses. For older kernels (2.4) there are utilities that do this as well (ifrename, nameif, etc.).
 
Old 07-23-2006, 10:24 AM   #7
peter_robb
Senior Member
 
Registered: Feb 2002
Location: Szczecin, Poland
Distribution: Gentoo, Debian
Posts: 2,458

Rep: Reputation: 47
The utilities work after the interface is up..
I'd say it's better to do it from the boot sequence, then use those tools to tidy up any last bits, eg 4 NICs all the same chipset..

Last edited by peter_robb; 07-23-2006 at 10:41 AM.
 
Old 07-23-2006, 12:33 PM   #8
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 70
Quote:
Originally Posted by peter_robb
The utilities work after the interface is up..
Not exactly. They work after the loading of the driver, but not necessarily after the interfaces are up (you can put it in the boot sequence right after modprobing but before ifup/down).

Nevertheless, (assuming a recent distro) udev rules take place as the drivers are being loaded. This way, you are closest to the kernel naming scheme. And you won't get problems, if, for example you have the drivers for both NICs built-in to the kernel (instead of modules).

A lot of people compile drivers into the kernel, and then realize, that after a kernel upgrade, the internal order of loading drivers had inadvertently been switched, so the interface names are backwards. Udev rules can fix this.
 
Old 07-23-2006, 01:10 PM   #9
peter_robb
Senior Member
 
Registered: Feb 2002
Location: Szczecin, Poland
Distribution: Gentoo, Debian
Posts: 2,458

Rep: Reputation: 47
The udev flexibility is certainly great.
It's a pity about the learning curve tho'.
Let's hope we can get something entered into the LQ Wiki for future reference..
 
Old 07-24-2006, 02:17 PM   #10
Liefmans
LQ Newbie
 
Registered: Oct 2005
Location: Germany & Belgium
Distribution: debian
Posts: 24

Rep: Reputation: 15
FYI, my earlier writing doesn't work neither. I found out that my cards swap when I make a reboot . Nevertheless, the tip from osor seems to work and udev isn't that difficult! http://www.reactivated.net/writing_udev_rules.html has a good description on how to do it.

I used following procedure (debian, kernel 2.6):
via
Code:
udevinfo -a -p /sys/class/net/eth0 and
udevinfo -a -p /sys/class/net/eth1
I identified my MAC-addresses:
Code:
SYSFS{address}=="00:52:8b:d5:04:48"
SYSFS{address}=="00:00:6c:a3:39:9a"
I created the file /etc/udev/rules.d/10-local.rules and added the lines:
Code:
KERNEL=="eth*", SYSFS{address}=="00:52:8b:d5:04:48", NAME="lan
KERNEL=="eth*", SYSFS{address}=="00:00:6c:a3:39:9a", NAME="wlan"
I updated now my scripts (e.g. /etc/network/interfaces) and instead of referring to eth0 and eth1, I refer now to lan and wlan.

udev seems to me a great tool! I am looking for a strategy on how to load my modules. At the moment, it is a real mess (and I think that this is the root cause why my cards were swapping all the time). It seems to me that udev will be great help to structure my module loading. If anyone has tips or has his own strategy on module loading, they are always welcome (but maybe we can open a new thread for that)

Last edited by Liefmans; 07-24-2006 at 02:20 PM.
 
Old 02-05-2011, 12:48 PM   #11
ilopez
LQ Newbie
 
Registered: Feb 2011
Posts: 1

Rep: Reputation: 0
Unhappy Help

Hi everybody, I have a similar problem, let me explain you, I have a Debian 5.0.5 64bits kernel 2.6.26-2-amd64, running over VmWare esxi 4.1, the hardware has 4 network adapters and Debian can see the 4 adapters, well my problem is that every time a shutdown the Debian with init 0 the ips change their physical port, I have tried a lot of things like the udev rules changing the names of the interfaces, I have tried also the aliases in the /etc/modprobe.d/aliases, I have also tried to give always the same MAC write them manually in vmware but nothing, every time I use "init 0" the ips change their position, another thing, if a I use init 6 the ips stay in the same place they were last time. I don't know what else to do, please help me.
 
  


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
eth0 and eth1 switch cards at run time! haxcess Linux - Networking 8 12-12-2005 04:17 PM
Mandrake is switching the eth1 and eth0 interfaces... how can I switch them back? LaptopLinux Mandriva 3 03-28-2005 09:23 PM
How do you switch the default ethernet adapter (eth0 to eth1)? scoobdoobery Linux - Networking 3 09-05-2004 01:29 PM
Swapping eth0 & eth1? sarah_t_s Slackware 6 07-25-2004 11:14 AM
eth0 & eth1 switched superbondbond Linux - Hardware 5 12-12-2003 08:59 AM


All times are GMT -5. The time now is 10:23 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration