How to configure wifi from the commandline

How to do things, solutions, recipes, tutorials
Post Reply
Message
Author
User avatar
davids45
Posts: 1326
Joined: Sun 26 Nov 2006, 23:33
Location: Chatswood, NSW

#16 Post by davids45 »

G'day 'stu',
Thanks for your continued advice.
I did have another play last night trying wlan0 in place of rausb0 but got much the same result with your original code lines.
An extra Blinky appeared (eth0 is there and OK) but nothing wifi actually working.

However while later adding an sfs to my frugal /mnt/home, I noticed the 'system start' tool for doing this also has a black-listing capability for 'de-fault' drivers that are not suitable (= "the-fault drivers"??). So, using this, I stopped rt2570 from loading and added "ndiswrapper" as a to-be-loaded driver. On re-starting the 'puter, and then the network wizard, there was no pre-loaded default wifi network driver and I was able to click the ndiswrapper tab and link to my XP rt2500 inf file without error messages, or 'no new network' boxes when then testing with the wizard. So I had a working WPA wireless network. And it was registering on RutilT which I had thought was only for WEP systems.

The big test was this morning with a cold re-start. Having two minutes** before fleeing to work, had time to start-up, see the two network blinkies, use RutilT to check the wireless blinky was my network (and not one of the neighbours' open systems), check my email, then close down. So, success!

Thanks again,
David S.

**do that with Windows!

nobles
Posts: 9
Joined: Wed 12 Dec 2007, 15:55
Location: Winnipeg, Canada

#17 Post by nobles »

I edited /etc/wpa_supplicant.conf and followed the commands in Part 2 and did get WPA working with my DLink WPA-PSK router but I had to start another terminal session to enter the dhcpcd command as the wpa_supplicant command never successfully returned to the command prompt (although it obviously did its work as the encryption was setup). When I entered the dhcpcd command in the second terminal, I successfully got an IP address and I could browse the Internet. This was with a DLink Atheros based card using the ath_pci driver.

User avatar
yorkiesnorkie
Posts: 504
Joined: Mon 04 Jun 2007, 13:11
Location: George's Island

Re: excellent

#18 Post by yorkiesnorkie »

Hi,

I'm still a linux command line newbie. I can follow the command line stuff here but I'm not sure I quite understand what to do with a script. Where does the following script go? Is it just a file in /root? Do you call it anything special? Or, do I add it to one of the files?

Yorkiesnorkie
:-)

edit: I'm reading stuff on bash scripting...
raffy wrote:Thanks! An excellent HowTo from an esteemed developer for Puppy Linux. This will be useful for inclusion in Puppy Linux manuals.

Recently, I experimented with a simple user-editable script for activating wifi in a simple network setup using only ESSID. The example device is D-Link USB DWL-G122 with driver rt2570.

Code: Select all

#!/bin/sh
# Edit this file to input your own WiFi values
# then save and click to get your WiFi working!
# The file is in /root (open /root via Menu - Files - Rox)

####################################################################
# change rt2570 below to the name of your wifi chip

modprobe rt2570
sleep 5 # give it some time

####################################################################
# "rausb0" is for USB wifi device; use "ra0" if it is an internal device

ifconfig rausb0 up

####################################################################
# now start it - change "rausb0" to "ra0" if needed
# also change "linksys" to the essid of your wifi network

iwconfig rausb0 essid linksys

####################################################################
# clear the dhcpc folder (nothing to change here)

rm /etc/dhcpc/dhcpcd-eth0.pid 2>/dev/null #clear stale files
rm /etc/dhcpc/dhcpcd-eth0.cache 2>/dev/null #ditto
rm /etc/dhcpc/dhcpcd-eth0.info 2>/dev/null #ditto

####################################################################
# automatically get an IP address
# change "rausb0" to "ra0" if needed

dhcpcd -t 20 rausb0
(As to Jonyo, that could help. But note that Puppy was described as "amazing" in the Ubuntu forum: http://ubuntuforums.org/showthread.php?t=281922 )

User avatar
Pizzasgood
Posts: 6183
Joined: Wed 04 May 2005, 20:28
Location: Knoxville, TN, USA

#19 Post by Pizzasgood »

The only important thing is that you set it executable. You could right-click it and go to properties or permissions to do it, or from the commandline run
chmod 755 script_name
(if you aren't in the same directory as it, you need to include the path to the script rather than just its name)

As for naming, scripts sometimes end with a .sh extension, but that's optional. Very few scripts in Puppy use that. You can pretty much name them whatever you want, but it's best to choose something unique, especially if you put it in the path.

Where you put it is up to you. If it's something to run each boot, you might want to put it in /etc/rc.d/ and maybe name it starting in rc.<whatever> (but that doesn't affect anything).

One thing to keep in mind with placement is that if you put it in the path (/bin, /sbin, /usr/bin, /usr/sbin, /usr/local/bin, etcetera) you can run it by just typing it's name in the commandline, just like it's another application. Otherwise, you need to include the path to run it.


If you want it run every boot, you could add a line in /etc/rc.d/rc.local to run it (just type the name or path as appropriate on a blank line). Another method is to add an
if [ "$1" = "start" ]; then
to the beginning (after the #!/bin/sh part though), and a
fi
to the end, then place it in /etc/init.d. Then it will be automatically run every time Puppy boots. (The reason for the changes is because Puppy runs ever executable file in that directory with the "start" parameter on boot, and with the "stop" parameter on shutdown. As it was, it would run the same no matter what parameters were passed in. For booting, that's fine. But you don't really want it getting run again when you try to shut down. You could actually add another section to bring down the wireless interface, but that's not necessary (might be handy if you needed to disable it though, like to unplug the USB dongle without locking up the machine).

Code: Select all

if [ "$1" = "stop" ]; then
ifconfig rausb0 down
rmmod rt2570
fi
[size=75]Between depriving a man of one hour from his life and depriving him of his life there exists only a difference of degree. --Muad'Dib[/size]
[img]http://www.browserloadofcoolness.com/sig.png[/img]

User avatar
yorkiesnorkie
Posts: 504
Joined: Mon 04 Jun 2007, 13:11
Location: George's Island

Awesome Response

#20 Post by yorkiesnorkie »

Hi Pizzasgood,

Thanks for the detailed reply. Its awesome! That's exactly the information I was looking for to connect the dots. This stuff is very interesting I might add. While not a programming expert, I can see the potential to tinker with the inner workings and get it working the way I want.

So now I have to edit Raffy's script to fit my situation. I also have a choice to make, whether to run it myself whenever I want it to connect, or to have it run automatically. Hmmm... Well I'll definitely take a run at this because it would be nice to have it work on startup since the first thing I do usually is check the mail.

Until later!

Yorkiesnorkie
:-)

allanlewis
Posts: 24
Joined: Thu 03 Jan 2008, 12:07

Roaming between three networks: 1 WEP, 1 WPA, 1 unsecured

#21 Post by allanlewis »

Hi,

I followed the instructions at the beginning of this thread to set up a WEP connection - let's call this location A - and it works perfectly, although it slows my startup by about 30 seconds. I'm now at location B where I have a WPA network - the wizard connected to that first time, no problems, and I know I could script this using wpa_supplicant, but how can I get Puppy to work out which network is visible (the two locations are ~150 miles apart) and then choose WEP (i.e. iwconfig) or WPA (i.e. wpa_supplicant) as the connection method? In addition, I also have access to an unsecured network (my University's - there is no encryption but you have to log on over the web to access the internet) which I would like to be able to connect to automatically, although this is not so important.

Can anyone give me some pointers as to how to do this?

User avatar
Pizzasgood
Posts: 6183
Joined: Wed 04 May 2005, 20:28
Location: Knoxville, TN, USA

#22 Post by Pizzasgood »

Theoretically, you can save the settings for more than one network in wpa_supplicant.conf, and then the wpa_supplicant program is supposed to automagically choose which one to connect to. It's also supposed to be able to handle WEP networks. I don't know how to do that though.

A less elegant method would be to set it up to configure everything for the WEP network up to just before it runs dhcpcd. Then use iwlist to see if the network is available (pipe it into grep, and probably try it a couple times in case the card has trouble seeing it). If the network isn't available, switch to the WPA method.
[size=75]Between depriving a man of one hour from his life and depriving him of his life there exists only a difference of degree. --Muad'Dib[/size]
[img]http://www.browserloadofcoolness.com/sig.png[/img]

allanlewis
Posts: 24
Joined: Thu 03 Jan 2008, 12:07

#23 Post by allanlewis »

Ok, it seems that WPA supplicant solves all my problems - apparently I can just create a single configuration file listing my three networks and it will automatically choose the best one. It even prefers better security, all other things being equal! Brilliant :D

Thanks!

Update:

I now have it automatically connecting to my WPA network by manually calling wpa_supplicant from rc.local with my new wpa_supplicant.conf! All I now have is four lines:

Code: Select all

ifconfig eth0 up
wpa_supplicant -Dwext -ieth0 -c/etc/wpa_supplicant.conf
rm /etc/dhcpc/*.pid
dhcpcd -t 30 -h puppypc -d eth0
I think I'll write a quick "howto" on the appropriate board. (I'll put a link here if I remember.)

Update:

Take a look at my first ever HOWTO! (That's on anything, ever, IIRC!)

User avatar
LuisS
Posts: 4
Joined: Sun 02 Dec 2007, 19:13

#24 Post by LuisS »

Don't know if this public thanks fits the subject, but, by having my wireless pen SMC WUSB-G (ndiswrapper) working flawlessly with WPA2 I really feel I must thank everyone here, specially tempestuous and Pizzasgood. Thanks a lot.

(Sorry, I go sentimental when I get things done on computers)

crosscountry
Posts: 3
Joined: Wed 25 Jul 2007, 23:35

Rutilit works for me

#25 Post by crosscountry »

Puppy 3.01 loads the bcm43xx module on my Dell D620. Both the network wizard and the command line tricks in the post fail every time on both dhcp and static ip. RutilT works perfectly tho, if you don't mind entering the key each time. Good enough for me, I can't fight this any more.

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

#26 Post by tempestuous »

I just added a new section "PART 4: Troubleshooting, encryption problems" to an earlier post, to avoid the extra information being spread throughout this thread.
http://www.murga-linux.com/puppy/viewto ... 339#159339

jonyo

#27 Post by jonyo »

Suggest editing your first post with links to all the additional info.

User avatar
gasmaskpipe
Posts: 15
Joined: Sun 27 May 2007, 17:17
Location: Cornwall, UK

#28 Post by gasmaskpipe »

After quite a bit of messing around, I managed to get auto DHCP from startup on this Dell Vostro 1000 with Broadcom 43xx card. The bcm43xx driver seems to work fine for me, whereas I could not get the windows driver bcmwl5.inf to work at all through ndiswrapper.
I think the DHCP problem is it trying to log-in the card immediately after turning it on, as someone else suggested. I therefore added this to rc.local and now I'm on the net as soon puppy starts and I click on Firefox. eth0wireless & eth0mode files can be deleted, which will stop the network card being booted twice at startup. Basically it's putting a delay in the initialisation of the card, but why it won't work if you put the same script into eth0wireless I'm unsure.

Code: Select all

rmmod bcm43xx
modprobe bcm43xx
sleep 5s
ifconfig eth0 up
 iwconfig eth0 essid xxxxxxxxxx
 iwconfig eth0 channel x
 iwconfig eth0 mode managed
 iwconfig eth0 key open xxxxxxxxxx
 rm /etc/dhcpc/*.pid
dhcpcd -t 30 -h puppypc -d eth0
(obviously with relevant data in place of xxx's and change eth0 if different)

User avatar
Locky
Posts: 23
Joined: Wed 01 Mar 2006, 11:23

#29 Post by Locky »

How about an addition for compiling the ndiswrapper from scratch. This is often the best route for the absolute latest hardware as far as I know.

I'm a newbie currently struggling with this for my new laptop. ndiswrapper works for ubuntu with version 1.51.

see thread http://www.murga-linux.com/puppy/viewtopic.php?t=29334

User avatar
roganty
Posts: 7
Joined: Sat 10 May 2008, 16:36
Location: Bristol, UK
Contact:

#30 Post by roganty »

How about updating this for version 4?

It seems that wireless setup is different in the latest release, as no matter what there is no dhcpc folder in /etc
Yet when I try to run dhcpcd it says its already running

Also, if i run

Code: Select all

iwconfig ra0 essid name
iwconfig ra0 key open 0102030405060708090a0b0c0d
iwconfig ra0 mode manage
and then run

Code: Select all

iwconfig
it does not show that the essid has been set, but the other values have been set

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

#31 Post by tempestuous »

Update June 12 2008:
The version of dhcpcd in Puppy 4.x uses different locations for its configuration files than in earlier versions of Puppy.
So I have just updated the first post regarding the correct dhcpcd commands.

User avatar
shri
Posts: 12
Joined: Fri 13 Jun 2008, 05:11

Hi

#32 Post by shri »

Hi to all
i am useing puppy2.02 with kernel 2.6.16.7.when i am connect to modem (ZTE Model no:-Classic 23) its can't connect.
when i am cat /proc/bus/usb/devices its shows me

=03 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#= 2 Spd=12 MxCh= 0
D: Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
P: Vendor=10c4 ProdID=ea60 Rev= 1.00
S: Manufacturer=Silicon Labs
S: Product=USB to UART Bridge Controller
S: SerialNumber=0001
C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=100mA
I: If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=(none)
E: Ad=81(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms
E: Ad=01(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms

when i am useing Minisys kernel 2.6.21.7 its get connected to my pc.
when i am cat /proc/bus/usb/devices its shows me

=03 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#= 2 Spd=12 MxCh= 0
D: Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
P: Vendor=10c4 ProdID=ea60 Rev= 1.00
S: Manufacturer=Silicon Labs
S: Product=USB to UART Bridge Controller
S: SerialNumber=0001
C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=100mA
I: If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=cp2101
E: Ad=81(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms
E: Ad=01(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms

how to get cp2101.ko file for kernel 2.6.16.7 or any other source code to download this file.or any other tips or trics to connect modem (ZTE Model no:-Classic 23) with kernel 2.6.16.7.

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

#33 Post by tempestuous »

Your device is a wireless modem, not a wifi network adaptor.
It is not relevant to this thread.

And please don't cross-post your query in multiple threads.

User avatar
shri
Posts: 12
Joined: Fri 13 Jun 2008, 05:11

Sorry

#34 Post by shri »

:cry: sorry tempestuous. :cry:
next time i do this.

AceVentura
Posts: 12
Joined: Tue 01 Jul 2008, 04:35
Location: Mumbai - City of Dreams

WiFi on Sony VAIO CR 23 G using Billion Bipac 5200 router

#35 Post by AceVentura »

Hi,

I am a newbie in Linux arena, but have enuf knowledge of command line to navigate around. I am facing a issue configuring my Vaio to have wireless net access from Puppy Linux 4.0.

Hardware:
Sony VAIO VGN CR23G
Intel Core 2 Duo 2 GHz
1 GB RAM
Intel Pro Wireless 3945

Router:
Bilion Bipac 5200 Wireles modem + Router
SSID TESTINGHOME <example>
passphrase testing <example>
WPA2-PSK using TKIP

Software:
Puppy Linux 4.00
wpa_supplicant

I have tried all the things that have been mentioned previously but am not able to access wirelessly. Any hellp will be much appreciated.


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

network={
ssid="XXXXXXXXXX"
psk="XXXXXXXXXXX"
proto=WPA2
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP
}
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
The commands I ran were :

modprobe ipw3945
<<nno response>>

ifconfig eth1 up
<<nno response>>

rm /var/run/wpa_supplicant/*
<<no such file found>>

wpa_supplicant -i eth1 -D wext -c /etc/wpa_supplicant2.conf -dd
<<this runs in a loop and never comes back to console>>

<<did not run the below commands>>
rm /etc/dhcpc/*.pid
dhcpcd -t 30 -h puppypc -d eth1

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Output from the wpa_supplicant command.
I had it aborted as it was looping indefintely.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Initializing interface 'eth1' conf '/etc/wpa_supplicant2.conf' driver 'wext' ctrl_interface 'N/A' bridge 'N/A'
Configuration file '/etc/wpa_supplicant2.conf' -> '/etc/wpa_supplicant2.conf'
Reading configuration file '/etc/wpa_supplicant2.conf'
ctrl_interface='/var/run/wpa_supplicant'
ap_scan=2
update_config=1
Line: 5 - start of a new network block
ssid - hexdump_ascii(len=14):
54 68 65 20 4c 6f 73 74 20 57 6f 72 6c 64 The Lost World
PSK (ASCII passphrase) - hexdump_ascii(len=14): [REMOVED]
proto: 0x2
key_mgmt: 0x2
pairwise: 0x8
group: 0x8
PSK (from passphrase) - hexdump(len=32): [REMOVED]
Priority group 0
id=0 ssid='The Lost World'
Initializing interface (2) 'eth1'
EAPOL: SUPP_PAE entering state DISCONNECTED
EAPOL: KEY_RX entering state NO_KEY_RECEIVE
EAPOL: SUPP_BE entering state INITIALIZE
EAP: EAP entering state DISABLED
EAPOL: External notification - portEnabled=0
EAPOL: External notification - portValid=0
SIOCGIWRANGE: WE(compiled)=22 WE(source)=16 enc_capa=0xf
capabilities: key_mgmt 0xf enc 0xf
WEXT: Operstate: linkmode=1, operstate=5
Own MAC address: 00:1c:bf:59:b3:70
wpa_driver_wext_set_wpa
wpa_driver_wext_set_key: alg=0 key_idx=0 set_tx=0 seq_len=0 key_len=0
wpa_driver_wext_set_key: alg=0 key_idx=1 set_tx=0 seq_len=0 key_len=0
wpa_driver_wext_set_key: alg=0 key_idx=2 set_tx=0 seq_len=0 key_len=0
wpa_driver_wext_set_key: alg=0 key_idx=3 set_tx=0 seq_len=0 key_len=0
wpa_driver_wext_set_countermeasures
wpa_driver_wext_set_drop_unencrypted
Setting scan request: 0 sec 100000 usec
Added interface eth1
RTM_NEWLINK: operstate=0 ifi_flags=0x1002 ()
Wireless event: cmd=0x8b06 len=8
RTM_NEWLINK: operstate=0 ifi_flags=0x1003 ([UP])
RTM_NEWLINK, IFLA_IFNAME: Interface 'eth1' added
RTM_NEWLINK: operstate=0 ifi_flags=0x1003 ([UP])
RTM_NEWLINK, IFLA_IFNAME: Interface 'eth1' added
State: DISCONNECTED -> SCANNING
Trying to associate with SSID 'The Lost World'
Cancelling scan request
WPA: clearing own WPA/RSN IE
Automatic auth_alg selection: 0x1
WPA: No WPA/RSN IE available from association info
WPA: Set cipher suites based on configuration
WPA: Selected cipher suites: group 8 pairwise 8 key_mgmt 2 proto 2
WPA: clearing AP WPA IE
WPA: clearing AP RSN IE
WPA: using GTK TKIP
WPA: using PTK TKIP
WPA: using KEY_MGMT WPA-PSK
WPA: Set own WPA IE default - hexdump(len=22): 30 14 01 00 00 0f ac 02 01 00 00 0f ac 02 01 00 00 0f ac 02 00 00
No keys have been configured - skip key clearing
wpa_driver_wext_set_drop_unencrypted
State: SCANNING -> ASSOCIATING
wpa_driver_wext_set_operstate: operstate 0->0 (DORMANT)
WEXT: Operstate: linkmode=-1, operstate=5
wpa_driver_wext_associate
Setting authentication timeout: 60 sec 0 usec
EAPOL: External notification - EAP success=0
EAPOL: External notification - EAP fail=0
EAPOL: External notification - portControl=Auto
RTM_NEWLINK: operstate=0 ifi_flags=0x1003 ([UP])
Wireless event: cmd=0x8b06 len=8
RTM_NEWLINK: operstate=0 ifi_flags=0x1003 ([UP])
Wireless event: cmd=0x8b1a len=22
CTRL-EVENT-TERMINATING - signal 2 received
Removing interface eth1
State: ASSOCIATING -> DISCONNECTED
wpa_driver_wext_set_operstate: operstate 0->0 (DORMANT)
WEXT: Operstate: linkmode=-1, operstate=5
No keys have been configured - skip key clearing
EAPOL: External notification - portEnabled=0
EAPOL: External notification - portValid=0
wpa_driver_wext_set_wpa
wpa_driver_wext_set_drop_unencrypted
wpa_driver_wext_set_countermeasures
No keys have been configured - skip key clearing
Cancelling scan request
Cancelling authentication timeout
WEXT: Operstate: linkmode=0, operstate=6


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Post Reply