I can’t figure out how to properly bring up the wi-fi card on my laptop. When I turn it on and issue
$ sudo iwconfig wlan0 txpower auto $ sudo iwlist wlan0 scan wlan0 Interface doesn't support scanning : Network is down
it reports that the network is down. Trying to bring it up fails too:
$ sudo ifup wlan0 wlan0 no private ioctls. Failed to bring up wlan0.
Apparently I’m missing some basic low-level iw... command.
When I issue dhclient on the interface:
$ sudo dhclient -v wlan0 Internet Systems Consortium DHCP Client 4.2.2 Copyright 2004-2011 Internet Systems Consortium. All rights reserved. For info, please visit https://www.isc.org/software/dhcp/ ^C$
and interrupt it, it brings the device up somehow and then scanning etc. works. I’d like to avoid this obviously superfluous step.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
sudo ip link set wlan0 up or sudo ifconfig wlan0 up.
Answer from Apr 13’17:
To elaborate on the answer by Martin:
ifup and ifdown commands are part of ifupdown package, which now is considered a legacy frontend for network configuration, compared to newer ones, such as network manager.
Upon ifup ifupdown reads configuration settings from /etc/network/interfaces; it runs pre-up, post-up and post-down scripts from /etc/network, which include starting /etc/wpasupplicant/ifupdown.sh that processes additional wpa-* configuration options for wpa wifi, in /etc/network/interfaces (see zcat /usr/share/doc/wpasupplicant/README.Debian.gz for documentation). For WEP wireless-tools package plays similar role to wpa-supplicant. iwconfig is from wireless-tools, too.
ifconfig at the same time is a lower level tool, which is used by ifupdown and allows for more flexibility. For instance, there are 6 modes of wifi adapter functioning and IIRC ifupdown covers only managed mode (+ roaming mode, which formally isn’t mode?). With iwconfig and ifconfig you can enable e.g. monitor mode of your wireless card, while with ifupdown you won’t be able to do that directly.
ip command is a newer tool that works on top of netlink sockets, a new way to configure the kernel network stack from userspace (tools like ifconfig are built on top of ioctl system calls).
Method 2
Try ifconfig wlan0 up instead of ifup.
Method 3
As of Ubuntu 18.04 (and corresponding Debian versions) ifconfig and ifup/ifdown are deprecated, and the recommended way to bring up the interface is with the ip command:
ip link set dev <interface> up ip link set dev <interface> down
And you can check your available interfaces with:
ip link
And you can show your interfaces’ assigned ip addresses with:
ip addr show
Or more specifically:
ip addr show scope global | grep inet
Method 4
Here’s what I use to connect to a WEP access point, on a daily basis:
#!/bin/bash
DEV=$(iw dev | awk '/Interface/ {interf=$2} END {print interf}')
PIDFILE=/var/run/dhcpcd-$DEV.pid
if [[ -f $PIDFILE ]] && kill -0 $(cat /var/run/dhcpcd-$DEV.pid)
then
dhcpcd -k $DEV
fi
ifconfig $DEV down
sleep 1
iwconfig $DEV mode managed
iwconfig $DEV key blabfoobar
ifconfig $DEV up
iwconfig $DEV essid 'Unindicted Co-conspirator'
iwconfig $DEV ap 00:0D:51:EB:E5:1E
sleep 5
dhcpcd --noipv6rs --noarp $DEV
You’ll have to put in the ESSID and MAC for whatever access point you want.
It’s a little harder for WPA encryption. You have to have a wpa_supplicant.conf file with an appropriate entry. Like this:
# Simple case: WPA-PSK, PSK as an ASCII passphrase, allow all valid ciphers
network={
ssid="FaveCoffeeHouse"
psk="cafe241800"
priority=1
}
Once you have such a conf file, then you can run this script:
#!/bin/bash
DEV=$(iw dev | awk '/Interface/ {print $2}')
ifconfig $DEV down
iwconfig $DEV mode managed
ifconfig $DEV up
iwconfig $DEV essid 'FaveCoffeeHouse'
iwconfig $DEV ap 00:21:1e:3d:2a:80
echo now run: wpa_supplicant -Dnl80211 -i$DEV -c./wpa_supplicant.conf
Update, 2014-12-03:
Arch linux being what it is, my connect-to-WEP script is a lot different. I thought I’d add it to this answer to keep it up-to-date.
#!/bin/bash
DEV=wlp12s0
if [[ -f /run/dhcpcd-$DEV.pid ]]
then
kill -QUIT $(cat /run/dhcpcd-$DEV.pid)
fi
ifconfig $DEV down
iw dev $DEV set type managed
ifconfig $DEV up
sleep 2
iw dev wlp12s0 connect -w 'Akond of Swat' 2462 00:7c:41:eb:e5:1e key 0:befedade
sleep 15
dhcpcd -4 --nohook 10-wpa_supplicant --noarp --noipv6rs $DEV
I had to switch to using iw very suddenly. Something about the Arch LTS kernel, or the WiFi drivers (my laptop has an Intel WiFi card using the “iwl4965” driver) changed not too long ago. You’ll have to change the frequency (“2462”) and MAC address of the access point to get this to work.
Method 5
I had problem with the network manager running in the background on Lubuntu, so I had to switch it off first.
sudo su # switch to root user /etc/init.d/network-manager stop # stop the network-manager iw dev # find name of wifi interface, I stick to wlan0 ip link set wlan0 up # switch on wlan # ip link show wlan0 # check result of previous step iw wlan0 scan # find your wifi router # iw wlan0 scan |grep SSID # find just names of wifis around you iw dev wlan0 connect -w WifiWithoutPassword # do not forget -w wait parameter iw wlan0 link # ping 8.8.8.8 # this should work dhclient wlan0 # add dhcp detection # ip link show wlan0 # check connection # ping unix.stackexchange.com # this should work # wpa_cli status # check it all
Password pages need wpa_passphrase and wpa_supplicant, but it is another question.
These pages were helpful to me:
https://www.blackmoreops.com/2014/09/18/connect-to-wifi-network-from-command-line-in-linux/
https://wiki.archlinux.org/index.php/Network_configuration/Wireless
Well, this is the low level solution. It can be of course elegantly done in the network manager via nmcli command, but I need more RAM space in my PC, so I strive to get rid of all resident daemons as much as I can.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0