Putting a network interface up/down from command line
In Xubuntu 14.04, I tried to use both
ifconfigto handle a network interface, but they gave the same result.
$ sudo ifconfig wlan0 down $ sudo ip link set wlan0 down
both correcly put down the interface and the connectivity does not work; but then
$ sudo ifconfig wlan0 up $ sudo ip link set wlan up
did not restore the connectivity!
This is the output of
ip link showafter putting the interface down:
wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc mq state DOWN group default qlen 1000 link/ether <my_MAC_address> brd ff:ff:ff:ff:ff:ff inet 192.168.1.29/24 brd 192.168.1.255 scope global wlan0 valid_lft forever preferred_lft forever
and this is the output after putting the interface up:
wlan0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000 link/ether <my_MAC_address> brd ff:ff:ff:ff:ff:ff inet 192.168.1.29/24 brd 192.168.1.255 scope global wlan0 valid_lft forever preferred_lft forever
So it has no carrier and I can't access the web, but it has an IP!
1) Why? Shouldn't the
upcommand restore the previous situation? I had to turn off and on the physical switch of the wireless board to browse again the web. I also tried with
dhclient -r wlan0and
dhclient wlan0, but the result was that neither the physical switch was useful and I had to restart the whole system.
2) Even after putting the interface down, the GUI connectivity icon was active and a connection to the wireless Access-Point was normally shown (even if no webpages were actually available). Why?
I think that
ifconfigis not handling wireless stuff like ESSID, channel and key. Take a look to
You can also use "NetworkManager command line"
thanks, but can you provide some example about deactivating and reactivating the wireless card? After reading the original manual (the one you provided is in Italian!) I did not find such an example.
If using *WPA* take also a look to `wpasupplicant`. A search to "ubuntu WPA wifi command line" will give you many links like: http://ubuntuforums.org/showthread.php?t=1798927 http://askubuntu.com/questions/461825/connect-to-wifi-from-command-line