How to configure wifi from the commandline

How to do things, solutions, recipes, tutorials
Message
Author
stevesr0
Posts: 169
Joined: Sun 24 Jun 2007, 17:25

#61 Post by stevesr0 »

I Googled around and found a statement that the configuration files are saved as /etc/name of adaptermode and /etc/name of adapter wireless.

In /etc, I found /etc/eth0mode, /etc/eth0oldmode, /etc/eth0wireless, /etc/wlan0mode and /etc/wlan0wireless.

The three mode files all have the following content:
echo "Trying to get IP address from DHCP server (60sec timeout)..."
echo "Trying to get IP address from DHCP server (60sec timeout)..." > /dev/console
rm /etc/dhcpc/dhcpcd-adapter name.pid 2>/dev/null #if left over from last session, causes trouble.
rm /etc/dhcpc/dhcpcd-adapter name.cache 2>/dev/null #ditto
rm /etc/dhcpc/dhcpcd-adapter name.info 2>/dev/null #ditto
if [ ! -f /root/.dhcpcd.duid ];then
[ -d /etc/dhcpc ] && dhcpcd adapter name || dhcpcd -I '' eth0
else
#[ ! -d /var/lib/dhcpcd ] && mkdir /var/lib/dhcpcd
#[ -s /root/.dhcpcd.duid ] && cp /root/.dhcpcd.duid /var/lib/dhcpcd/dhcpcd.duid
dhcpcd adapter name
fi
and the two wireless files are very similar:

wlan0wireless:
#Configure the wireless interface
echo "Configuring wireless interface wlan0"
ifconfig wlan0 up

iwconfig wlan0 essid "name"
iwconfig wlan0 mode managed
iwconfig wlan0 key open wep key

eth0wireless:
#Configure the wireless interface
echo "Configuring wireless interface eth0"
ifconfig eth0 up

iwconfig eth0 essid "name"
iwconfig eth0 channel x
iwconfig eth0 mode managed
iwconfig eth0 ap xxxxxxxxxx
iwconfig eth0 key open wep key

The eth0 wireless file is the one I select after rebooting to successfully configure my wifi and I then connect via auto DHCP.

Are you suggesting that my problems may be because there are multiple wireless and/or mode files in addition to the code I wrote into my rc.local file?

...And, as a corollary, eliminating the running of these files at boot (by deleting or renaming them) would then likely lead to the running of the rc.local file?

Steve

tempestuous
Posts: 5464
Joined: Fri 10 Jun 2005, 05:12
Location: Australia

#62 Post by tempestuous »

stevesr0 wrote:Are you suggesting that my problems may be because there are multiple wireless and/or mode files in addition to the code I wrote into my rc.local file?
Yes
stevesr0 wrote:...And, as a corollary, eliminating the running of these files at boot (by deleting or renaming them) would then likely lead to the running of the rc.local file?
Yes

stevesr0
Posts: 169
Joined: Sun 24 Jun 2007, 17:25

Solved, if I broadcast

#63 Post by stevesr0 »

Deleting the files didn't work.

I then tried adjusting the rc.local file by adding the address of the router and removing the route add gw command. No change.

Finally, recalling past experience having a problem configuring when my router wasn't broadcasting (and rarsa's comment about broadcasting NOT improving security), I changed the router setting to broadcast the ssid.

In my next (and only, so far) reboot, the connection was automatically made.

It is peculiar that neither my linux based Nokia internet tablet nor this laptop (with Puppy) when running Windows XP have a problem connecting without my router broadcasting.
Somehow, I still feel more secure if my router is not broadcasting.

In rarsa's thread on getting his bcm43xx using computer to autoconnect, he mentions a revised network file (for 4.01, but said to probably work on earlier puppies) on the developer blog. I read the note and tried to look at the file (following a link to ibiblio) but got a 404 error.

Thanks for your help. I am glad to remove extra files when I can. It makes me feel a little more in charge of my system.

Steve

fleamour
Posts: 158
Joined: Tue 20 May 2008, 00:06
Location: UK

#64 Post by fleamour »

Both my network printers print the boxed out code as gobbledygook?!? Not the greatest of help really.

nic2109
Posts: 405
Joined: Mon 01 Jan 2007, 20:24
Location: Hayslope, near Middlemarch, Midlands, England

#65 Post by nic2109 »

Hi; under Puppy 3 and 4.0 this all works just fine with the now obsolete iwp3945 driver module. But with the newer kernels where the module is iwl3945 it's a different story.

I've tried this all the way including the last section on Trouble-shooting encryption but still it's no good - no WPA encrypted wireless. :( .

Open works, WEP works, but WPA is a no-no. Old Network Wizard; new Network wizard; command-line (as per this How-to) are all the same.

Specifically, with the command-line the wpa_supplicant command just loops round endlessly.

Would it be helpful to capture the output and post it? If so, how? I tried to > it into a logfile but that didn't work as some of the output was treated as a command and did some very strange things.
[color=darkblue][b][size=150]Nick[/size][/b][/color]

tempestuous
Posts: 5464
Joined: Fri 10 Jun 2005, 05:12
Location: Australia

#66 Post by tempestuous »

Try the updated wpa_supplicant-0.5.10 from here -
http://www.murga-linux.com/puppy/viewto ... 841#229841

This new version should play better with the new "mac80211" family of wifi drivers in Puppy4.1.

nic2109
Posts: 405
Joined: Mon 01 Jan 2007, 20:24
Location: Hayslope, near Middlemarch, Midlands, England

#67 Post by nic2109 »

tempestuous wrote:Try the updated wpa_supplicant-0.5.10 from here -
http://www.murga-linux.com/puppy/viewto ... 841#229841

This new version should play better with the new "mac80211" family of wifi drivers in Puppy4.1.
Thanks, I've tried that but sadly it's no better. Here's a screenshot of the rvxt window following the the loading of the encryption modules and the wpa_supplicant command (sorry, but I couldn't get it to log into a file). Left to its own devices it loops round and round giving that output.

Sadly it means nothing to me, but does it tell you anything?
Attachments
wpa_supplicant.png
(25.9 KiB) Downloaded 1013 times
[color=darkblue][b][size=150]Nick[/size][/b][/color]

tempestuous
Posts: 5464
Joined: Fri 10 Jun 2005, 05:12
Location: Australia

#68 Post by tempestuous »

I did a Google search for "iwl3945 wpa_supplicant" and I see a lot of stories about problems with hidden SSID's. This seems to match with forum member JustGreg's findings.
So the first thing you should do is configure your router to broadcast the SSID - which, according to rarsa, is actually more secure than a hidden SSID.
Then you should continue running the wpa_supplicant command manually, trying different "ap_scan=" values in /etc/wpa_supplicant.conf (or /etc/wpa_supplicant2.conf for WPA2). Try the values "0", "1", and "2".

nic2109
Posts: 405
Joined: Mon 01 Jan 2007, 20:24
Location: Hayslope, near Middlemarch, Midlands, England

#69 Post by nic2109 »

tempestuous wrote:I did a Google search for "iwl3945 wpa_supplicant" and I see a lot of stories about problems with hidden SSID's. This seems to match with forum member JustGreg's findings.
So the first thing you should do is configure your router to broadcast the SSID - which, according to rarsa, is actually more secure than a hidden SSID.
Then you should continue running the wpa_supplicant command manually, trying different "ap_scan=" values in /etc/wpa_supplicant.conf (or /etc/wpa_supplicant2.conf for WPA2). Try the values "0", "1", and "2".
Sorry about the pause - been away again.

I'm afraid that none of your suggested values worked. They timed out at different speeds, and some of the messages looked a bit different; but still no WPA connection. :(
[color=darkblue][b][size=150]Nick[/size][/b][/color]

tempestuous
Posts: 5464
Joined: Fri 10 Jun 2005, 05:12
Location: Australia

#70 Post by tempestuous »

I think it's worth revisiting the issue of encryption-related modules. I seem to recall that the Intel wifi drivers require a particular encryption module; "michael_mic".

So I suggest that before you run the wpa_supplicant command you first run "lsmod" to see what modules are loaded, looking for the following:

aes_generic
arc4
crc32c
crypto_blkcipher
ecb
michael_mic

If any of these is not loaded, load it manually with "modprobe xxx"
then try the wpa_supplicant command again.

nic2109
Posts: 405
Joined: Mon 01 Jan 2007, 20:24
Location: Hayslope, near Middlemarch, Midlands, England

#71 Post by nic2109 »

tempestuous wrote:I think it's worth revisiting the issue of encryption-related modules. I seem to recall that the Intel wifi drivers require a particular encryption module; "michael_mic".

So I suggest that before you run the wpa_supplicant command you first run "lsmod" to see what modules are loaded, looking for the following:

aes_generic
arc4
crc32c
crypto_blkcipher
ecb
michael_mic

If any of these is not loaded, load it manually with "modprobe xxx"
then try the wpa_supplicant command again.
Thanks. I'll give that another try soon and report back.

Sorry that my attempts nave been rather intermittent, but as I use wireless most of the time, and as others in the household do so all the time, I find that it's only when I don't want to do anything else that I boot up with the newest kernel version and have another go with WPA! My opportunities for fiddling with the wireless settings are fairly limited.

I do have another question that may or may not be germain. In the wpa_supplicant.conf file where we put in our secret pass-phrase, should that be the straight string as we set it up in the router? Or should it be the encrypted value? I have observed that the same file in working (i.e. older kernel) versions have it stored as encrypted, so I have copied that value. Could this be what's screwing it up? It occurs to me that I may have caused my own problems here and wasted our time. But then, if that's true at what point in the process does the encrypted value get written back to over-write the original value? Where I have got WPA to work the .conf file always has a scrambled and unreadable passphrase.

Later Update

Well; what I actually did was to d/l and try 4.1 beta - the latest kernel version. And lo; it worked, right out of the box! :D

Whether it's the network wizard or something else I don't actually know. But for me the struggle is now over.

@Tempestuous If you would like me to try out some other settings on my previous 4.1 (alpha 6 actually) in the interests of understanding then please let me know.

Or we could just give thanks for what we have received and move on.
[color=darkblue][b][size=150]Nick[/size][/b][/color]

tempestuous
Posts: 5464
Joined: Fri 10 Jun 2005, 05:12
Location: Australia

#72 Post by tempestuous »

Nick,
what would be useful is if you could establish a WPA2 connection, then run "lsmod" and list here exactly which of the encryption modules that I mentioned above are loaded.
This may help us troubleshoot encryption problems for others.

nic2109
Posts: 405
Joined: Mon 01 Jan 2007, 20:24
Location: Hayslope, near Middlemarch, Midlands, England

#73 Post by nic2109 »

@Tempestuous As you requested I have run lsmod looking for the various encryption modules you mentioned. The results surprised me as only arc4, crypto_blkcipher and ecb were present. See the attached screenshot.

What the screenshot also shows is the results of searching for 'wpa_supplicant' with pfind. It demonstrates something that surprised me even more which is that the Network Wizard does not appear to have created a wpa_supplicant.conf file with my settings. Either it has a different name or it uses a different setup altogether. I looked at /etc/wpa_supplicant.conf to see whether it held the passphrase straight or encrypted and observed that it was still at all default values. I then noticed that it was dated 2007/02/04 so it's clear that it hasn't been over-written with my values.

'Tis a great mystery - to me at any rate. What do you think is going on here?
[color=darkblue][b][size=150]Nick[/size][/b][/color]

numerix
Posts: 1
Joined: Tue 30 Sep 2008, 16:54
Location: Germany

#74 Post by numerix »

@tempestuous:
Thanks a lot for your detailed description on how to get wlan working by hand. I spend several hours on getting access to the internet with my MSI US54SE WLAN USB stick, but wasn't successfull - neither with WPA nor WEP nor without any encryption.

I got some strange errors, couldn't explain it. Then I followed your instructions and a last found out that the problem was the file /etc/resolv.conf which was a symbolic link to /etc/ppp/resolv.conf which was a symbolic link to /etc/resolv.conf ...

After I repaired that, everything run well - connection is okay now.

I'm new to puppy since a few days, tried (successfully!) to install it on an older notebook and I was really surprised how fast it boots and works on that old hardware.

User avatar
HairyWill
Posts: 2928
Joined: Fri 26 May 2006, 23:29
Location: Southampton, UK

#75 Post by HairyWill »

I have access to an advent 7111 for a few days that has a wireless card 8086:4222 which uses iwl3945 in puppy 4.1rc1, I am using it with a wep connection.

This has given me some grief getting it working but I think I have it sussed now.

The first hurdle was that I got errors trying to bring the interface up, I suspect this was because the hardware kill switch had been activated in windows which is now dead (hooray). I discovered this by looking at the error messages reported by dmesg. I found on the ubuntu forums a suggestion to

Code: Select all

rmmod iwl3945
modprobe iwl945
Presumably the device needs taking down cleanly in software before it can be brought back again properly. This was not needed on subsequent boots.

Then

Code: Select all

ifconfig wlan0 up
iwconfig essid xxxxxxx
iwconfig key zzzzzzzz

configures the card
I then have to take the interface down and bring it back up again. This seems to be crucial. If I don't do this I end up with a 169..... ip address

Code: Select all

ifconfig wlan0 up
ifconfig wlan0 up

and then request an IP addess

Code: Select all

dhcpcd -d wlan0
Will
contribute: [url=http://www.puppylinux.org]community website[/url], [url=http://tinyurl.com/6c3nm6]screenshots[/url], [url=http://tinyurl.com/6j2gbz]puplets[/url], [url=http://tinyurl.com/57gykn]wiki[/url], [url=http://tinyurl.com/5dgr83]rss[/url]

normanp
Posts: 6
Joined: Sat 11 Oct 2008, 12:42

#76 Post by normanp »

rmmod b43
modprobe b43
ifconfig wlan0 up
iwconfig wlan0 essid myessid
iwconfig wlan0 key mykey
ifconfig wlan0 down
ifconfig wlan0 up
dhcpcd -d wlan0
I tried the above up to dhcpcd -d wlan0
This then gave me info up to 'broadcasting for a lease'
sending DHCP_DISCOVER several times then trying old lease - not found
then eventually adds address 169.254.160.169/16.

I can ping 169.254.160.169 successfully

Does this mean the driver is OK but the issue is with my router?
Thsi would be surprising as the router is fine when connecting from win xp.

Does it matter if the essid or key are upper or lower case?

Is there any way to be able to copy from the console window and paste here to show in detail what happened?

Thanks for any help.
BTW I am trying the console approach because the wizard gives no detailed feedback as to why it failed to connect.

tempestuous
Posts: 5464
Joined: Fri 10 Jun 2005, 05:12
Location: Australia

#77 Post by tempestuous »

Try the dhcpcd command like this -

Code: Select all

dhcpcd -I '' -d wlan0
That's hyphen, capital i, space, apostrophe, apostrophe (not quotation marks).

This information can be found in "How to configure wifi from the commandline "
http://www.murga-linux.com/puppy/viewtopic.php?t=22469

normanp
Posts: 6
Joined: Sat 11 Oct 2008, 12:42

#78 Post by normanp »

Thanks tempestuous - I have tried this and the result is the same - the DHCP_DISCOVER fails as before. Is there a log file that I can consult?

mawebb88
Posts: 246
Joined: Sun 13 Jul 2008, 09:54
Location: France nr Lyon

WPA in Puppy 4.1 (SD card) on an EeePC901(rt2860sta driver)

#79 Post by mawebb88 »

Got this working following the instructions in the thread (many thanks). Put the code into an executable script and a link to it in the Startup folder. I use a static IP address. No luck with the Network Wizard but this works just fine for me:

Code: Select all

ifconfig ra0 up
rm /var/run/wpa_supplicant/*
wpa_supplicant -i ra0 -D wext -c /etc/network-wizard/wireless/wpa_profiles/wpa_supplicant.conf -B
sleep 1
ifconfig ra0 192.168.1.239 netmask 255.255.255.0 broadcast 192.168.1.255
route add default gw 192.168.1.1
sleep 1
iwconfig ra0 key open
The wpa_supplicant is:

Code: Select all

ctrl_interface=/var/run/wpa_supplicant
ap_scan=1
update_config=1

network={
	ssid="my ssid"
	scan_ssid=1
	psk="my psk"
	proto=WPA
	key_mgmt=WPA-PSK
	pairwise=TKIP
	group=TKIP
}

juhasza
Posts: 1
Joined: Fri 31 Oct 2008, 19:17

iwconfig not working ?

#80 Post by juhasza »

Hello
I configuring my wlan ,and i look this:
# iwconfig
lo no wireless extensions.
eth0 no wireless extensions.
wlan0 IEEE 802.11b ESSID:off/any
Mode:Managed Frequency:2.437 GHz Access Point: Not-Associated
Bit Rate:11 Mb/s Tx-Power:24 dBm Sensitivity=0/3
RTS thr:off Fragment thr:off
Encryption key:6B69-6E67-614B-494E-4741-3132-33 Security restricted
Power Management:off Link Quality:0 Signal level:0 Noise level:0 Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0


# iwconfig wlan0 essid "nokia6ex"
# iwconfig
lo no wireless extensions.

wlan0 IEEE 802.11b ESSID:off/any
# uname -a
Linux puppypc 2.6.25.16 #1 Tue Aug 26 10:45:53 GMT-8 2008 i686 GNU/Linux

where my esid ??

# cat /etc/issue
Puppy Linux
Linux 2.6.25.16 [i686 arch]

thanks
a

Post Reply