You are not logged in.

#1 2010-02-19 11:57:52

jcerdan
Member
From: Andorra
Registered: 2005-12-17
Posts: 50
Website

netcfg Disable wireless if cable is plugged in?

Hi,

I recently updated to netcfg 2.5.2 which is really powerful!

I have a little question/problem:
This problem is with a laptop with ethernet and wireless connection.
At work we have 2 connection types: wired and wireless. The first provides connection and access to some confidential files, the second is just for external connections.
At home I have a wireless connection.
I have set the daemons 'net-auto-wired' and 'net-auto-wireless' (in that order) to start at boot in /etc/rc.conf as at home it will connect to my wireless and at work it will connect to the ethernet.

When I start my laptop at work, with the ethernet cable plugged-in, both connections wired and wireless start (this is normal), so I have eth0 and wlan0 up; but I just want eth0 to be waken up.

Is it possible to inform the system that in case that eth0 is up and running, then it should not wake up wlan0?
Is there a way to modify 'net-auto-wireless' to do this? or is there a parameter I haven't seen?

Offline

#2 2010-02-19 12:12:32

chpln
Member
From: Australia
Registered: 2009-09-17
Posts: 361

Re: netcfg Disable wireless if cable is plugged in?

I'm not sure of a configuration for `net-auto-wireless' itself, but I do have something similar set up:

I've removed net-auto-wireless from /etc/rc.conf and in /etc/rc.local:

( test $(cat /sys/devices/platform/thinkpad_acpi/rfkill/rfkill0/state) == 1 && \
    ifplugstatus | grep "eth0: unplugged" && \
    /etc/rc.d/net-auto-wireless start ) &

Simply, it brings up net-auto-wireless if no ethernet connection is available and the wireless kill-switch allows it.

Offline

#3 2010-02-19 12:15:19

skanky
Member
From: WAIS
Registered: 2009-10-23
Posts: 1,845

Re: netcfg Disable wireless if cable is plugged in?

Two options I can think of:

1) In Post-Up (see wiki) for the wired link you could have a command that takes down the wireless link/profile.

2) See ifplugd(1) to take down the wireless link on a connection (and maybe start it on a disconnect). You should have ifplugd installed if using net-auto-wired.


"...one cannot be angry when one looks at a penguin."  - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle

Offline

#4 2010-02-22 19:30:59

zenlord
Member
From: Belgium
Registered: 2006-05-24
Posts: 1,218
Website

Re: netcfg Disable wireless if cable is plugged in?

I'm struggling with the same thing. Surely there must be an 'optimal solution' to this:

1. Try the wired interface
2. Ifplugd: connect and softblock (kill) wireless interface
3. if unplugd: disconnect and enable wireless interface
4. If not plugd: don't even bother trying for net-auto-wired and go straight to net-auto-wireless
5. Ifplugd: try to connect and if succes: disable wireless

I guess this should be possible with a combo of PRE-UP, POST-UP and IFPLUGD, but how does one set this up?

Offline

#5 2010-02-22 20:44:06

jcerdan
Member
From: Andorra
Registered: 2005-12-17
Posts: 50
Website

Re: netcfg Disable wireless if cable is plugged in?

Well, I managed to partially solve the situation doing a merge of the answers and what I found on the web:

1) Modified /etc/ifplugd/ifplugd.action

#!/bin/sh
#
# ifplugd.action script for Arch Linux

. /etc/rc.conf
. /etc/rc.d/functions

case "$2" in
  up)
    /etc/rc.d/network ifup $1 
    # ugly way to load up gateway, since
    # al's net configuration doesn't associate
    # gateways with specific interfaces 
    /sbin/route add $gateway
    /etc/rc.d/net-auto-wireless stop
  ;;
  down)
    /etc/rc.d/network ifdown $1
    # same as up...
    /sbin/route del $1
    /etc/rc.d/net-auto-wireless start
  ;;
  *)
    echo "Wrong arguments" > /dev/stderr
  ;;
esac  

exit 1

In fact, added lines to start and stop net-auto-wireless service

2) started net-auto-wired at boot in rc.conf

I don't remember now if I did anything else... I will edit this post if I remember.

At least now if wired is not connected, Wireless starst smile

Offline

Board footer

Powered by FluxBB