PDA

View Full Version : Connect to WLAN from command line


nite_man
12-27-2006, 10:33 AM
Hi!

I'd like to know is there some way to connect to WLAN from command line? I need to connect to the network right after Nokia boot. There is an only one access point.

Thanks in advance.

Michael

SeRi@lDiE
12-27-2006, 11:50 AM
I have not try this on maemo but you can give it a try... be care full I am not responsible if you brick your N770.

You need to edit the /etc/network/interfaces file to something like this....



#
# File: /etc/network/interfaces
#

# The primary network interface
auto eth1
iface eth1 inet static
address 10.30.2.55
netmask 255.255.255.0
wireless-essid unix

auto eth0
iface eth0 inet dhcp
wireless-essid null_one

SeRi@lDiE
12-27-2006, 11:52 AM
If is secure than you need to follow aditional steps..

And if you just want to do it from xterm...

ifconfig eth1 up (bring up specified interface)

iwconfig eth1 mode managed key [WEP key] (128 bit WEP use 26 hex characters, 64 bit WEP uses 10)

iwconfig essid "[ESSID]" (Specify ESSID for the WLAN)

or iwlist scan to scan for AP.

nite_man
12-29-2006, 12:09 PM
Hi,

Thanks a lot for your suggestions. More or less I understand how it should be done :)
But I'm curious a bit regarding Nokia's file interfaces. I found that it's very strange that this file doesn't contain wlan0 device. Can you post your file, for example?

SeRi@lDiE
12-29-2006, 04:25 PM
Here is my interface file...


auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
auto usb0
iface usb0 inet static
address 192.168.2.15
netmask 255.255.255.0
gateway 192.168.2.14

nite_man
01-01-2007, 10:48 AM
Hmmm ... My file interfaces looks the same. So, I should add some wireless-* options to the eth0 and use wlan0 to bring up network interface? Because, when I try to run
ifconfig eth0
it give me an error that device not found

SeRi@lDiE
01-01-2007, 03:08 PM
Yes use wlan0

nite_man
01-03-2007, 10:44 AM
Well, I run following commands to bring up WLAN:

ifconfig wlan0 up # without this iwconfig gives me an error that device wlan0 not found

iwconfig wlan0 enc MY_NET_KEY mode managed essid MY_NET_ID channel 6

I see that command passes without errors (I use iwevent) but IP address is not given by DHCP and nework interface is not up.

What I do wrong?

SeRi@lDiE
01-03-2007, 11:03 AM
Did you install the wireless tools?
https://maemo.org/maemowiki/ApplicationCatalog2006#head-2b2bdff453efd17b3c238ba6c1e89da6ba5c2564

nite_man
01-03-2007, 11:09 AM
Sure. I couldn't call iwconfig and iwevent without them

TA-t3
01-03-2007, 12:40 PM
Running just 'iwconfig' after the initial iwconfig setup command should show your essid and key etc. If so, then it's associated ok. After that you'll have to run a program to actually do the dhcp setup, I don't know what the dhcp client is called on the 770, try just entering 'dhcp' and press <tab>. It's usually either of dhcp-client or dhcpcd, but could be something else. In any case, whatever its name run it with 'wlan0' as argument (e.g. 'dhcp-client wlan0')

SeRi@lDiE
01-03-2007, 01:38 PM
Running just 'iwconfig' after the initial iwconfig setup command should show your essid and key etc. If so, then it's associated ok. After that you'll have to run a program to actually do the dhcp setup, I don't know what the dhcp client is called on the 770, try just entering 'dhcp' and press <tab>. It's usually either of dhcp-client or dhcpcd, but could be something else. In any case, whatever its name run it with 'wlan0' as argument (e.g. 'dhcp-client wlan0')


I think he is trying to connect to a specific network... with a specific IP.

The actual command for dhcp is dhcpclient wlan0

lmf
01-03-2007, 05:08 PM
Sure. I couldn't call iwconfig and iwevent without them

I also tried this, and it didn't work...

I did:
sudo gainroot
ifconfig wlan0 up
iwconfig wlan0 mode managed essid my_ap_essid

after that, i confirm that the n770 did not connect to the ap, even though they are in the same room...

running "iwlist wlan0 scanning", lists my AP.
(btw, my ap's essid is hidden)

nite_man
01-04-2007, 02:40 AM
I found the way to connect my Nokia to WLAN. Run following commands:

ifconfig wlan0 up
iwconfig essid "My access Point" enc MY_KEY mode managed
udhcpc -i wlan0

Note that ESSID should be in the quotes. Otherwise it won't be assigned correctly (at least in my case).
To check that everything ok run first iwconfig wlan0. It should display you options of your access point. Then run ifconfig to see that IP is assigned to your device.

TA-t3
01-04-2007, 06:38 AM
Yes, any word with spaces in must be inside quotes on Unix (or you may backslash the spaces), otherwise the word after the space will be taken as the next argument instead.

lmf
01-04-2007, 01:57 PM
This ONLY works if the ap is NOT hiding the essid...
(it's strange, because from another linux machine I can connect without any problems...)
However, connecting from the top bar icon, works. (it's just a bit slow...)

so, the question is:
How to manually connect the Nokia 770 to a wifi hotspot with a hidden essid?

nite_man
01-05-2007, 05:41 AM
Here is an another way to bring WLAN up from command line. It's possible to do using dbus:
Actually, I would suggest sending a dbus message to the network control
software, which would take care of all of that for you. However, the dbus
ontology is very meagerly documented, and to discover the magic incantation
you'll have to execute "dbus-monitor" with the correct command line
arguments. Then (with the interface shut off) start the web browser
showing an outside URL. It will send the signal, and when the net comes up
a dbus signal returns to the browser and it knows it can download and show
that page. And you will have trapped the dbus chatter that makes it
happen, so you can imitate in your command line application.
Personally, I didn't test it yet. But probably, it'd better to use dbus because in this case all native Nokia770 connection functionality will work i. e. WLAN connection applet indicator.

SeRi@lDiE
01-05-2007, 08:15 PM
I stand corrected all commands in Debian are just like BSD are all different from *nix

Neil McAllister
01-09-2007, 05:24 PM
I have heard that the DHCP client on the 770 is called 'udhcpc', but I haven't had any real luck with it. I was hoping the command line would give me a second crack at DHCP when my 770 fails with the dreaded "link local address" (yes, my 770 is still all but useless to me in public places where there are lots of Wi-Fi networks present).

nite_man
01-10-2007, 03:13 AM
Be sure that you became a root - 1. Flash you Nokia with some options (see maemo wiki) and run a command sudo gainroot. All network commands are available only for root.

TA-t3
01-10-2007, 09:04 AM
As for the ESSID, if it's hidden or not shouldn't matter, as long as you specify the correct ESSID with the iwconfig command. 'Hidden' only means that the AP doesn't broadcast it, you still specify it the same as ever when associating with the AP (access point).