Thread: Connect to a wireless network via Linux command line

  1. #1
    Registered User
    Join Date
    Jan 2009
    Posts
    159

    Connect to a wireless network via Linux command line

    Hi,
    Here is what I did
    Code:
    ifconfig wlan0 up
    iwlist wlan0 scan
    iwconfig wlan0 essid NETWORK_ID key WIRELESS_KEY
    1. After iwconfig, I got this error
    Internet Systems Consortium DHCP Client V3.1.1
    Copyright 2004-2008 Internet Systems Consortium.
    All rights reserved.
    For info, please visit http://www.isc.org/sw/dhcp/

    wmaster0: unknown hardware address type 801
    wmaster0: unknown hardware address type 801
    Listening on LPF/wlan0/00:0e:9b:cd:4e:18
    Sending on LPF/wlan0/00:0e:9b:cd:4e:18
    Sending on Socket/fallback
    DHCPREQUEST of 192.168.1.3 on wlan0 to 255.255.255.255 port 67
    DHCPREQUEST of 192.168.1.3 on wlan0 to 255.255.255.255 port 67
    DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 3
    DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 5
    DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 7
    DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 8
    DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 11
    DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 8
    DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 11
    DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 8
    No DHCPOFFERS received.
    Trying recorded lease 192.168.1.3
    PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.

    --- 192.168.1.1 ping statistics ---
    1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0ms

    No working leases in persistent database - sleeping.
    2. I also try to see if it is to use an ascii key, so I added the “s:” prefix to my key as
    Code:
    iwconfig wlan0 essid NETWORK_ID key s:WIRELESS_KEY
    But it will give error
    Error for wireless request "Set Encode" (8B2A) :
    SET failed on device wlan0 ; Invalid argument.
    3. Do I have to specify the type of the wireless network: WEP WAP etc? I am able to access several wireless networks: WEP, WAP and open without password.
    4. When I connect to the open wireless network, "iwconfig wlan0" gives "Access Point: Not-Associated".
    wlan0 IEEE 802.11bg ESSID:"bell"
    Mode:Managed Frequency:2.462 GHz Access Point: Not-Associated
    Bit Rate:9 Mb/s Tx-Power=27 dBm
    Retry min limit:7 RTS thrff Fragment thr=2352 B
    Encryption key:2D13-1B69-557F-3574-61CF-E091-51F9-4B70-0F9E-597B-2438-7B57-3468-0C35-D704-0D3E [2] Security modepen
    Power Managementff
    Link Quality=48/100 Signal level:-67 dBm Noise level=-69 dBm
    Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
    Tx excessive retries:0 Invalid misc:0 Missed beacon:0
    Does this mean the connection to the wireless network fail? But I still can surf on the internet.

    Thanks and regards!

  2. #2
    Registered User carrotcake1029's Avatar
    Join Date
    Apr 2008
    Posts
    404
    I am running linux and have just successfully connected my card by doing the following:

    This will give u the essid and Access Point and channel.
    Code:
    iwlist scan
    For the key and essid arguments, keep the apostrophes. When entering your channel number, replace integer with, of course, the channel number supplied to you by iwlist.
    Code:
    iwconfig wlan0 key 'mykey' mode managed essid 'mychannel' channel integer ap 00:00:00:00:00:00
    Also you may or may not need to manually supply the access point. I had to because it wasn't being assigned correctly.

    Also be sure to take your device down before you start and start the device back up when you are done:
    Code:
    ifconfig wlan0 up/down
    Hopefully this helps.

    Edit: Just read your post in more detail and saw this line:
    Code:
    Access Point: Not-Associated
    So like I described, be sure to manually input your access point. It is the 6 hex numbers separated by colons given to you in iwlist.
    Last edited by carrotcake1029; 08-09-2009 at 11:07 AM.

  3. #3
    1337
    Join Date
    Jul 2008
    Posts
    135
    First of all, if you are connecting to WPA, you cannot use iwconfig wlan0 essid NETWORK_ID key WIRELESS_KEY command. You will have to use wireless-tools or wpa_supplicant. I am using wpa_supplicant and it is kinda straight forward. Got to do some settings in wpa_supplicant.conf file, and nothing else.

    If you are using WEP, then try this.
    modprobe -r <your wireless module here>
    modprobe <your wireless module>
    iwconfig wlan0 up
    iwconfig wlan0 essid <network name> key <password>

  4. #4
    Registered User carrotcake1029's Avatar
    Join Date
    Apr 2008
    Posts
    404
    Quote Originally Posted by valthyx View Post
    First of all, if you are connecting to WPA, you cannot use iwconfig wlan0 essid NETWORK_ID key WIRELESS_KEY command. You will have to use wireless-tools or wpa_supplicant.
    iwconfig is part of wireless-tools

    But yes, you are right, you do need to be running wpa_supplicant

  5. #5
    1337
    Join Date
    Jul 2008
    Posts
    135
    iwconfig is part of wireless-tools
    owh really? I do not know that as i never got to use it.

    Anyway, how is your problem now, lehe?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WinXP Network Connections pop-up
    By DavidP in forum Tech Board
    Replies: 1
    Last Post: 10-02-2002, 05:36 PM
  2. Linux Network Programing
    By Unregistered in forum Linux Programming
    Replies: 2
    Last Post: 07-27-2002, 06:08 AM
  3. Linux Under Windows
    By Strut in forum Linux Programming
    Replies: 3
    Last Post: 05-27-2002, 08:09 PM
  4. linux vs linux?
    By Dreamerv3 in forum Linux Programming
    Replies: 5
    Last Post: 01-22-2002, 09:39 AM
  5. Linux cannot connect to internet
    By taps in forum Linux Programming
    Replies: 3
    Last Post: 11-09-2001, 09:11 AM