Re: Ethernet-multiple NICs and laptop

2000-05-11 Thread Jim Roland

After several hours at trial and error and my RHCE Study guide, I managed
to figure out what was wrong.  The RH 6.1 scripts for network startup are
expecting DEVICE to be assigned inside one of the eth-* scripts (formerly
ifcfg-eth*).  Since we were trying to keep away from that to avoid having
to manually config the network cards at each boot (eth0 and eth1 float
around), putting in a DEVICE= in the ifcfg-eth* scripts, I assumed was a
big no-no for what I was trying to accomplish.

I debugged the scripts, found the correct one and found that ifcfg-eth0 and
ifcfg-eth1 (a symb link to ifcfg-eth0) was being passed the $CONFIG
parameter, which had a value of "ifcfg-eth0" when eth0 was being setup (the
name of the script), and "ifcfg-eth1" when eth1 was being setup (and so
on).  I assigned DEVICE= inside your ifcfg-eth* script that you provided
me.

I managed to get my first sed (stream editor) formula written, and here is
what I did:
(added to your script)
# Since DEVICE is defined in here, we must define it based on what is
# passed for starting this script (ifup uses CONFIG which for eth0 is
# ifcfg-eth0):
DEVICE=`echo $CONFIG | sed -ne 's/.*ifcfg-/\1/p'`

This, in effect, takes the CONFIG parameter (value of "ifcfg-eth0") and
makes it "eth0" assigning that to DEVICE.

I also changed your last statement, since reboots were not reassigning the
tmp files you originally defined (/var/tmp/eth-docking, and so on) because
the test was checking for a zero length file, at shutdown, there was no
deletion of these tmp files if I undocked my Latitude (I could have put it
in a shutdown script I guess).

Therefore I changed:
[ -n "$USERDEVICENAME" ]  echo $DEVICE  /var/tmp/$USERDEVICENAME
to
echo $DEVICE  /var/tmp/$USERDEVICENAME

Which makes the /var/tmp/eth-docking or /var/tmp/eth-pcmcia get written
each time the system is booted.

Thanks for pointing me in the right direction.  I'm providing these changes
to the audience in the event there is another like me trying to get docking
and undocking profiles to work in RedHat.


-=Jim Roland
 
"Never settle with words what you can settle with a flamethrower."
--Anonymous
 

On Sat, 8 Apr 2000, Keith Owens wrote:

 Date: Sat, 08 Apr 2000 13:06:53 +1000
 From: Keith Owens [EMAIL PROTECTED]
 To: Jim Roland [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED], [EMAIL PROTECTED]
 Subject: Re: Ethernet-multiple NICs and laptop 
 
 On Thu, 6 Apr 2000 08:32:36 -0600 (CST), 
 Jim Roland [EMAIL PROTECTED] wrote:
 I have a port replicator with a 3Com 3C905C NIC built-in.  When I'm docked,
 my port replicator's NIC enables with eth0 and my PCMCIA network card
 enables with eth1.  When I'm undocked my PCMCIA card takes over eth0.  How
 do I get the PCMCIA card to ALWAYS use eth1???
 
 Don't bother trying.  eth0/eth1 are what the kernel calls the hardware
 and is always going to be hardware dependent.  The mistake is trying to
 override the kernel's hardware numbering, this mistake arises because
 the user wants to use eth0 and eth1 instead of "eth-pcmcia" and
 "eth-docking".  That is, you are trying to use a kernel construct as a
 user identifier.
 
 The solution to the problem of multiple NICs is to use separate kernel
 and user identifiers.  Anything in user space should use the user
 identifier to get the kernel identifier.  "Any problem can be solved by
 another level of indirection".
 
 Example.
 
 In directory /etc/sysconfig/network-scripts (this is RedHat, other
 distributions may use different names) there are ifup and ifdown
 scripts.  These are general scripts that obtain IP addresses and
 routing data from ifcfg-device, e.g. ifcfg-eth0.  Instead of hard
 coding the pcmcia data in ifcfg-eth0 and the docking station data in
 ifcfg-eth1, make the data dynamic.  Create two files in
 /etc/sysconfig/network-scripts for the pcmcia card and the docking
 station data, call them eth-pcmcia and eth-docking.  In those files you
 store the IP data for the relevant card, lines like
 
 # eth-pcmcia
 USERDEVICENAME=eth-pcmcia
 ONBOOT=no
 BOOTPROTO=dhcp
 
 # eth-docking
 USERDEVICENAME=eth-docking
 IPADDR=192.168.255.3
 NETMASK=255.255.255.0
 NETWORK=192.168.255.0
 BROADCAST=192.168.255.255
 GATEWAY=192.168.255.1
 ONBOOT=yes
 
 The job of ifcfg-eth[01] is now to work out which card is being
 accessed and to map the kernel identifier (eth[01]) to a user
 identifier (eth-{docking,pcmcia}).  This example ifcfg-eth0 script uses
 MAC addresses, replace the sample MAC addresses with your own.  If you
 do not like using MAC to identify cards, find some other way to
 identify which physical card is being configured.  Replace both the
 ifcfg-eth0 and ifcfg-eth1 files (make one a link to the other) with
 
 # ifcfg-eth*
 USERDEVICENAME=
 case `ifconfig $DEVICE | sed -ne 's/.*HWaddr *\([^ ]*\) */\1/p'` in
   00:10:A4:F3:A3:79) . eth-pcmcia;;   # read pcmcia data
   00:80:AD:79:82:D8) . eth-docking;;

Re: Ethernet-multiple NICs and laptop

2000-05-10 Thread Jim Roland

Sorry it has taken me so long to get back, but I finally got around to
modifying my system's scripts.  I'm having problems with the scripts you
gave me.

1) When docked (both eth0 (docking sta) and eth1 (pcmcia) active), eth0 is
configured correctly.  this part is good.
2) Either undocked (pcmcia only present) or docked, the pcmcia card, which
is supposed to be DHCP, does not work.  I have to manually get pump to run
by running it from the command line.
It's a 10/100 Cardbus card, and when not yet negotiates with the
hub (switch), both the 10 and 100 leds are lit.
When both leds are lit, ifconfig shows the MAC and eth0, but the
interface is not yet assigned an IP.
I then run "pump -i eth0" and it initializes and gets an IP.
If I use the old scripts, all works fine.
3) My /var/tmp/eth-* files are not written with just the one card in the 
system.
4) When I go to shutdown, the system screams about the MAC address being
wrong (the else condition of the case statement).  (When I start the system
up, it does not complain about a wrong MAC address--if I type it wrong in
the ifcfg-eth* file, it does complain as it should).

My scripts are identical to yours except for the MAC address and IP
addresses.

Can you help?


-=Jim Roland
 
"Never settle with words what you can settle with a flamethrower."
--Anonymous
 

On Sat, 8 Apr 2000, Keith Owens wrote:

 Date: Sat, 08 Apr 2000 13:06:53 +1000
 From: Keith Owens [EMAIL PROTECTED]
 To: Jim Roland [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED], [EMAIL PROTECTED]
 Subject: Re: Ethernet-multiple NICs and laptop 
 
 On Thu, 6 Apr 2000 08:32:36 -0600 (CST), 
 Jim Roland [EMAIL PROTECTED] wrote:
 I have a port replicator with a 3Com 3C905C NIC built-in.  When I'm docked,
 my port replicator's NIC enables with eth0 and my PCMCIA network card
 enables with eth1.  When I'm undocked my PCMCIA card takes over eth0.  How
 do I get the PCMCIA card to ALWAYS use eth1???
 
 Don't bother trying.  eth0/eth1 are what the kernel calls the hardware
 and is always going to be hardware dependent.  The mistake is trying to
 override the kernel's hardware numbering, this mistake arises because
 the user wants to use eth0 and eth1 instead of "eth-pcmcia" and
 "eth-docking".  That is, you are trying to use a kernel construct as a
 user identifier.
 
 The solution to the problem of multiple NICs is to use separate kernel
 and user identifiers.  Anything in user space should use the user
 identifier to get the kernel identifier.  "Any problem can be solved by
 another level of indirection".
 
 Example.
 
 In directory /etc/sysconfig/network-scripts (this is RedHat, other
 distributions may use different names) there are ifup and ifdown
 scripts.  These are general scripts that obtain IP addresses and
 routing data from ifcfg-device, e.g. ifcfg-eth0.  Instead of hard
 coding the pcmcia data in ifcfg-eth0 and the docking station data in
 ifcfg-eth1, make the data dynamic.  Create two files in
 /etc/sysconfig/network-scripts for the pcmcia card and the docking
 station data, call them eth-pcmcia and eth-docking.  In those files you
 store the IP data for the relevant card, lines like
 
 # eth-pcmcia
 USERDEVICENAME=eth-pcmcia
 ONBOOT=no
 BOOTPROTO=dhcp
 
 # eth-docking
 USERDEVICENAME=eth-docking
 IPADDR=192.168.255.3
 NETMASK=255.255.255.0
 NETWORK=192.168.255.0
 BROADCAST=192.168.255.255
 GATEWAY=192.168.255.1
 ONBOOT=yes
 
 The job of ifcfg-eth[01] is now to work out which card is being
 accessed and to map the kernel identifier (eth[01]) to a user
 identifier (eth-{docking,pcmcia}).  This example ifcfg-eth0 script uses
 MAC addresses, replace the sample MAC addresses with your own.  If you
 do not like using MAC to identify cards, find some other way to
 identify which physical card is being configured.  Replace both the
 ifcfg-eth0 and ifcfg-eth1 files (make one a link to the other) with
 
 # ifcfg-eth*
 USERDEVICENAME=
 case `ifconfig $DEVICE | sed -ne 's/.*HWaddr *\([^ ]*\) */\1/p'` in
   00:10:A4:F3:A3:79) . eth-pcmcia;;   # read pcmcia data
   00:80:AD:79:82:D8) . eth-docking;;  # read docking station data
   *) echo Unknown MAC address, please update ifcfg-eth0
 esac
 [ -n "$USERDEVICENAME" ]  echo $DEVICE  /var/tmp/$USERDEVICENAME
 
 Now it does not matter whether the kernel calls a network card eth0 or
 eth1 or even eth99.  The configure scripts assign the correct IP and
 routing data no matter what the kernel id is.  If you need to access
 the kernel id, use the value in /var/tmp/eth-*, e.g.
 
 route add -net 192.168.0.0 netmask 255.255.0.0 dev `cat /var/tmp/eth-docking`
 
 I use this technique on multi NIC boxes where device numbers have a
 tendency to move around as slots or IRQs or the kernel scan order
 changes.  Instead of trying to force the kernel into your order, accept
 whatever the kernel gives you and handle the mapping in user space.
 


-
To unsubsc

Re: Ethernet-multiple NICs and laptop

2000-04-08 Thread David Elliott

Actually, I think Windows does the equivilant of this in user space.  That is, it
internally numbers the devices as they appear just like Linux would, but then the
network code takes care of knowing which interface is supposed to have which
settings.  So it's basically the same thing as this cool little hack.

Actually, I think Red Hat should fix their network scripts to do this.  That is,
configure the card based on the MAC address and not the kernel number.

Very good idea.

-Dave

Jim Roland wrote:

 Thanks!  That's exactly what I need.  I just wish the kernel and init
 understood laptop docking and undocking like (no flames please) Winblows
 does.  That's the only redeeming value to Winblows, IMHO.

  The job of ifcfg-eth[01] is now to work out which card is being
  accessed and to map the kernel identifier (eth[01]) to a user
  identifier (eth-{docking,pcmcia}).  This example ifcfg-eth0 script uses
  MAC addresses, replace the sample MAC addresses with your own.  If you
  do not like using MAC to identify cards, find some other way to
  identify which physical card is being configured.  Replace both the
  ifcfg-eth0 and ifcfg-eth1 files (make one a link to the other) with
 




Re: Ethernet-multiple NICs and laptop

2000-04-08 Thread Alan Cox

 And for the broken architectures with one MAC per machine and the same type of cards
 there has got to be some way to identify different cards.

One MAC per machine isnt broken. Its quite valid.

Alan




Re: Ethernet-multiple NICs and laptop

2000-04-08 Thread Jim Roland

Device ID number in the kudzu database shows different id #s for each
card.


---
Jim Roland, President
Roland Internet Services, "The host with the most"
Offering premier web, email and CGI custom programming.
Ask us about Frontpage98 Extensions!
http://www.roland.net/  [EMAIL PROTECTED]
---


On Sat, 8 Apr 2000, Alan Cox wrote:

 Date: Sat, 8 Apr 2000 20:44:21 +0100 (BST)
 From: Alan Cox [EMAIL PROTECTED]
 To: David Elliott [EMAIL PROTECTED]
 Cc: Alan Cox [EMAIL PROTECTED], Jim Roland [EMAIL PROTECTED],
 Keith Owens [EMAIL PROTECTED], [EMAIL PROTECTED]
 Subject: Re: Ethernet-multiple NICs and laptop
 
  And for the broken architectures with one MAC per machine and the same type of 
cards
  there has got to be some way to identify different cards.
 
 One MAC per machine isnt broken. Its quite valid.
 
 Alan
 




Re: Ethernet-multiple NICs and laptop

2000-04-08 Thread David Elliott

I completely forgot about kudzu, probably because it usually works so damn well it's 
pretty
easy to forget about it.

Using kudzu id's would be a very good idea for the network scripts.

-Dave

Jim Roland wrote:

 Device ID number in the kudzu database shows different id #s for each
 card.

 ---
 Jim Roland, President
 Roland Internet Services, "The host with the most"
 Offering premier web, email and CGI custom programming.
 Ask us about Frontpage98 Extensions!
 http://www.roland.net/  [EMAIL PROTECTED]
 ---

 On Sat, 8 Apr 2000, Alan Cox wrote:

  Date: Sat, 8 Apr 2000 20:44:21 +0100 (BST)
  From: Alan Cox [EMAIL PROTECTED]
  To: David Elliott [EMAIL PROTECTED]
  Cc: Alan Cox [EMAIL PROTECTED], Jim Roland [EMAIL PROTECTED],
  Keith Owens [EMAIL PROTECTED], [EMAIL PROTECTED]
  Subject: Re: Ethernet-multiple NICs and laptop
 
   And for the broken architectures with one MAC per machine and the same type of 
cards
   there has got to be some way to identify different cards.
 
  One MAC per machine isnt broken. Its quite valid.
 
  Alan
 




Re: Ethernet-multiple NICs and laptop

2000-04-08 Thread Alan Cox

 Actually, I think Red Hat should fix their network scripts to do this.  That is,
 configure the card based on the MAC address and not the kernel number.

MAC address does not have to be unique per card. On older Sparcs for example
its unique per host which rather ruins the idea.

Alan




Re: Ethernet-multiple NICs and laptop

2000-04-08 Thread Jim Roland

Thanks!  That's exactly what I need.  I just wish the kernel and init
understood laptop docking and undocking like (no flames please) Winblows
does.  That's the only redeeming value to Winblows, IMHO.


---
Jim Roland, President
Roland Internet Services, "The host with the most"
Offering premier web, email and CGI custom programming.
Ask us about Frontpage98 Extensions!
http://www.roland.net/  [EMAIL PROTECTED]
---


On Sat, 8 Apr 2000, Keith Owens wrote:

 Date: Sat, 08 Apr 2000 13:06:53 +1000
 From: Keith Owens [EMAIL PROTECTED]
 To: Jim Roland [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED], [EMAIL PROTECTED]
 Subject: Re: Ethernet-multiple NICs and laptop 
 
 On Thu, 6 Apr 2000 08:32:36 -0600 (CST), 
 Jim Roland [EMAIL PROTECTED] wrote:
 I have a port replicator with a 3Com 3C905C NIC built-in.  When I'm docked,
 my port replicator's NIC enables with eth0 and my PCMCIA network card
 enables with eth1.  When I'm undocked my PCMCIA card takes over eth0.  How
 do I get the PCMCIA card to ALWAYS use eth1???
 
 Don't bother trying.  eth0/eth1 are what the kernel calls the hardware
 and is always going to be hardware dependent.  The mistake is trying to
 override the kernel's hardware numbering, this mistake arises because
 the user wants to use eth0 and eth1 instead of "eth-pcmcia" and
 "eth-docking".  That is, you are trying to use a kernel construct as a
 user identifier.
 
 The solution to the problem of multiple NICs is to use separate kernel
 and user identifiers.  Anything in user space should use the user
 identifier to get the kernel identifier.  "Any problem can be solved by
 another level of indirection".
 
 Example.
 
 In directory /etc/sysconfig/network-scripts (this is RedHat, other
 distributions may use different names) there are ifup and ifdown
 scripts.  These are general scripts that obtain IP addresses and
 routing data from ifcfg-device, e.g. ifcfg-eth0.  Instead of hard
 coding the pcmcia data in ifcfg-eth0 and the docking station data in
 ifcfg-eth1, make the data dynamic.  Create two files in
 /etc/sysconfig/network-scripts for the pcmcia card and the docking
 station data, call them eth-pcmcia and eth-docking.  In those files you
 store the IP data for the relevant card, lines like
 
 # eth-pcmcia
 USERDEVICENAME=eth-pcmcia
 ONBOOT=no
 BOOTPROTO=dhcp
 
 # eth-docking
 USERDEVICENAME=eth-docking
 IPADDR=192.168.255.3
 NETMASK=255.255.255.0
 NETWORK=192.168.255.0
 BROADCAST=192.168.255.255
 GATEWAY=192.168.255.1
 ONBOOT=yes
 
 The job of ifcfg-eth[01] is now to work out which card is being
 accessed and to map the kernel identifier (eth[01]) to a user
 identifier (eth-{docking,pcmcia}).  This example ifcfg-eth0 script uses
 MAC addresses, replace the sample MAC addresses with your own.  If you
 do not like using MAC to identify cards, find some other way to
 identify which physical card is being configured.  Replace both the
 ifcfg-eth0 and ifcfg-eth1 files (make one a link to the other) with
 
 # ifcfg-eth*
 USERDEVICENAME=
 case `ifconfig $DEVICE | sed -ne 's/.*HWaddr *\([^ ]*\) */\1/p'` in
   00:10:A4:F3:A3:79) . eth-pcmcia;;   # read pcmcia data
   00:80:AD:79:82:D8) . eth-docking;;  # read docking station data
   *) echo Unknown MAC address, please update ifcfg-eth0
 esac
 [ -n "$USERDEVICENAME" ]  echo $DEVICE  /var/tmp/$USERDEVICENAME
 
 Now it does not matter whether the kernel calls a network card eth0 or
 eth1 or even eth99.  The configure scripts assign the correct IP and
 routing data no matter what the kernel id is.  If you need to access
 the kernel id, use the value in /var/tmp/eth-*, e.g.
 
 route add -net 192.168.0.0 netmask 255.255.0.0 dev `cat /var/tmp/eth-docking`
 
 I use this technique on multi NIC boxes where device numbers have a
 tendency to move around as slots or IRQs or the kernel scan order
 changes.  Instead of trying to force the kernel into your order, accept
 whatever the kernel gives you and handle the mapping in user space.
 




Re: Ethernet-multiple NICs and laptop

2000-04-08 Thread Ed Carp

Alan Cox ([EMAIL PROTECTED]) writes:

  Actually, I think Red Hat should fix their network scripts to do this.  That is,
  configure the card based on the MAC address and not the kernel number.
 
 MAC address does not have to be unique per card. On older Sparcs for example
 its unique per host which rather ruins the idea.

Didn't IBM make Ethernet cards with programmable MAC addresses at one time?



Re: Ethernet-multiple NICs and laptop

2000-04-08 Thread Jeff Garzik

Ed Carp wrote:
 
 Alan Cox ([EMAIL PROTECTED]) writes:
 
   Actually, I think Red Hat should fix their network scripts to do this.  That is,
   configure the card based on the MAC address and not the kernel number.
 
  MAC address does not have to be unique per card. On older Sparcs for example
  its unique per host which rather ruins the idea.
 
 Didn't IBM make Ethernet cards with programmable MAC addresses at one time?

This question was answered in a thread not two weeks ago :)

Many Ethernet cards allow you to change the MAC address advertised to
the network; however it is generally not a good idea to do so...

-- 
Jeff Garzik  | Nothing cures insomnia like the
Building 1024| realization that it's time to get up.
MandrakeSoft, Inc.   |-- random fortune



Re: Ethernet-multiple NICs and laptop

2000-04-07 Thread Keith Owens

On Thu, 6 Apr 2000 08:32:36 -0600 (CST), 
Jim Roland [EMAIL PROTECTED] wrote:
I have a port replicator with a 3Com 3C905C NIC built-in.  When I'm docked,
my port replicator's NIC enables with eth0 and my PCMCIA network card
enables with eth1.  When I'm undocked my PCMCIA card takes over eth0.  How
do I get the PCMCIA card to ALWAYS use eth1???

Don't bother trying.  eth0/eth1 are what the kernel calls the hardware
and is always going to be hardware dependent.  The mistake is trying to
override the kernel's hardware numbering, this mistake arises because
the user wants to use eth0 and eth1 instead of "eth-pcmcia" and
"eth-docking".  That is, you are trying to use a kernel construct as a
user identifier.

The solution to the problem of multiple NICs is to use separate kernel
and user identifiers.  Anything in user space should use the user
identifier to get the kernel identifier.  "Any problem can be solved by
another level of indirection".

Example.

In directory /etc/sysconfig/network-scripts (this is RedHat, other
distributions may use different names) there are ifup and ifdown
scripts.  These are general scripts that obtain IP addresses and
routing data from ifcfg-device, e.g. ifcfg-eth0.  Instead of hard
coding the pcmcia data in ifcfg-eth0 and the docking station data in
ifcfg-eth1, make the data dynamic.  Create two files in
/etc/sysconfig/network-scripts for the pcmcia card and the docking
station data, call them eth-pcmcia and eth-docking.  In those files you
store the IP data for the relevant card, lines like

# eth-pcmcia
USERDEVICENAME=eth-pcmcia
ONBOOT=no
BOOTPROTO=dhcp

# eth-docking
USERDEVICENAME=eth-docking
IPADDR=192.168.255.3
NETMASK=255.255.255.0
NETWORK=192.168.255.0
BROADCAST=192.168.255.255
GATEWAY=192.168.255.1
ONBOOT=yes

The job of ifcfg-eth[01] is now to work out which card is being
accessed and to map the kernel identifier (eth[01]) to a user
identifier (eth-{docking,pcmcia}).  This example ifcfg-eth0 script uses
MAC addresses, replace the sample MAC addresses with your own.  If you
do not like using MAC to identify cards, find some other way to
identify which physical card is being configured.  Replace both the
ifcfg-eth0 and ifcfg-eth1 files (make one a link to the other) with

# ifcfg-eth*
USERDEVICENAME=
case `ifconfig $DEVICE | sed -ne 's/.*HWaddr *\([^ ]*\) */\1/p'` in
00:10:A4:F3:A3:79) . eth-pcmcia;;   # read pcmcia data
00:80:AD:79:82:D8) . eth-docking;;  # read docking station data
*) echo Unknown MAC address, please update ifcfg-eth0
esac
[ -n "$USERDEVICENAME" ]  echo $DEVICE  /var/tmp/$USERDEVICENAME

Now it does not matter whether the kernel calls a network card eth0 or
eth1 or even eth99.  The configure scripts assign the correct IP and
routing data no matter what the kernel id is.  If you need to access
the kernel id, use the value in /var/tmp/eth-*, e.g.

route add -net 192.168.0.0 netmask 255.255.0.0 dev `cat /var/tmp/eth-docking`

I use this technique on multi NIC boxes where device numbers have a
tendency to move around as slots or IRQs or the kernel scan order
changes.  Instead of trying to force the kernel into your order, accept
whatever the kernel gives you and handle the mapping in user space.