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

Got WPA2 connection after adding file named .WPA2.conf to

#141 Post by stevesr0 »

I was able to connect with the network wizard ("Connect" app) only after I copied the contents of the wpa_supplicant2.conf file to a file named .WPA2.conf in the same directory (/etc/network-wizard/wireless/wpa_profiles.

The reason I created this file is that the program gave me an error message saying there was no supplicant file named .WPA2.conf.

I didn't notice a mention of this file in this thread, so I posted this.

I am running puppy 4.2.1.

Thanks for this thread.

Steve

:

User avatar
Spaccafumo
Posts: 33
Joined: Thu 15 Jan 2009, 11:06
Location: Sulmona - Italy

Suddenly happens.

#142 Post by Spaccafumo »

My wireless module is: ath_pci
On the same pc i have 2 puppy 4.30 (old kernel), one for each hard disk (full installation).
All went well during last months. Yesterday, suddenly, wifi connection of puppy installed in hda1 failed whereas the other one in hdb1 is still perfect (I am using it now).
Network-wizard reported:
-----------------
Failed to connect to wpa_supplicant - wpa_ctrl_open: No such file or directory
-----------------
I went to /var/run , made a "wpa_supplicant" directory but
it was erased as soon as i attempted to restart the connection (by Network wizard).

Is there any file in hdb1 (where connection is OK) to copy in hda1 (where connection fails) to solve the problem by a file-transfusion?
Saluti.
I downgraded to wep-128. So i solved. :oops:
Last edited by Spaccafumo on Wed 21 Dec 2011, 13:17, edited 1 time in total.
Qui si usa Linux
http://www.puppylinux.org
Sulmona - Italy

cortezthekiller
Posts: 4
Joined: Sun 14 Feb 2010, 19:38

#143 Post by cortezthekiller »

Excellent post, it really helped me .
thanks a lot!!

jcinpv
Posts: 1
Joined: Sat 27 Feb 2010, 01:17

Puppy and WiFi setup

#144 Post by jcinpv »

I quote: Puppy's Network Wizard is one of the best in the business.

I got this out of the very first forum entries in this thread.

I spent the better part of several hours trying to get Puppy to connect to my hidden SSID. Finally, I enabled broadcasting the SSID and I was able to connect using the same setup as before.

So where in that is "one of the best in the business"?

User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

#145 Post by Flash »

You should see the worst. :lol:

Seriously, we appreciate the detailed feedback. It should be very helpful in improving Puppy's network wizard. In addition we will gladly refund your purchase price, and you can keep your Puppy. :P

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

#146 Post by tempestuous »

When forum member rarsa announced the initial development of the wifi component of the Network Wizard approximately 3 years ago, I warned him that it was near-impossible to accommodate the configuration differences of all wifi adaptors and access points, and that he would probably receive no thanks from the majority of users whose configurations work perfectly, but more likely abuse from the minority whose configurations don't work perfectly.
The earlier post is a sad confirmation of this prediction.

It needs to be noted, at the outset, that we're talking about an individual instance here.
It should also be noted that hidden SSID's can be a problem in Linux usually with WPA encryption (even though the poster failed to indicate the type of encryption being used). This is a shortcoming of wpa_supplicant, the application running behind the Network Wizard, and this will be the case (obviously) with all Linux distributions. But more fairly, it's also a shortcoming of certain Linux drivers which fail to interact with wpa_supplicant in a standardised manner.
So again, success or failure will often depend on the nuances of the particular combination of wifi device and router.
Forum member JustGreg did some thorough testing with hidden SSID's here
http://www.murga-linux.com/puppy/viewtopic.php?t=29205

You will see that some wifi devices (and their Linux drivers) work fine, some don't.

Windows XP contains very few, if any, wifi drivers. Most are provided by the individual vendors, and the only reason opensource drivers and utilities need to be used in Linux is because of the discriminatory practice of many wifi vendors in not providing Linux drivers, themselves.
Ultimately, any "failure" under Linux is directly the fault of the wifi device manuafacturers.

And in this particular instance, the wifi connection failure was actually due to the user setting their router for hidden SSID (which is not the default setting on a wifi router) ...
which is not such a bad thing, because hiding your router's SSID, ironically, makes your wifi network less secure.
This has been discussed in technical detail on the forum before
"HOW-TO have a more secure wireless network"
http://www.murga-linux.com/puppy/viewto ... 892#207892

gerry
Posts: 986
Joined: Thu 26 Jul 2007, 21:49
Location: England

#147 Post by gerry »

Confession: I've not read every post all the way through this topic, but my rapid scan did not see my problem mentioned.
EDIT: I've read it all now, so...

I'm trying to set up wifi on Puppy 4.3.1 on an Acer Aspire One. Wizard does not work, but the command line method does. Hurrah!! But the configuration does not survive a reboot.

I'm running live usb stick, with a save file on the hard drive.

One odd thing is that all those files that we delete in the config process do not appear afterwards. Should they? Do I need to provide empty directories/files?

gerry

ddubois
Posts: 1
Joined: Thu 29 Jul 2010, 19:04

#148 Post by ddubois »

The network wizard works great for me, except for the bit about saving a profile and automatically using it on the next boot. I have to re-run the network wizard every boot. Before I resort to trying to trying to determine all the correct parameters for a command line script to leave on my desktop, does anyone have any suggestions for me?

SimpleWater
Posts: 94
Joined: Tue 19 Apr 2011, 11:53

#149 Post by SimpleWater »

i used Vettephil's simple script on the first page. Works nicely 8)

User avatar
Spaccafumo
Posts: 33
Joined: Thu 15 Jan 2009, 11:06
Location: Sulmona - Italy

Replacing wpa to wep in iwconfig.

#150 Post by Spaccafumo »

How to replace this wep-128 (ascii) command:
iwconfig eth0 key s:asciipassword
with a wpa2 analogous command?
Can you write any example-text?

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

#151 Post by tempestuous »

Spaccafumo wrote:How to replace this wep-128 (ascii) command:
iwconfig eth0 key s:asciipassword
with a wpa2 analogous command?
See "PART 2: WPA encryption" on the first page of this thread
http://www.murga-linux.com/puppy/viewto ... 336#159336

renketsu0
Posts: 3
Joined: Thu 14 Jun 2012, 17:50

#152 Post by renketsu0 »

I had a startup script working perfectly until a few weeks ago when all of a sudden it gets stuck in some loop during the 4 way handshake. I didn't change any configuration files on router or within puppy so I'm not sure what caused this change.

In addition to being stuck in an infinite 4-way handshake loop, after I halt the command my router goes nuts and refuses to connect any other client until I reset it.

I should note that I can connect via net-setup.sh for some reason, even though it appears to issue the same command and points to the same config file I am pointing to.

My script is

Code: Select all

#!/bin/sh

ifconfig wlan0 down
modprobe rtl8187
sleep 3s
ifconfig wlan0 up

rm /var/run/wpa_supplicant/*

wpa_supplicant -B -i wlan0 -D wext -c /etc/network-wizard/wireless/wpa_profiles/wpa_supplicant2.conf 
rm -f /var/lib/dhcpcd/*.info
rm -f /var/run/*.pid

# start dhcp
dhcpcd -t 30 -h myhost -d wlan0

# start the firewall
/etc/rc.d/rc.firewall
I remove -B and add -dd to see a bunch of stuff I don't understand, but I do notice

Code: Select all

...
Cancelling authentication timeout
State: GROUP_HANDSHAKE -> COMPLETED
CTRL-EVENT-CONNECTED - Connection to MAC:ADD completed (auth) [id=0 id_str=]
wpa_driver_wext_set_operstate: operstate 0->1 (UP)
netlink: Operstate: linkmode=-1, operstate=6
EAPOL: External notification - portValid=1
EAPOL: External notification - EAP success=1
EAPOL: SUPP_PAE entering state AUTHENTICATING
EAPOL: SUPP_BE entering state SUCCESS
EAP: EAP entering state DISABLED
EAPOL: SUPP_PAE entering state AUTHENTICATED
EAPOL: Supplicant port status: Authorized
EAPOL: SUPP_BE entering state IDLE
EAPOL authentication completed successfully
RTM_NEWLINK: operstate=1 ifi_flags=0x11043 ([UP][RUNNING][LOWER_UP])
RTM_NEWLINK, IFLA_IFNAME: Interface 'wlan0' added
RTM_NEWLINK: operstate=1 ifi_flags=0x11043 ([UP][RUNNING][LOWER_UP])
RTM_NEWLINK, IFLA_IFNAME: Interface 'wlan0' added
Wireless event: cmd=0x8b15 len=20
Wireless event: new AP: MAC:ADD
State: COMPLETED -> ASSOCIATED
wpa_driver_wext_set_operstate: operstate 1->0 (DORMANT)
netlink: Operstate: linkmode=-1, operstate=5
Associated with MAC:ADD
WPA: Association event - clear replay counter
WPA: Clear old PTK
EAPOL: External notification - portEnabled=0
EAPOL: SUPP_PAE entering state DISCONNECTED
EAPOL: Supplicant port status: Unauthorized
EAPOL: SUPP_BE entering state INITIALIZE
EAPOL: Supplicant port status: Unauthorized
EAPOL: External notification - portValid=0
EAPOL: Supplicant port status: Unauthorized
EAPOL: External notification - EAP success=0
EAPOL: Supplicant port status: Unauthorized
EAPOL: External notification - portEnabled=1
EAPOL: SUPP_PAE entering state CONNECTING
...
with MAC:ADD substituting for the real MAC addresses. It seems it actually is connecting, but then disconnecting and retrying for some reason.

Any ideas on how I can fix this? I'd even be satisfied if I could just script whatever net-setup.sh is doing when I click the "use this profile" button to execute at boot since that apparently works.[/code]

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

#153 Post by tempestuous »

At the outset I reiterate that manual wifi configuration is only necessary if the Puppy Network Wizard does not work, or you have some special requirement.

First up, I see a problem with your script -

Code: Select all

ifconfig wlan0 down
modprobe rtl8187
Puppy will almost certainly have automatically loaded the rtl8187 driver, so it appears that you're forcibly loading this same driver a second time! This will most likely corrupt the driver (and the wifi device).
If you feel that the rtl8187 driver needs to be reloaded, it's important that you unload the driver, first. It's not good enough just to take down the interface with "ifconfig wlan0 down".

renketsu0 wrote:I'd even be satisfied if I could just script whatever net-setup.sh is doing when I click the "use this profile" button to execute at boot since that apparently works.
Once you have run the Network Wizard, and click the "save" button, you have enabled the net-setup.sh script to run at each boot up. And since it works, great ... but you appear to be still running your own separate script - so the two will be fighting each other! Which one wins depends on where in the boot sequence you have located your script!

I suspect the best solution would be to forget about your script, and just use the Network Wizard.
Don't use the Simple Network Wizard - this has a relatively high failure rate, especially with WPA encryption.

renketsu0
Posts: 3
Joined: Thu 14 Jun 2012, 17:50

#154 Post by renketsu0 »

Actually network wizard doesn't connect me on boot, not even right after install and only running the wizard once with net-setup.sh. That's the only reason I wanted to script it.

I'm glad you mentioned driver corruption though, as it caused me to take a close look at the drivers. It turns out puppy was using the r8180 for my card and not rtl8187 (even though my card is an 8187). My fault for not looking to see what it detected first. After removing that line everything works fine. Thanks!

renketsu0
Posts: 3
Joined: Thu 14 Jun 2012, 17:50

#155 Post by renketsu0 »

I have a new problem. Getting wireless running is working fine but it seems my wireless router for whatever reason disconnects all clients whenever a new client connects. Or rather when I look at the router's log it shows that the previously connected clients are stuck in some reauthentication loop and connection on the client-side is shown as dropped. This will go on until I manually disconnect and reconnect. While I know it's really time for a new router I can't help but think there's a way to code reauthentication into my script. But I have no idea how I would go about doing that. Any ideas?

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

#156 Post by tempestuous »

I urge all newcomers only to resort to ndiswrapper as a last resort! The success rate of ndiswrapper is low, and you will generally get a more reliable wifi connection by using a true Linux driver.

Ibidem
Posts: 549
Joined: Wed 26 May 2010, 03:31
Location: State of Jefferson

Poking at sysfs

#157 Post by Ibidem »

I found out the basics of this reading SNS-retro, then poked around a little more.

All interfaces are symlinks under /sys/class/net/; these symlinks point to "../../class/<bus id>/net/<interface>".
So /sys/class/net/$INTERFACE/../../ is the directory for the device.

Within this directory, there are several files:
uevent contains the information passed at hotplug, more-or-less
For example:

Code: Select all

$ cat /sys/class/net/wlan0/../../uevent
DRIVER=rtl8192se
PCI_CLASS=28000
PCI_ID=10EC:8172
PCI_SUBSYS_ID=10EC:E020
PCI_SLOT_NAME=0000:03:00.0
MODALIAS=pci:v000010ECd00008172sv000010ECsd0000E020bc02sc80i00
DRIVER is the module name; MODALIAS is how it got loaded...
driver/module/parameters/ contains all module parameters.
If you have a wireless device, wireless/ contains several files:
beacon
crypt
fragment
level
link (I think this tells signal strenth)
misc
noise
nwid
retries
status

To find all network devices and identify the driver:

Code: Select all

#!/bin/sh
cd /sys/class/net
INTERFACES="`ls`"

WL=""
ETH=""
LO=""
for IFACE in $INTERFACES
do
	if [ -e $IFACE/wireless ]
	then
		echo "wireless ${IFACE} `grep DRIVER ${IFACE}/../../uevent`"
		WL="$WL $IFACE"
	elif [ -e $IFACE/../../uevent ]
	then
		echo "wired ${IFACE} `grep DRIVER ${IFACE}/../../uevent`"
		ETH="$ETH $IFACE"
	else
		echo "virtual $IFACE"
		LO="$LO $IFACE"
	fi
done

Ibidem
Posts: 549
Joined: Wed 26 May 2010, 03:31
Location: State of Jefferson

#158 Post by Ibidem »

I've mentioned the basic concept for this here, but I figured I'd cover it here...

wpa_cli -a <script> makes wpa_cli run as a daemon, and it automatically executes the script with interface name and CONNECTED or DISCONNECTED whenever wpa_supllicant connects or disconnects.
This can be used to run a dhcp client at the right time:

Code: Select all

#!/bin/sh
case $2 in
CONNECTED)
udhcpc -i $1 -h `hostname`
;;
DISCONNECTED)
;;
*)
;;
esac 
Some extensions:
Add a "manual terminate" feature
Run the DHCP client in the foreground, then cleanup the PID file on exit.
Kill the DHCP client on disconnect (may make flakey connections worse?)
rescan/reassociate on disconnect (likewise?)
Bring up VPN connection.

And a partial implementation:

Code: Select all

#!/bin/sh
export PIDFILE=/var/run/udhcpc/${1}.pid
dhcp_lease()(
[ -e $PIDFILE ] && ( kill `cat $PIDFILE` ; rm $PIDFILE ; )
udhcpc -i $1 -h `hostname` -p $PIDFILE 
rm $PIDFILE
)
case $2 in
CONNECTED)
dhcp_lease $1 &
;;
DISCONNECTED)
#kill `cat $PIDFILE`
wpa_cli -i $1  scan
;;
stop)
wpa_cli -i $1 disconnect
wpa_cli -i $1 terminate
;;
*)
echo "Use this script as a wpa_cli action script or $0 iface1 stop to leave iface1 ready for manual configuration"
;;
esac 

User avatar
JamesTheAwesomeDude
Posts: 99
Joined: Tue 29 Jan 2013, 17:17
Location: Classified

#159 Post by JamesTheAwesomeDude »

Okay, I can't figure out what to do:

Wi-Fi adapter, wlan0
Connecting to wireless router with WPA2 encryption
Using the carl9170usb driver
Static (custom) local IP
Custom DNS settings

What do I need to type? The stupid carl9170 driver is really crashy, and I hate having to make 40 clicks every 5 minutes to repair the internet, so I'm just gonna stick a script on the desktop labeled "Kick the Wi-Fi adapter" or something like that, that will auto-reconnect everything.
[url=http://www.murga-linux.com/puppy/viewtopic.php?t=84349][img]http://i.imgur.com/Zw6vryI.png[/img][color=#3B6EA3][b][size=200] Version 27. Dotpet. Click here.[/size]
(SFS available too!)[/b][/color][/url]

Ibidem
Posts: 549
Joined: Wed 26 May 2010, 03:31
Location: State of Jefferson

#160 Post by Ibidem »

JamesTheAwesomeDude wrote:Okay, I can't figure out what to do:

Wi-Fi adapter, wlan0
Connecting to wireless router with WPA2 encryption
Using the carl9170usb driver
Static (custom) local IP
Custom DNS settings

What do I need to type? The stupid carl9170 driver is really crashy, and I hate having to make 40 clicks every 5 minutes to repair the internet, so I'm just gonna stick a script on the desktop labeled "Kick the Wi-Fi adapter" or something like that, that will auto-reconnect everything.
Something like this (UNTESTED! CAUTION! YOU PROBABLY WILL NEED TO DEBUG AND CHANGE THIS!):

Code: Select all

#!/bin/sh
IF=wlan0
#You probably want to change these.
IP=10.0.0.100 
GW=0.0.0.0
#DNS: saved in /etc/resolv.conf, which should be static.

#modalias is a not-really-readable hw-specific ID that identifies one module.
read MOD </sys/class/net/${IF}/../../modalias
export MOD IF IP
start(){
wpa_supplicant -Dwext -B -c /etc/wpa.conf -i $IF
#I'm guessing the IP needs to be set after the interface is up.
#Really, this should be called via an action script, instead of dhcp
sleep 5
ifconfig $IF $IP
route add default gw $GW dev $IF
}
reload(){
wpa_cli -i $IF terminate
ifconfig $IF down
#Disable hardware encryption. Known to be desirable for AR9170 chips:
# http://linuxwireless.org/en/users/Drivers/carl9170
modprobe -r $MOD && modprobe $MOD nohwcrypt=1
}
reload && start 
This assumes that the WPA config is in /etc/wpa.conf (probably not true for you!)

Post Reply