Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
different /etc/conf.d/net files at boot based on runlevel?
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
SirronD
Guest





PostPosted: Wed May 15, 2002 1:59 am    Post subject: different /etc/conf.d/net files at boot based on runlevel? Reply with quote

I have a IBM Thinkpad with a built in lan (eepro100 - and eth0). I also have a linksys wan card (pcmcia_core, i82365, ds, orinoco orinoco_cs - and eth1).

They both work well, but I need a way to selectively (at boot) choose which one to use (but have the same static IP and gateway).

So I did the following
1. create seperate "gentoo" runlevels named xdm-lan and xdm-wan. And in xdm-lan there is a link to /etc/init.d/net.eth0, and in xdm-wan there is a link to /etc/init.d/net.eth1
2. modified the depend in net.eth1 to need pcmcia
3. added seperate menus in grub with one for runlevel 5 (xdm-lan) and the other to runlevel 4 (xdm-wan).
4. modified /etc/inittab to point to xdm-wan and xdm-lan at runlevels 4 and 5.

Each "runlevel" works correctly except for one BIG problem, and that is
/etc/conf.d/net.

How do I properly define my gateway as eth0 or eth1 depending on which runlevel I choose? Somehow /etc/init.d/net.eth0 and /etc/init.d/net.eth1 both point to the same /etc/conf.d/net script and so I always must manually switch my gateway after logging in.
Back to top
klieber
Bodhisattva
Bodhisattva


Joined: 17 Apr 2002
Posts: 3657
Location: San Francisco, CA

PostPosted: Wed May 15, 2002 3:35 pm    Post subject: Re: different /etc/conf.d/net files at boot based on runleve Reply with quote

SirronD wrote:
Somehow /etc/init.d/net.eth0 and /etc/init.d/net.eth1 both point to the same /etc/conf.d/net script and so I always must manually switch my gateway after logging in.


Unless I'm misunderstanding your quesiton, you would define both gateways in the same /etc/conf.d/net script:

Code:
gateway="eth0/192.168.2.1"
gateway="eth1/192.168.1.1"


Then, the right gateway should get defined correctly no matter which eth interface you start.

--kurt
_________________
The problem with political jokes is that they get elected
Back to top
View user's profile Send private message
Guest






PostPosted: Fri May 17, 2002 5:41 am    Post subject: Doesn't work if both gateways are defined in /etc/conf.d/net Reply with quote

If I set both gateway strings in the /etc/conf.d/net file it does not work.

Here is a copy of my net file (of course I have real IP, broadcast, mask and gateway addresses)

iface_eth0="1.2.3.4 broadcast 1.2.3.7 netmask 255.255.255.xxx"
iface_eth1="1.2.3.4 broadcast 1.2.3.7 netmask 255.255.255.xxx"

gateway="eth0/1.2.3.1"
gateway="eth1/1.2.3.1"

If I have the "gateway=" line twice, then it assigns eth1 (the last listed) as my gateway device even though eth0 is the only device activated. So I cannot use any outside address until I manually "route -add..." to swithc to "eth0/..." as the gateway.

In your example you have two different IP addresses for eth0 and eth1. I only have a single address, and a single gateway.
Back to top
klieber
Bodhisattva
Bodhisattva


Joined: 17 Apr 2002
Posts: 3657
Location: San Francisco, CA

PostPosted: Fri May 17, 2002 11:32 am    Post subject: Re: Doesn't work if both gateways are defined in /etc/conf.d Reply with quote

Anonymous wrote:
I only have a single address, and a single gateway.


OK, now I'm confused -- if you only have a single address and a single gateway, then why do you need to change your gateway at all?

--kurt
_________________
The problem with political jokes is that they get elected
Back to top
View user's profile Send private message
Guest






PostPosted: Fri May 17, 2002 5:06 pm    Post subject: Switching between wireless and cat5 cable is why Reply with quote

I have a wireless PC Card (linksys) and accesspoint on my 100mbit home lan network. The wireless part works at 11mbits. This is great for most access including internet access thru my DSL as the 11mbits exceeds the speed of my DSL connection. So when I use my laptop I normally use the wireless connetion. The wireless card is eth1 on my laptop.

But sometimes I need to backup big files (2GB database container files) to other computers in my home network. And sometimes I access a database running on another machine in my network. For those tasks I plug in my cat5 cable, and remove the wireless PCMCIA card. The builtin lan in my laptop is eth0, and it operates at 100mbit.

The difference in backup time between 11 vs 100 speed connection is hours for these 2GB files. And response time when accessing data from an NFS mount to another machine is noticable.

So when I use my laptop for internet surfing (playtime!), I use the wireless connection, and I can roam around my house. But when I am working, I need the cat5 connection, and I am tethered to my home/office.
Back to top
klieber
Bodhisattva
Bodhisattva


Joined: 17 Apr 2002
Posts: 3657
Location: San Francisco, CA

PostPosted: Fri May 17, 2002 5:14 pm    Post subject: Re: Switching between wireless and cat5 cable is why Reply with quote

Anonymous wrote:
So when I use my laptop for internet surfing (playtime!), I use the wireless connection, and I can roam around my house. But when I am working, I need the cat5 connection, and I am tethered to my home/office.


I understand that part, but it sounds like the gateway is the same in either case. Your original post said you had to switch your gateway -- that's the part that I don't get.

--kurt
_________________
The problem with political jokes is that they get elected
Back to top
View user's profile Send private message
Guest






PostPosted: Fri May 17, 2002 8:19 pm    Post subject: it is the gateway device that is the problem Reply with quote

It is the gateway device that is the problem. The system needs the device (eth0 or eth1).

So with the statement as: gateway="eth0/1.2.3.1" then it searches for the gateway (1.2.3.1) over eth0.

With the statement as: gateway="eth1/1.2.3.1" then it searches for the gateway (1.2.3.1) over eth1.

If both statemnts are active (in the /etc/conf.d/net file), only the last one "takes".

When I have the wireless card, my only active net device is eth1, and the gateway device must be eth1. When I have my cat5 cable plugged in, my only active net device is eth0, and the gateway device must be eth0.

So the problem is that "eth0" is the only active device, but the gateway device is assigned to "eth1". So no gateway, and no net access.
Back to top
Guest






PostPosted: Fri May 17, 2002 8:58 pm    Post subject: Reply with quote

First, I'll say I don't have a clue :). Next, I'll say I was curious, so I started poking around.
Could you put something in /etc/init.d/net.eth0 and net.eth1 that would make or mv the correct file?
Code:
checkconfig() {
   if [ -z "$(eval echo \$\{iface_${IFACE}\})" ]
   then
      eerror "Please make sure that /etc/conf.d/net has \$iface_$IFACE set"
      return 1
   fi
}

Since net.eth0 (on my system) makes sure the interface is set (above code), I'd think you could do
some work in the script to do some work. Just a thought. Maybe there is a better place than the net.eth? files to do the work.
Back to top
pjp
Administrator
Administrator


Joined: 16 Apr 2002
Posts: 20073

PostPosted: Fri May 17, 2002 9:00 pm    Post subject: Reply with quote

:x darn timeout
Back to top
View user's profile Send private message
SirronD
Guest





PostPosted: Tue May 28, 2002 7:49 am    Post subject: I figured it out - and it is very easy Reply with quote

I finally figured out what I need to do. And it's very easy (of course after figuring it out !!!)

the "/sbin/runscript.sh" script sources the file /etc/conf.d/net for any of the /etc/init.d/net.XXXX starts. But if there is a matching /etc/conf.d/net.XXXX then that is the file it will use rather than the generic /etc/conf.d/net.

So I did not need to do anything special (like trying to cp special /etc/conf.d/net files).

I created /etc/conf.d/net.eth0 with a gateway of - gateway="eth0/xxx.xxx.xxx.xxx"

I created /etc/conf.d/net.eth1 with a gateway of - gateway="eth1/xxx.xxx.xxx.xxx"

I created runlevel xdm-lan which includes net.eth0 (my lan connection). I created runlevel xdm-wan which included net.eth1 (my wireless connection).

Now in grub I choose to boot xdm-lan (when connected to my cat 5 cable and I need the 100mbit connection) or boot xdm-wan (connected to my wireless pcmcia card and I want to wander around my house).

All with the same IP and gateway. And the gateway uses the correct device!
Back to top
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