# Disable wireless if I have wired network?

## bretthoerner

OK, I seem to be using the 'new' networking setup as talked about in the conf.d/net.example page...  in short, I have a network card (eth0) and a wireless card (eth1), I config eth0 in conf.d/net and I have eth1 configured in conf.d/wireless.

I don't have any networking scripts that start at boot... but wireless always automativally tries to find AP's or uses the ones I've put in if they're available (this is good)

My problem is, when I'm at home - I want to use my DSL, not my neighbors crappy wireless... I added ifplugd to boot, so it automatically grabs an IP for eth0 when I plug in a cable, the problem is - I want this to also disable wireless (until unplugged, preferably).  As it stands, I get on both wireless and wired... and it seems that wireless is what my comp tends to choose to use... as my connection is crappy and slow, unlike DSL.

So basically - how can I say "If no wired, use wireless, if a wire is plugged in, stop wireless, when a wire is removed, try wireless".

Thanks.

----------

## chunderbunny

 *bretthoerner wrote:*   

> I don't have any networking scripts that start at boot... but wireless always automativally tries to find AP's or uses the ones I've put in if they're available (this is good)

 

That shouldn't actually be happening, networking should only start when you specifically request it. Please post the output of "rc-update show".

----------

## bretthoerner

 *chunderbunny wrote:*   

>  *bretthoerner wrote:*   I don't have any networking scripts that start at boot... but wireless always automativally tries to find AP's or uses the ones I've put in if they're available (this is good) 
> 
> That shouldn't actually be happening, networking should only start when you specifically request it. Please post the output of "rc-update show".

 

Yeah, thats what I thought, too... but...

```
               acpid |      default

           alsasound |

             apache2 |

                apmd |

            bootmisc | boot

             checkfs | boot

           checkroot | boot

               clock | boot

            coldplug |      default

         consolefont | boot

            cpufreqd |      default

        cpufrequtils |      default

         crypto-loop |

               cupsd |      default

                dbus |      default

                dhcp |

            dhcrelay |

          domainname | boot

              esound |

                 gpm |      default

                hald |      default

              hdparm |

            hostname | boot

             hotplug |      default

             ifplugd |      default

             keymaps | boot

               local |      default nonetwork

          localmount | boot

             modules | boot

            net.eth0 |

            net.eth1 |

              net.lo | boot

            netmount |

                nscd |

          ntp-client |      default

                ntpd |

             numlock |

              pcmcia |      default

       pg_autovacuum |

          postgresql |

           rmnologin | boot

              rsyncd |

               samba |      default

               spamd |

                sshd |      default

            svnserve |

           syslog-ng |      default

               udhcp |

             urandom | boot

          vixie-cron |      default

                 xdm |

              xinetd |      default

```

I realize that ifplugd starts my eth0 when it's plugged in, but even if I remove that from boot I think my eth0 tries to do dhcp (I for SURE know that wireless still grabs an AP and gets an IP no matter what)

----------

## chunderbunny

It's possible that your network connection is being pulled in as a dependancy of another service. Try removing ntp-client from the boot process and see if that has an effect.

----------

## bretthoerner

 *chunderbunny wrote:*   

> It's possible that your network connection is being pulled in as a dependancy of another service. Try removing ntp-client from the boot process and see if that has an effect.

 Right, but that isn't my problem and isn't really a solution.  If I'm using my laptop I either have wireless or ethernet, and I'd just like ethernet to take precidence... I don't want to have to hard-start all my daemons based on where I am, etc.

----------

## chunderbunny

Yes, but if you remove ntp from boot and everything works as it should then we know where the problem is. Once you know the problem it becomes much easier to solve it.

----------

## bretthoerner

Disabling ntp didn't do anything, I still grab eth0 (DSL) immediatly when I boot (assuming a cable is in) and then about 30 seconds later my wireless finds an AP even though it doesn't need to.

----------

## lghman

Look at the output of ls -l for the /etc/init.d/ directory.  I had this same problem and it was due to a link between net.lo and (on my computer) net.eth0.  I couldnt figure it out for a while and it was quite annoying.  When I deleted the link the problem stoped.

--sonik

----------

## bretthoerner

Hmm,

```
lrwxrwxrwx  1 root root     6 Sep 29 04:50 net.eth0 -> net.lo

lrwxrwxrwx  1 root root     6 Sep 29 07:05 net.eth1 -> net.lo

-rwxr-xr-x  1 root root 26960 Sep 29 12:57 net.lo

```

net.lo starts at boot, but eth0 and eth1 don't.  I don't really think I want to turn off net.lo though... because I do want my machine to start net on boot... I just want it to only start eth1 is ifplugd says eth0 isn't connected... if that is possible.

I would turn off net on boot and do this by hand, but then anything that needs net would fail.  I'd have to boot, start eth0 or eth1 based on where I was (kind of annoying) and then I'd have to sshd... samba... netmounts... ntp... etc... etc... Oy.

----------

## digitall2000

did ya figure it out?

if you are using ifplug

then you need ifmetric

if i remember the metric on any interface in linux is 1

this lets you easily set the metric of the wireless to 2

so when you plug in the wire ifplug brings it up with a 

lower metric and that is now the route your box will take

lance

net-analyzer/ifmetric

      Latest version available: 0.3

      Latest version installed: 0.3

      Size of downloaded files: 79 kB

      Homepage:    http://0pointer.de/lennart/projects/ifmetric/

      Description: A Linux tool for setting the metrics of all IPv4 routes attached to a given network interface at once.

      License:     GPL-2

----------

## UberLord

Or you can use baselayout-1.12 which sets wireless interface metric to n + 1000 which also solves the problem quite nicely  :Smile: 

----------

