# Status: inactive and other questions [SOLVED]

## cristianbdg

I'm trying to understand how the new baselayout scripts work, but I don't get it. I have a network cord called eth0 and a wireless card called wlan0. I've got netplug installed, and like I said I'm using the new baselayout. I put net.eth0 and net.wlan0 at the default runlevel. With the ethernet cable plugged in at bootup, I get the following:

```
...

Starting eth0

   Starting netplug on eth0 ...

      Backgrounding ...

Starting wlan0

   Starting wpa_supplicant on wlan0 ...

   Starting wpa_cli on wlan0 ...

      Backgrounding ...

...
```

If at this point I check the status of eth0 I get started, and for wlan0 I get inactive. Internet works fine.

Why does eth0 say Backgrounding, if it gets started normally?

What does Backgrounding mean?

What is the difference between inactiver and stopped (or started?)

Why is wlan0 inactive?

If I do /eth/init.d/wlan0 start I get a "already started" error. Restart works, but doesn't seem adequate for an "inactive" device. Why isn't there a activate command?

If I take out the network cable, netplug disables eth0, which is a good thing, but (as I complained in another topic) ignores wlan0. Now I have bot eth0 and wlan0 set to inactive and I have to manually activate wlan0 with /eth/init.d/wlan0 restart.

Is there a way to make wlan0 start automatically when eth0 is disconnected?

I tried modifying the netplug script to stop wlan0 when eth0 gets started and start wlan0 when eth0 stops. Does this break anything?

Now I plug the cable back in and I get both devices "started". ifconfig says that both devices have the same IP, and to my surprise... internet works!

Is it normal that it works having two network cards (one ethernet and one wireless) with the same IP?

What would happen if eth0 and wlan0 got different IPs? Would it still work?

If both of the above are normal and work, what is the use for disabling devices?

Finally, what would be the way to configure the following (I think very simple) setup:

When the cable is plugged: use eth0 and disable wlan0 (it's a laptop, so we need the battery power)

When the cable is unplugged: enable wlan0, and disable eth0 if it's necessary to not interfere with wlan0

I hope anyone can help me with my questions. Thanks in advance.

Last edited by cristianbdg on Fri May 05, 2006 9:39 am; edited 1 time in total

----------

## UberLord

 *cristianbdg wrote:*   

> Why does eth0 say Backgrounding, if it gets started normally?
> 
> What does Backgrounding mean?
> 
> What is the difference between inactiver and stopped (or started?)
> ...

 

Backgrounding means that the service has started, but will continue configuration in the background by a triggered event, such as a cable being plugged in or associating to an Access Point. When a service backgrounds it as inactive. Inactive means that when a daemon starts or stops in then the process continues. If you stop it then it really stops.

There is no activate command because it's the daemons job to activate, not yours. If it's not fully starting then in wpa_supplicants case it's not associating t an access point.

 *Quote:*   

> If I take out the network cable, netplug disables eth0, which is a good thing, but (as I complained in another topic) ignores wlan0. Now I have bot eth0 and wlan0 set to inactive and I have to manually activate wlan0 with /eth/init.d/wlan0 restart.
> 
> Is there a way to make wlan0 start automatically when eth0 is disconnected?
> 
> I tried modifying the netplug script to stop wlan0 when eth0 gets started and start wlan0 when eth0 stops. Does this break anything?

 

The act of eth0 stopping will not active wlan0 and that is fine.

You are launching netplug and wpa_supplicant - netplug will start and stop eth0 when cable is inserted, removed and wpa_supplicant will do the same for wlan0.

 *Quote:*   

> 
> 
> Now I plug the cable back in and I get both devices "started". ifconfig says that both devices have the same IP, and to my surprise... internet works!
> 
> Is it normal that it works having two network cards (one ethernet and one wireless) with the same IP?
> ...

 

They should not get the same IP - are you giving the same IP to two different MAC addresses in the DHCP server? If so stop it, things will break.

 *Quote:*   

> 
> 
> Finally, what would be the way to configure the following (I think very simple) setup:
> 
> When the cable is plugged: use eth0 and disable wlan0 (it's a laptop, so we need the battery power)
> ...

 

I use acpid to start and stop my wireless when I do Fn+Battery on my thinkpad. It also turns of tx power which effectively kills the card without the need to unload the module.

----------

## cristianbdg

Thanks so very much for answering, that creared up a lot! Just a couple more things:

 *Quote:*   

> If it's not fully starting then in wpa_supplicants case it's not associating to an access point.

 

Actually, at bootup (with the network cable plugged in) wlan0 does associate with the access point (that's what iwconfig says), it just doesn't have an IP (that's what ifconfig says). So if it's associated, why does it have an "inactive" status and no IP? Maybe because it's configured with the same IP as eth0?

 *Quote:*   

> The act of eth0 stopping will not active wlan0 and that is fine.

 

I can understand why, but in my case that's exactly what I want. When I have my laptop near the router I want to plug it in and use ethernet, and when I take the laptop to the living room I want it to automatically start using wifi. Is that possible?

 *Quote:*   

> They should not get the same IP - are you giving the same IP to two different MAC addresses in the DHCP server? If so stop it, things will break.

 

I don't have a DHCP server running at my LAN because I like to know what IP every computer has. That's why I have the same IP for my ethernet and my wireless connection: I set that manually in /etc/conf.d/net, because at home I don't ever use them at the same time (eth and wifi). Maybe I should use different fixed IPs for the ethernet and wireless connections at the same computer. Would that work?

 *Quote:*   

> I use acpid to start and stop my wireless when I do Fn+Battery on my thinkpad. It also turns of tx power which effectively kills the card without the need to unload the module.

 

I have a button on my lapop which turns off wireless, at least that's what it's supposed to do, because although Link quality/Signal level drop to 0 and it says it's "Not associated" anymore, Tx-power is still 25 dBm. The problem is that turning it on has the same effect as at bootup: It associates, but it doesn't get an IP.

So what am I supposed to do? Maybe if I should remove wlan0 from the default runlevel and the adapt the netplug script to start/stop wlan0 when eth0 goes on/off?

Sorry to keep bothering, but this is something I would really like to see solved. Thanks again!

----------

## UberLord

 *cristianbdg wrote:*   

>  *Quote:*   If it's not fully starting then in wpa_supplicants case it's not associating to an access point. 
> 
> Actually, at bootup (with the network cable plugged in) wlan0 does associate with the access point (that's what iwconfig says), it just doesn't have an IP (that's what ifconfig says). So if it's associated, why does it have an "inactive" status and no IP? Maybe because it's configured with the same IP as eth0?

 

Sorry, bad wording on my part. Associated and authenticated - ie wpa_supplicant thinks it's ready to rock. iwconfig will only report the associated part.

 *Quote:*   

> 
> 
>  *Quote:*   The act of eth0 stopping will not active wlan0 and that is fine. 
> 
> I can understand why, but in my case that's exactly what I want. When I have my laptop near the router I want to plug it in and use ethernet, and when I take the laptop to the living room I want it to automatically start using wifi. Is that possible?

 

No, that's not what you want. What you want is them both to be connected when they can be so if one route does not work then the other will. Trust me on this, I do the same with my laptop  :Wink: 

 *Quote:*   

> 
> 
>  *Quote:*   They should not get the same IP - are you giving the same IP to two different MAC addresses in the DHCP server? If so stop it, things will break. 
> 
> I don't have a DHCP server running at my LAN because I like to know what IP every computer has. That's why I have the same IP for my ethernet and my wireless connection: I set that manually in /etc/conf.d/net, because at home I don't ever use them at the same time (eth and wifi). Maybe I should use different fixed IPs for the ethernet and wireless connections at the same computer. Would that work?

 

You have to give them different IP addresses, plain and simple. Maybe that's why it's not working  :Wink: 

 *Quote:*   

> 
> 
>  *Quote:*   I use acpid to start and stop my wireless when I do Fn+Battery on my thinkpad. It also turns of tx power which effectively kills the card without the need to unload the module. 
> 
> I have a button on my lapop which turns off wireless, at least that's what it's supposed to do, because although Link quality/Signal level drop to 0 and it says it's "Not associated" anymore, Tx-power is still 25 dBm. The problem is that turning it on has the same effect as at bootup: It associates, but it doesn't get an IP.
> ...

 

I suggest you fix wlan0 so that it works and then revisit this one so that you know the act of pressing the button stops wlan0.

----------

## cristianbdg

Wow, what an incredibly quick reply!

Now (I think) I finally understand how this is supposed to work. You were completely right about the IPs. Now that  the devices get different IPs, both are connected and configured well. Now, when I disconnect the cable, eth0 gets disabled, but as wlan0 is connected also, my connection keeps working, which is exactly what I wanted!

Just one more small question. When both interfaces are active, how does the OS know what device (eth0 or wlan0) to use? Does it prefer wired over wireless? Does it use the first that was configured?

Oh, and a last note. I noticed that there is absolutely no difference between having net.eth0 and net.wlan0 at the default bootlevel, or only net.wlan0. Even when I remove both from the default runlevel, they get started anyway. Is this the normal behavior?

Thanks so much UberLord for your help!

----------

## UberLord

 *cristianbdg wrote:*   

> Just one more small question. When both interfaces are active, how does the OS know what device (eth0 or wlan0) to use? Does it prefer wired over wireless? Does it use the first that was configured?

 

It will use whichever route has the lowest metric - use the route command to see this. Using baselayout-1.12 you will get a higher route for wireless interfaces which means it will prefer wired.

 *Quote:*   

> Oh, and a last note. I noticed that there is absolutely no difference between having net.eth0 and net.wlan0 at the default bootlevel, or only net.wlan0. Even when I remove both from the default runlevel, they get started anyway. Is this the normal behavior?

 

There's currently a debate on that  :Smile: 

It's basically udev doing coldplug (depending on your version) or you're the coldplug init script or your forceably loading the modules.

----------

## bianco

Thank you UberLord!!!

You halp me so mutch!   :Very Happy: 

Thank you! Thank you! Thank you!Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you!    :Laughing: 

----------

## VinzC

Hi.

I'd like to know what I can do to *not* have net.eth0 backgrounding with parallel start. When I disable parallel start net.eth0 backgrounds and is run early enough before any script that needs net.eth0.

Now if I enable parallel start in /etc/conf.d/rc all scripts that depend on eth0 (e.g. ntp-client, nfsmount) run before eth0 gets its IP address from dhcpcd... Consequently these scripts, which need DNS resolution cannot start since /etc/resolv.conf doesn't exist yet when they start.

Is there a way to force net.eth0 into the foreground when parallel start is true?

EDIT: Just found the answer in /lib/rcscript/net/netplugd.sh:

```
        timeout="plug_timeout_${ifvar}"

...

        if [[ ${timeout} == "0" ]] ; then

                ewarn "WARNING: infinite timeout set for ${iface} to come up"

        elif [[ ${timeout} -lt 0 ]] ; then

                einfo "Backgrounding ..."

                exit 0

        fi

...

```

Solution: set a positive value for plug_timeout_eth0.

----------

