Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Multiple NIC mapping [SOLVED+HOWTO]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
danomac
l33t
l33t


Joined: 06 Nov 2004
Posts: 881
Location: Vancouver, BC

PostPosted: Sat Aug 12, 2006 5:35 pm    Post subject: Multiple NIC mapping [SOLVED+HOWTO] Reply with quote

Where to start...

I have 3 NICs in a PC, and I'm wondering how the kernel determines the order they are mapped in. I need to set up 2 as static and one as DHCP, so if eth0 becomes eth1 and vice versa on a reboot, it'll seriously muck things up and the PC's database won't be able to synchronize with another PC.

Is there a way to define a static way to define the mapping? All net modules are compiled directly in the kernel, and 2 of the NICs are of the same chipset.

lspci:
Code:

00:0a.0 Ethernet controller: Linksys NC100 Network Everywhere Fast Ethernet 10/100 (rev 11)
00:0b.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL-8139/8139C/8139C+ (rev 10)
00:13.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL-8139/8139C/8139C+ (rev 10)


dmesg: (the onboard LAN got named to eth1? I figured it'd be eth0, but oh well...)
Code:

eth0: RealTek RTL8139 at 0xe800, 00:30:bd:bb:25:e8, IRQ 10
eth0:  Identified 8139 chip type 'RTL-8100B/8139D'
eth1: RealTek RTL8139 at 0xd400, 00:20:ed:68:45:ec, IRQ 10
eth1:  Identified 8139 chip type 'RTL-8100B/8139D'
eth2: ADMtek Comet rev 17 at f880ec00, 00:50:BF:AE:E9:DC, IRQ 10.


ifconfig -a
Code:

eth0      Link encap:Ethernet  HWaddr 00:30:BD:BB:25:E8
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
          Interrupt:10 Base address:0xe800

eth1      Link encap:Ethernet  HWaddr 00:20:ED:68:45:EC
          inet addr:192.168.247.80  Bcast:192.168.247.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2976 errors:0 dropped:0 overruns:0 frame:0
          TX packets:834 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:241888 (236.2 Kb)  TX bytes:70030 (68.3 Kb)
          Interrupt:10 Base address:0xd400

eth2      Link encap:Ethernet  HWaddr 00:50:BF:AE:E9:DC
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
          Interrupt:10 Base address:0xec00


The NICs are all detected and working. Before I do this final configuration I wanted to see if it could possibly change the mapping on me.


Last edited by danomac on Wed Aug 16, 2006 4:58 am; edited 2 times in total
Back to top
View user's profile Send private message
nielchiano
Veteran
Veteran


Joined: 11 Nov 2003
Posts: 1287
Location: 50N 3E

PostPosted: Sat Aug 12, 2006 10:17 pm    Post subject: Reply with quote

IIRC, there are 2 ways: the old nameif-way, and the much better udev way.

For the second way, see this guide. It's best to read it all, but the link should point directly to the interesting part.
You can change eth0 to eth1, but even (like I do) to eth_int or eth_wlan
Back to top
View user's profile Send private message
danomac
l33t
l33t


Joined: 06 Nov 2004
Posts: 881
Location: Vancouver, BC

PostPosted: Sun Aug 13, 2006 1:41 am    Post subject: Reply with quote

Perfect, thanks... now I can make sure by MAC address that eth1 is the physical port I think it is. :)
Back to top
View user's profile Send private message
nielchiano
Veteran
Veteran


Joined: 11 Nov 2003
Posts: 1287
Location: 50N 3E

PostPosted: Sun Aug 13, 2006 7:45 am    Post subject: Reply with quote

danomac wrote:
Perfect, thanks... now I can make sure by MAC address that eth1 is the physical port I think it is. :)

Glad it helped.
Could you add [solved] in the subject?
Back to top
View user's profile Send private message
danomac
l33t
l33t


Joined: 06 Nov 2004
Posts: 881
Location: Vancouver, BC

PostPosted: Sun Aug 13, 2006 6:58 pm    Post subject: Reply with quote

nielchiano wrote:
Could you add [solved] in the subject?


Done. :)
Back to top
View user's profile Send private message
Bob P
Advocate
Advocate


Joined: 20 Oct 2004
Posts: 3355
Location: Jackass! Development Labs

PostPosted: Tue Aug 15, 2006 12:57 pm    Post subject: Reply with quote

danomac wrote:
Perfect, thanks... now I can make sure by MAC address that eth1 is the physical port I think it is. :)


insofar as rewriting the udev rules requires you to reconfigure all of your system interfaces, execution of this method is a little complicated. writing the udev rules is simple enough following @dsd's guide, but then the user is also required to rewrite all of the references to the hardware interfaces on the system as well.

could you do us all a favor and document what you've done to achieve a working configuration? specifically, the modifications to /etc/init.d, /etc/conf.d, and your firewall configs would be a real time saver.

thanks!
_________________
.
Stage 1/3 | Jackass! | Rockhopper! | Thanks | Google Sucks
Back to top
View user's profile Send private message
nielchiano
Veteran
Veteran


Joined: 11 Nov 2003
Posts: 1287
Location: 50N 3E

PostPosted: Tue Aug 15, 2006 1:03 pm    Post subject: Reply with quote

Bob P wrote:
could you do us all a favor and document what you've done to achieve a working configuration? specifically, the modifications to /etc/init.d, /etc/conf.d, and your firewall configs would be a real time saver.

Isn't realy hard to find that out yourself, but here is mine:
Code:

cd /etc/udev/rules.d
cat > 10-local.rules <<EOF
KERNEL="eth*", SYSFS{address}="00:51:8c:a3:12:83", NAME="eth_wlan"
EOF
reboot
Back to top
View user's profile Send private message
danomac
l33t
l33t


Joined: 06 Nov 2004
Posts: 881
Location: Vancouver, BC

PostPosted: Wed Aug 16, 2006 4:14 am    Post subject: Reply with quote

Bob P wrote:
could you do us all a favor and document what you've done to achieve a working configuration? specifically, the modifications to /etc/init.d, /etc/conf.d, and your firewall configs would be a real time saver.

thanks!


Bob P, I know what you mean. You mean to have everything [i.e all the initscripts and configs] set up correctly so that the system is aware of a system-wide change, correct? Gentoo's initscripts make this somewhat easy, I found out.

This has been moved to the Documentation, Tips & Tricks forum.

Is this enough information? :wink: The bonus of setting it up this way is that if you have to stop a specific interface for whatever reason, you don't have to try to remember if it was eth0, 1, 2, 3 etc. Worth the mucking about and experimenting I did, I think.


Last edited by danomac on Fri Feb 02, 2007 4:56 pm; edited 4 times in total
Back to top
View user's profile Send private message
danomac
l33t
l33t


Joined: 06 Nov 2004
Posts: 881
Location: Vancouver, BC

PostPosted: Wed Aug 16, 2006 4:34 am    Post subject: Reply with quote

Hmm, maybe I should copy the howto over to the Tips forum.
Back to top
View user's profile Send private message
Bob P
Advocate
Advocate


Joined: 20 Oct 2004
Posts: 3355
Location: Jackass! Development Labs

PostPosted: Sat Aug 19, 2006 1:35 pm    Post subject: Reply with quote

Thanks for your detailed tips. I had done the udev thing, and ran into a problem when I renamed the interfaces with an alias. I had renamed eth0, eth1 and eth2 to wan, lan, and dmz, respectively. this seemed to be intuitively obvious and user-friendly naming scheme at the time.

Although the udev rules worked fine, the problem that came up was that the aliasing names really borked shorewall. to get the udev aliases to work, I would have had to rewrite all of the shorewall scripts, replacing all references to eth0, etc. that seemed like an unnecessarily burdensome task, which was something i didn't want to undertake. i was hoping that you had a simple answer, and while i waited for your response i tried another approach.

my approach was to alias all of the eth* statements in udev to rename the devices with the aliases eth0, eth1 and eth2. although it may seem like doing this would be frought with errors, you can do it this way if you're careful enough to perform the assignments in the right order, and assign the interfaces in the numeric order that they're detected by bios on your mobo. (ie: slot ordering). this prevents the user from having to rewrite all of their network dependent scripts. the only downside i've noticed is the undesirable side effect of forcing you to pay attention to slot ordering if you should ever have to change a NIC again.

all things consdiered, its probably just as easy (or even easier) to just pass the ethernet interface configuration information, including the base address and interrupt , via the kernel parameters specificed in grub.conf. as we all know, udev implementation is still incomplete, its still kind of buggy, and over all its still a rapidly moving target in gentoo. at times i wonder if what i work on with udev today will still work next week or next month. :?

thanks again.
_________________
.
Stage 1/3 | Jackass! | Rockhopper! | Thanks | Google Sucks
Back to top
View user's profile Send private message
danomac
l33t
l33t


Joined: 06 Nov 2004
Posts: 881
Location: Vancouver, BC

PostPosted: Sat Aug 19, 2006 8:53 pm    Post subject: Reply with quote

I've posted it the Documentation, Tips & Tricks forum here as well.

When it comes to configuring iptables/firewalls there's no real easy way other than aliases like you mentioned or editing the scripts. I'd just use grep and see where eth? is mentioned and run a script or something to change the references.

Edit: Wouldn't shorewall have a way to specify the interfaces you are using? I don't use it, but it seems odd that it would just "assume" the WAN side is always eth0!
Back to top
View user's profile Send private message
Bob P
Advocate
Advocate


Joined: 20 Oct 2004
Posts: 3355
Location: Jackass! Development Labs

PostPosted: Mon Aug 21, 2006 9:01 pm    Post subject: Reply with quote

danomac wrote:
Edit: Wouldn't shorewall have a way to specify the interfaces you are using? I don't use it, but it seems odd that it would just "assume" the WAN side is always eth0!

well, accepted convention in the industry is that eth0 is ALWAYS the external interface. similarly, when building a firewall, this convention is followed and eth0 is defined as the external interface on the firewall. the LAN and DMZ are typically mapped to eth1 and eth2, again by convention.

the only "official" work that i've ever encountered that violates this convention is Mike Frysinger's Gentoo Home Router howto. IMHO that guide intentionally violates accepted conventions and teaches people to do things bass ackwards.
_________________
.
Stage 1/3 | Jackass! | Rockhopper! | Thanks | Google Sucks
Back to top
View user's profile Send private message
zxy
Veteran
Veteran


Joined: 06 Jan 2006
Posts: 1160
Location: in bed in front of the computer

PostPosted: Fri Sep 01, 2006 12:41 am    Post subject: Reply with quote

@danomac
You made a little mistake, or maybe udev changed.
You should use == instead of = in udev configuration file.
Code:
KERNEL=="eth*", SYSFS{address}=="??:??:??:??:??:??", NAME="eth_wan"
KERNEL=="eth*", SYSFS{address}=="??:??:??:??:??:??", NAME="eth_lan"

That's at least how it works for me.
_________________
Nature does not hurry, yet everything is accomplished.
Lao Tzu
Back to top
View user's profile Send private message
dtread
n00b
n00b


Joined: 18 Mar 2007
Posts: 10

PostPosted: Sat Aug 04, 2007 4:23 pm    Post subject: Setting eth0 Reply with quote

Good afternoon,

I would like to know if there is any way of configuring witch network adapter is eth0 and witch is eth1 and so on.

Regards
Back to top
View user's profile Send private message
nixnut
Bodhisattva
Bodhisattva


Joined: 09 Apr 2004
Posts: 10974
Location: the dutch mountains

PostPosted: Sat Aug 04, 2007 5:25 pm    Post subject: Reply with quote

merged above post here.
_________________
Please add [solved] to the initial post's subject line if you feel your problem is resolved. Help answer the unanswered

talk is cheap. supply exceeds demand
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum