Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
disable wlan turn on automatically
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
queen
Veteran
Veteran


Joined: 19 Jul 2005
Posts: 1642

PostPosted: Sun Mar 17, 2013 5:48 pm    Post subject: disable wlan turn on automatically Reply with quote

Hi All

My built in wlan0 card is turned on automatically during the boot process. I would like to disable this automatic feature and turn the card on manually only when I need it. I played around with some files, but it still doesn't work. wlan1 is a usb card.

The client I use is dhcpcd, latest version. I don't use any network manager. I just use wpa_supplicant.

Here are the files that I played with:

Code:

/etc/conf.d/net
# This blank configuration will automatically use DHCP for any net.*
# scripts in /etc/init.d.  To create a more complete configuration,
# please review /usr/share/doc/openrc*/net.example* and save your configuration
# in /etc/conf.d/net (this file :]!).
#config_eth0="192.168.0.2 netmask 255.255.255.0 brd 192.168.0.255"
#routes_eth0="default via 192.168.0.1"
#config_eth0="dhcp"
modules="wpa_supplicant"
#sleep_scan_wlan1="3"
#associate_timeout_wlan1="10"
#associate_test_wlan1="MAC"
#dhcp_wlan1="release nodns nogateway nosendhost"


Code:

# conf.d file for wpa_supplicant
#
# Please check man 8 wpa_supplicant for more information about the options
# wpa_supplicant accepts.
#
wpa_supplicant_args=""



This is my rc.conf (I didn't play with it yet;
Code:

cat /etc/rc.conf


rc_interactive="YES"

rc_shell=/sbin/sulogin

#rc_depend_strict="YES"

#rc_hotplug="*"

rc_logger="YES"

#rc_log_path="/var/log/rc.log"

#rc_env_allow="VAR1 VAR2"

#rc_start_wait=100

#rc_nostop=""

#rc_crashed_stop=NO
#rc_crashed_start=YES

unicode="YES"

#extra_net_fs_list=""

#export SSD_NICELEVEL="-19"

#rc_ulimit="-u 30"

#rc_config="/etc/foo"
#rc_need="openvpn"
#rc_use="net.eth0"
#rc_after="clock"
#rc_before="local"
#rc_provide="!net"

#rc_foo_config="/etc/foo"
#rc_foo_need="openvpn"
#rc_foo_after="clock"

#rc_net_tap0_provide="!net"

rc_sys=""

rc_tty_number=12


How can I disable it? I don't have dhcp server installed.
Back to top
View user's profile Send private message
massimo
Veteran
Veteran


Joined: 22 Jun 2003
Posts: 1226

PostPosted: Mon Mar 18, 2013 6:34 am    Post subject: Reply with quote

I think it should work as you expect it if you put
Code:

config_wlan1="null"

in your /etc/conf.d/net
_________________
Hello 911? How are you?
Back to top
View user's profile Send private message
The Doctor
Moderator
Moderator


Joined: 27 Jul 2010
Posts: 2678

PostPosted: Mon Mar 18, 2013 7:09 am    Post subject: Reply with quote

You didn't say if you have other network interfaces that automatically get started at boot. Several bootup services need net, so even if wlan0 is not set to start up it will be started to satisfy the requirement.

You need to add something like this to rc.conf
Code:
rc_hotplug="!net.wlan0 !net.eth0"
I believe you may also need to make arrangement's for net to be available. or some services will fail. If you want to use something like wicd that provides net, then you can satisfy that dependency. There is no requirement that wicd must connect automatically, so it would be both a covenant GUI and a solution to your problem. I strongly advise you against trying to control wicd from the command line. It is possible, bit it is not pretty. I think network manager would give you the same options, but I have no experience in that.
_________________
First things first, but not necessarily in that order.

Apologies if I take a while to respond. I'm currently working on the dematerialization circuit for my blue box.
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6227
Location: Room 101

PostPosted: Mon Mar 18, 2013 11:01 am    Post subject: Reply with quote

queen ...

Its not really clear what you mean by "turned on automatically at boot", that could mean the card itself or the network interface brought up.

As has been pointed out by massimo and The Doctor, you can disable net.${IFACE} from running (assuming nothing in the runlevel 'need[s] net' and that if this is the case 'net' is provided by some other ${IFACE}) or null any configuration. The problem would of course then be what happens when you want to start the interface, as in massimo's suggestion (config_wlan1="null") it would not start subsequently without first changing the configuration.

One aproach is to blacklist the module and then provide a preup() function to load the module prior to starting the interface.

/etc/modprobe.d/blacklist.conf
Code:
blacklist <usb_wireless_module_name>

/etc/conf.d/net
Code:
preup() {

if [[ ${IFACE} = "wlan1" && -z $(lsmod | awk '$1 ~/<usb_wireless_module_name>/') ]] ; then
    modprobe <usb_wireless_module_name>
fi

return 0
}

modules_wlan1="!plug wpa_supplicant"
config_wlan1="dhcp"
<etc>

This will prevent the card being initialised until /etc/conf.d/net.wlan1 is run.

Still, its not altogether clear what you want to do, and so it may be that what your looking for is more in line with The Doctor's suggestion of running wicd, or what-have-you.

best ... khay
Back to top
View user's profile Send private message
queen
Veteran
Veteran


Joined: 19 Jul 2005
Posts: 1642

PostPosted: Tue Mar 19, 2013 4:01 pm    Post subject: Reply with quote

khayyam wrote:
queen ...

Its not really clear what you mean by "turned on automatically at boot", that could mean the card itself or the network interface brought up.

As has been pointed out by massimo and The Doctor, you can disable net.${IFACE} from running (assuming nothing in the runlevel 'need[s] net' and that if this is the case 'net' is provided by some other ${IFACE}) or null any configuration. The problem would of course then be what happens when you want to start the interface, as in massimo's suggestion (config_wlan1="null") it would not start subsequently without first changing the configuration.

One aproach is to blacklist the module and then provide a preup() function to load the module prior to starting the interface.

/etc/modprobe.d/blacklist.conf
Code:
blacklist <usb_wireless_module_name>

/etc/conf.d/net
Code:
preup() {

if [[ ${IFACE} = "wlan1" && -z $(lsmod | awk '$1 ~/<usb_wireless_module_name>/') ]] ; then
    modprobe <usb_wireless_module_name>
fi

return 0
}

modules_wlan1="!plug wpa_supplicant"
config_wlan1="dhcp"
<etc>

This will prevent the card being initialised until /etc/conf.d/net.wlan1 is run.

Still, its not altogether clear what you want to do, and so it may be that what your looking for is more in line with The Doctor's suggestion of running wicd, or what-have-you.

best ... khay


Thanks a lot for all the replies. I will answer to everyone. I have 3 interfaces.
eth0 wired card. I don't use it.
wlan0 wifi card built in the laptop.
wlan1 wifi usb card.

after boot, I see wlan0, eth0, wlan1
Code:

eth0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
wlan1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1492
wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1492


I don't want them to be up by default. I want to turn the card up manually and turn on only the card that I want to use. For instance ifconfig wlan0 up.

If I remove net.lo from boot runlevel, will it disable the cards?
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6227
Location: Room 101

PostPosted: Tue Mar 19, 2013 4:51 pm    Post subject: Reply with quote

queen wrote:
I have 3 interfaces. eth0 wired card. I don't use it. wlan0 wifi card built in the laptop. wlan1 wifi usb card. after boot, I see wlan0, eth0, wlan1
Code:
eth0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
wlan1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1492
wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1492

I don't want them to be up by default. I want to turn the card up manually and turn on only the card that I want to use. For instance ifconfig wlan0 up. If I remove net.lo from boot runlevel, will it disable the cards?

queen ... no, do not remove net.lo, this is the 'loopback' and is required for normal functioning. By default the cards are not UP, so something is bringing them up, what do you have in the default runlevel? I suspect you have net.eth0, net.wlan0, net.wlan1, or prehaps dhcpcd, or wpa_supplicant. So, if you want to "turn the card up manually" then you shouldn't have anything in the runlevel, nor should you have anything set to run that 'need[s] net'.

Using 'ifconfig wlan1 up' doesn't do all that is required to authenticate with an AP, or establish a network connection, it just puts the card in an active state, so I'm not sure what you really mean here, and how it fits with establishing the network connection. If you don't want anything 'started' then remove them from the runlevel, and then use '/etc/init.d/net.${IFACE} start' to start it.

best ... khay
Back to top
View user's profile Send private message
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