Well ,when I turn the Router off and then I turn it on again while running Ubuntu , it doesn't obtain an IP address automatically :

enter image description here

I click on disconnect , but it remains like above.

It works only if I log out and switch to another session and then back the default one.

So How do I reset the network adapter using a terminal command, or any another suggestions?

Edit: I've tried using sudo dhclient , but it didn't work.

  • Have you tried disabling/enabling the whole wireless networking through nm? (cannot remember if 11.04 has this feature, though). – enzotib Jul 27 '11 at 13:41
  • Network Manager? It used to allow to disable Networking or Wireless Networking in the menu you obtain clicking on its icon. – enzotib Jul 27 '11 at 13:44
  • Yeah I got it ,You mean to untick "enable wireless" from the network manager? – Binarylife Jul 27 '11 at 13:44
  • Yeah, I mean this – enzotib Jul 27 '11 at 13:45
  • Yeah,it didn't work also. – Binarylife Jul 27 '11 at 13:46
up vote 15 down vote accepted

If you really want to reset the network adapter you usually need to unload and reload the kernel module that it uses.

If you just want to reconfigure it you can usually do:

sudo /etc/init.d/network-manager restart

But if you just want a new dhcp lease (that's the technical name for obtain a new IP from the router), you just need to use:

sudo dhclient -v eth1
  • So sudo dhclient will obtain a new IP Address? – Binarylife Jul 27 '11 at 13:48
  • @Binarylife yes, that should get you a new IP address. If it doesnt, the router's DHCP may be at fault, and not your wifi card. – Thomas Ward Jul 27 '11 at 13:52
  • @The Evil Phoenix: Okay, I'll try it when I get the issue again, thanks. – Binarylife Jul 27 '11 at 13:57
  • If it doesn't work, the messages that it will output can be useful for debugging. – Javier Rivera Jul 27 '11 at 16:08
  • 2
    IMHO this answer will not work, as both mentioned commands refer to listed devices in /etc/network/interfaces. In a normal Ubuntu install, only 'loopback' is listed there. – minimec Jul 28 '11 at 14:06

This sound like a network-manager problem to me.

I would try the following: (in a gnome-terminal)

  1. 'Softblock' your wireless device with rfkill block wifi
  2. rfkill list will show you if you were successful.
  3. killall nm-applet You kill the network-manager process (panel icon will be gone).
  4. rfkill unblock wifi Enable wifi again.
  5. nm-applet Load a new network-manager session.

Maybe simply killing/loading nm-applet will do. Also note, that you don't need to use 'sudo' for this.

I do know that some router and wifi devices do not 'like' each other very well. This is often a problem of a somehow 'beta' wifi linux-driver...

  • Thanks for your answer, I'll try it also. By the way I am using Siemens ADSL sl2-141router. – Binarylife Jul 28 '11 at 16:22

I wrote a script to try various methods to reset the wifi when it dropped the connection or was otherwise non-responsive (it is called every 2 minutes in a cron):

  # program to check wifi and reset if not running
  DEVICE=`$iwconfig | egrep 802 | awk ' {print $1}'`

  if ping -c 1 $IPTEST >/dev/null 2>&1 ; then
    #echo $IPTEST ok
    exit 0
    # Failed, try to reset wifi - sometimes works ok
    echo "Apagando wifi...."
    nmcli nm wifi off
    sleep 3
    echo Iniciando wifi....
    nmcli nm wifi on
    sleep 10
    if ping -c 1 $IPTEST >/dev/null 2>&1 ; then
        #echo $IPTEST ok
        exit 0
        # try another way
        echo "Apagando wifi $iwconfig ...."
        $iwconfig $DEVICE txpower off
        sleep 3
        echo Iniciando wifi....
        $iwconfig $DEVICE txpower auto
    sleep 10
    if ping -c 1 $IPTEST >/dev/null 2>&1 ; then
        #echo $IPTEST ok
        exit 0
        # try another way
        echo "Apagando wifi $rfkill ...."
        $rfkill list
        $rfkill block wifi
        sleep 3
        echo Iniciando wifi....
        $rfkill unblock wifi
    #echo Cerrar esta ventana cuando sale el estado
    #sleep 3
    #iftop -i $DEVICE
    )  >> $HOME/wificheck.log 2>&1
  exit 0
  • Both; rfkill & nmcli helped me out. – tjt263 Jan 10 '16 at 22:13
nmcli radio wifi off
nmcli radio wifi on

works for me :-)

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.