Search code examples
ubuntuwifi

How to connect to using wpa_supplicant on ubuntu 10.04


I'm trying to connect to wifi using wpa_cli on ubuntu 10.04.

I test wifi using network-manager-applet in ubuntu.

Wifi driver is installed on system correctly.

First I make a file in the place /etc/wpa_supplicant.conf

network={
    ssid="367307-Maxis Fibre Internet"
    key_mgmt=WPA-PSK
    proto=RSN
    psk="429140AEFF"
}

Next, I excute the following command in terminal.

wpa_supplicant -B -ira0 -c/etc/wpa_supplicant.conf -Dwext && dhclient ra0

And I received the errors.

There is already a pid file /var/run/dhclient.pid with pid 3703

Killed old client process, removed PID file

Internet Systems Consortium DHCP Client V3.1.3
Copyright 2004-2009 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Listening on LPF/ra0/44:33:4c:c1:16:ee
Sending on   LPF/ra0/44:33:4c:c1:16:ee
Sending on   Socket/fallback
DHCPREQUEST of 192.168.1.121 on ra0 to 255.255.255.255 port 67
DHCPREQUEST of 192.168.1.121 on ra0 to 255.255.255.255 port 67
DHCPDISCOVER on ra0 to 255.255.255.255 port 67 interval 5
DHCPDISCOVER on ra0 to 255.255.255.255 port 67 interval 7
DHCPDISCOVER on ra0 to 255.255.255.255 port 67 interval 10
DHCPDISCOVER on ra0 to 255.255.255.255 port 67 interval 21
DHCPDISCOVER on ra0 to 255.255.255.255 port 67 interval 15
DHCPDISCOVER on ra0 to 255.255.255.255 port 67 interval 3
No DHCPOFFERS received.
Trying recorded lease 192.168.1.121
PING 192.168.1.254 (192.168.1.254) 56(84) bytes of data.
--- 192.168.1.254 ping statistics ---
1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0ms
No working leases in persistent database - sleeping.
------------------------------

Why I can't obtain the ip address from dhcp server?


Solution

  • First, to do what you want, you have to be the only one to command the wpa_supplicant and dhclient. So you have to kill every network managers that you have. So you have to kill your network-manager-applet.

    Then, your file /etc/wpa_supplicant.conf have to include the ctrl_interface information to be able to command the wpa_supplicant with the wpa_cli. Moreover the proto statement is not mandatory in the network description, and can be an error source (if you don't known exactly the AP proto). So use this file instead:

    ctrl_interface=/var/run/wpa_supplicant
    
    network={
        ssid="367307-Maxis Fibre Internet"
        key_mgmt=WPA-PSK
        psk="429140AEFF"
    }
    

    Then you can run the wpa_supplicant daemon:

    wpa_supplicant -B -i ra0 -c /etc/wpa_supplicant.conf -D wext
    

    You can also run it as an normal application to be able to see debug output (you will have to open a new tty):

    wpa_supplicant -dd -i ra0 -c /etc/wpa_supplicant.conf -D wext
    

    Then check the wifi connection status with the wpa_cli:

    wpa_cli -i ra0 status
    

    In the output you must see wpa_state=COMPLETED before continue.

    When the Wi-Fi link is in COMPELETED state. Run the dhcp server to get an ip address:

    dhclient ra0
    

    If all is OK, you will have a fully enable IP link over Wi-Fi :D

    To stop all of this, just kill the dhclient and the wpa_supplicant.

    NOTE: You should think to update your ubuntu version, you are 4 years late and 2 LTS...