C Board  

Go Back   C Board > General Programming Boards > Networking/Device Communication

Reply
 
LinkBack Thread Tools Display Modes
Old 08-09-2009, 09:35 AM   #1
Registered User
 
Join Date: Jan 2009
Posts: 156
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
Quote:
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
Quote:
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".
Quote:
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!
lehe is offline   Reply With Quote
Old 08-09-2009, 11:05 AM   #2
Registered User
 
carrotcake1029's Avatar
 
Join Date: Apr 2008
Posts: 299
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.
carrotcake1029 is offline   Reply With Quote
Old 08-09-2009, 11:26 AM   #3
Registered User
 
Join Date: Jul 2008
Posts: 76
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>
valthyx is offline   Reply With Quote
Old 08-09-2009, 07:37 PM   #4
Registered User
 
carrotcake1029's Avatar
 
Join Date: Apr 2008
Posts: 299
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
carrotcake1029 is offline   Reply With Quote
Old 08-10-2009, 05:18 AM   #5
Registered User
 
Join Date: Jul 2008
Posts: 76
Quote:
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?
valthyx is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

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


All times are GMT -6. The time now is 07:51 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22