How to configure wifi from the commandline

How to do things, solutions, recipes, tutorials
Message
Author
User avatar
Semme
Posts: 8399
Joined: Sun 07 Aug 2011, 20:07
Location: World_Hub

#166 Post by Semme »

Yeah, it's gonna be someone else. Seems I've misplaced my ndiswrapper using card and have to bail- sorry.

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

#167 Post by JamesTheAwesomeDude »

Ibidem wrote:
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!)
Hmm, couldn't manage to debug that ^, but I wrote this from scratch (many thanks to the Arch Linux Wiki):

Code: Select all

#!/bin/sh
killall wpa_supplicant
rfkill unblock 0
modprobe carl9170
rm /run/wpa_supplicant/wlan0
ip link set wlan0 up
wpa_supplicant -B -Dwext -i wlan0 -c /etc/wpa_supplicant.conf
ip addr add 192.168.2.64/24 dev wlan0
ip route add default via 192.168.2.1
Gets everything connected in <2 seconds, much faster then "manually" clicking through all the GUI options. It can also reconnect when carl9170 dies (I do not like carl9170 one bit. >:()

Before you can use the handy-dandy script I made, you have to do this:

Code: Select all

wpa_passphrase "Your_Wifi_SSID" "v3ry_g00d_p@$$phr@$3" >> /etc/wpa_supplicant.conf
[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]

der-schutzhund
Posts: 1045
Joined: Mon 26 Nov 2007, 22:07
Location: Blomberg / Germany

#168 Post by der-schutzhund »

I vainly trying to configure a wireless connection.
Went through the entire post and tried a lot but it does not work!
Using the Simple Network setup I can manually establish a connection but not automatically by script!
How should be a simple script?

Greetings

Wolfgang
Attachments
wlan-2.jpg
(25.71 KiB) Downloaded 2049 times
wlan-1.jpg
(32.57 KiB) Downloaded 2489 times

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

#169 Post by tempestuous »

der-schutzhund wrote:I vainly trying to configure a wireless connection.
Went through the entire post and tried a lot but it does not work!
It's not necessary to go through the entire post. The complete instructions are in the 11th post on the first page of this thread - "PART 2: WPA encryption."
http://www.murga-linux.com/puppy/viewto ... 336#159336
Summary:
- first check your wifi router to see if it uses WPA or WPA2 encryption.
If WPA, use Geany to open /etc/network-wizard/wireless/wpa_profiles/wpa_supplicant.conf
If WPA2, use Geany to open /etc/network-wizard/wireless/wpa_profiles/wpa_supplicant2.conf

Add your SSID ("3210 Phone WLAN SL") and Personal Security Key (0815A31F), and save.
Assuming WPA2, you can now run a script with this -

Code: Select all

ifconfig wlan0 up
rm /var/run/wpa_supplicant/*
wpa_supplicant -i wlan0 -D wext -c /etc/network-wizard/wireless/wpa_profiles/wpa_supplicant2.conf -B
sleep 15
rm -f /var/lib/dhcpcd/*.info
rm -f /var/run/*.pid
dhcpcd -t 30 -h puppypc -d wlan0

der-schutzhund
Posts: 1045
Joined: Mon 26 Nov 2007, 22:07
Location: Blomberg / Germany

#170 Post by der-schutzhund »

Hi tempestuous,

thanks for the information! With these lines, it works!!!

When I work with the file /etc/network-wizard/wireless/wpa_profiles/wpa_supplicant.conf I had to remaster it.
Otherwise I have to make entries manually every time.
How can I set up the wireless without a remaster?

Can I enter the ssid and the Personal Security Key in the script? If so how?

Greetings

Wolfgang

der-schutzhund
Posts: 1045
Joined: Mon 26 Nov 2007, 22:07
Location: Blomberg / Germany

#171 Post by der-schutzhund »

Hi,

to make everything in a script I'm writing a new file /etc/network-wizard/wireless/wpa_profiles/wpa_supplicant.conf.

This all works very well!

Greetings

Wolfgang

tannaroo
Posts: 23
Joined: Sun 17 Feb 2013, 05:33

#172 Post by tannaroo »

hi all,

can anyway point me in the right direction to write a script so that I can connect via GPRS modem. I've done it manually but would like an automatic script that connects automatically on startup?

cheers

Antzus
Posts: 5
Joined: Sun 14 Apr 2013, 14:28

Editing the wpa_supplicant file

#173 Post by Antzus »

Hi all. I've used a LOT of information (as well as PET files, etc) from these fora but I've only just now created an account, because I wanted to share something I just found out.

I'm using an old 701 4G Surf Eee PC with its onboard Atheros wireless card, and Puppeee operating system installed. I've been trying all manner of things to connect to the WEP network here at my mum's place, which is shared by a couple of siblings on wifi as well as a couple of ethernet cables. I kept getting stuck somewhere at "WPA Status: Associating" without ever getting to the next step of a DHCP handshake.

After losing my sanity for about 24 hours I stumbled across this giant wpa_supplicant file, which is something of a complete list of what is possible to include: http://www.lsi.upc.edu/lclsi/Manuales/w ... icant.conf
and in there I found the answer to my problem - to the relevant SSID section I added the line :

Code: Select all

auth_alg=SHARED
That one little line made a world of difference to the supplicant file, and to me not having to sit on the floor in the corner using a 1m ethernet cable. So for anyone in the same situation, don't go downloading drivers, blacklisting modules or anything else I've been wasting my mental health on, try that line in your wpa_supplicant file.

cthisbear
Posts: 4422
Joined: Sun 29 Jan 2006, 22:07
Location: Sydney Australia

#174 Post by cthisbear »

Antzus:

Thanks mate ....hope this helps others out....

Cheers....Chris.

redandwhitestripes
Posts: 179
Joined: Fri 02 Jan 2009, 06:49

#175 Post by redandwhitestripes »

I posted about my bizarre connection problems on the broadcom thread here:
http://www.murga-linux.com/puppy/viewto ... 767#698767

and it was suggested I post my pdiag readout. As it's hefty, which parts of it should I post.

I will also paste here a readout after I attempted to connect from the commandline though I doubt it helps, as it still couldn't see my SSID.

Code: Select all

# wpa_supplicant -i wlan0 -D wext -c /etc/network-wizard/wireless/wpa_profiles/wpa_supplicant2.conf -dd
Initializing interface ‘wlan0' conf ‘/etc/network-wizard/wireless/wpa_profiles/wpa_supplicant2.conf’ driver ‘wext’ ctrl_interface ‘N/A’ bridge ‘N/A’
Configuration file ‘/etc/network-wizard/wireless/wpa_profiles/wpa_supplicant2.conf’ -> ‘/etc/network-wizard/wireless/wpa_profiles/wpa_supplicant2.conf’
Reading configuration file ‘/etc/network-wizard/wireless/wpa_profiles/wpa_supplicant2.conf’
ctrl_interface='/var/run/wpa_supplicant’
ap_scan=1
update_config=1
Line: 5 - start of a new network block
ssid - hexdump_ascii(len=8):
     5a 79 58 45 4c 6e 65 77                           ZyXELnew        
scan_ssid=1 (0x1)
PSK (ASCII passphrase) - hexdump_ascii(len=10): [REMOVED]
proto: 0x2
key_mgmt: 0x2
pairwise: 0x18
group: 0x18
PSK (from passphrase) - hexdump(len=32): [REMOVED]
Priority group 0
   id=0 ssid='ZyXELnew’
SIOCGIWRANGE: WE(compiled)=22 WE(source)=19 enc_capa=0xf
  capabilities: key_mgmt 0xf enc 0xf flags 0x0
netlink: Operstate: linkmode=1, operstate=5
Own MAC address: 00:21:00:92:85:79
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_key: alg=0 key_idx=4 set_tx=0 seq_len=0 key_len=0
wpa_driver_wext_set_key: alg=0 key_idx=5 set_tx=0 seq_len=0 key_len=0
wpa_driver_wext_set_countermeasures
RSN: flushing PMKID list in the driver
Setting scan request: 0 sec 100000 usec
WPS: UUID based on MAC address - hexdump(len=16): 98 74 c7 1e 86 40 58 34 9a 19 c7 75 5b f7 d1 b5
EAPOL: SUPP_PAE entering state DISCONNECTED
EAPOL: Supplicant port status: Unauthorized
EAPOL: KEY_RX entering state NO_KEY_RECEIVE
EAPOL: SUPP_BE entering state INITIALIZE
EAP: EAP entering state DISABLED
EAPOL: Supplicant port status: Unauthorized
EAPOL: Supplicant port status: Unauthorized
Using existing control interface directory.
Added interface wlan0
RTM_NEWLINK: operstate=0 ifi_flags=0x11003 ([UP][LOWER_UP])
RTM_NEWLINK, IFLA_IFNAME: Interface ‘wlan0' added
Wireless event: cmd=0x8b06 len=8
RTM_NEWLINK: operstate=0 ifi_flags=0x11003 ([UP][LOWER_UP])
RTM_NEWLINK, IFLA_IFNAME: Interface ‘wlan0' added
Wireless event: cmd=0x8b1a len=40
State: DISCONNECTED -> SCANNING
Scan SSID - hexdump_ascii(len=8):
     5a 79 58 45 4c 6e 65 77                           ZyXELnew        
Starting AP scan for specific SSID(s)
Scan requested (ret=0) - scan timeout 5 seconds
RTM_NEWLINK: operstate=0 ifi_flags=0x11003 ([UP][LOWER_UP])
RTM_NEWLINK, IFLA_IFNAME: Interface ‘wlan0' added
Wireless event: cmd=0x8c02 len=29
WEXT: Custom wireless event: ‘Conn NoNetworks 03 00‘
EAPOL: disable timer tick
EAPOL: Supplicant port status: Unauthorized
Scan timeout - try to get results
ioctl[SIOCGIWSCAN]: Invalid argument
Failed to get scan results
Failed to get scan results - try scanning again
Setting scan request: 1 sec 0 usec
Starting AP scan for wildcard SSID
Scan requested (ret=0) - scan timeout 5 seconds
RTM_NEWLINK: operstate=0 ifi_flags=0x11003 ([UP][LOWER_UP])
RTM_NEWLINK, IFLA_IFNAME: Interface ‘wlan0' added
Wireless event: cmd=0x8b19 len=8
Received 0 bytes of scan results (0 BSSes)
BSS: Start scan result update 1
New scan results available
Selecting BSS from priority group 0
Try to find WPA-enabled AP
Try to find non-WPA AP
No suitable network found

User avatar
peebee
Posts: 4370
Joined: Sun 21 Sep 2008, 12:31
Location: Worcestershire, UK
Contact:

#176 Post by peebee »

redandwhitestripes wrote:I posted about my bizarre connection problems on the broadcom thread here:
http://www.murga-linux.com/puppy/viewto ... 767#698767

and it was suggested I post my pdiag readout. As it's hefty, which parts of it should I post.

I will also paste here a readout after I attempted to connect from the commandline though I doubt it helps, as it still couldn't see my SSID.
Hi there

The output from pdiag is a .tar.gz file that you then attach to your post.

I think the significant line above could be

Code: Select all

ioctl[SIOCGIWSCAN]: Invalid argument 
which may indicate that the correct firmware isn't present, but this would mean that it is the b43 driver that is being used.

Can you run the lsmod command - is b43 or wl shown as loaded?

There are 2 links to other (maybe more up to date) b43 firmware in the "Broadcom" thread just under BACKGROUND which you may wish to try loading.

Cheers
PeeBee
ImageLxPup = Puppy + LXDE
Main version used daily: LxPupSc; Assembler of UPups, ScPup & ScPup64, LxPup, LxPupSc & LxPupSc64

johnmichaelreed
Posts: 11
Joined: Thu 04 Jul 2013, 02:09

Easiest way to connect to public wifi via terminal?

#177 Post by johnmichaelreed »

Hey. Sorry to be jumping into this thread without reading the proceeding posts, but this is all a little confusing to me.

As part of learning Unix, I decided to try and switch over as much as possible to the no GUI linux terminal. In class I routinely write programs as text files and send them to the school server via scp and ssh to complete my homework, but that requires that I connect to the wifi. And I only know how to connect to wifi when there's a GUI and I can just click on "connect" and pick a wireless network. All this stuff about scripts and long, multi-step processes is confusing me, but I'd really like to switch over to being totally free of the GUI to get more of a feel for the unix/linux terminal environment.

Can someone explain to me in as simple terms as possible which default puppy Linux Slacko 5.5 program I have to run and what I have to type in to connect to a public (in the sense that I do not need a password to connect, I only need to type in my student ID into the school homepage before I can browse) Wifi network?

Cuz right now auto-connection only seems to work for the no GUI boot when there's an Ethernet cord plugged in before boot.

Appreciated.

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

Re: Easiest way to connect to public wifi via terminal?

#178 Post by Ibidem »

johnmichaelreed wrote:Hey. Sorry to be jumping into this thread without reading the proceeding posts, but this is all a little confusing to me.

As part of learning Unix, I decided to try and switch over as much as possible to the no GUI linux terminal. In class I routinely write programs as text files and send them to the school server via scp and ssh to complete my homework, but that requires that I connect to the wifi. And I only know how to connect to wifi when there's a GUI and I can just click on "connect" and pick a wireless network. All this stuff about scripts and long, multi-step processes is confusing me, but I'd really like to switch over to being totally free of the GUI to get more of a feel for the unix/linux terminal environment.

Can someone explain to me in as simple terms as possible which default puppy Linux Slacko 5.5 program I have to run and what I have to type in to connect to a public (in the sense that I do not need a password to connect, I only need to type in my student ID into the school homepage before I can browse) Wifi network?

Cuz right now auto-connection only seems to work for the no GUI boot when there's an Ethernet cord plugged in before boot.

Appreciated.
A script is nothing more than a set of commands, with a little bit of logic thrown on top.
It's exactly the same language and interpreter that you use in the terminal. If you want to learn Unix, you will need to learn shell scripting eventually.

There are two tools you can use, wpa_supplicant/wpa_cli and iwconfig.
iwconfig is more basic but easier to learn. It's a one-time command though, so connections are likely to die.
wpa_supplicant is a daemon (long-running process that provides a system service; often started by boot scripts), which you need to configure and script.

The bare bones (iwconfig) is:

Code: Select all

iwlist scanning #note the interface that has SSIDs reported
#I'll use wlan0 as the interface and SCHOOL as SSID/essid
#change as needed
iwconfig wlan0 essid SCHOOL
iwconfig wlan0 #check if you associated
dhcpcd -h `hostname` -d wlan0   #or udhcpc -h `hostname` -i wlan0
If you want to get it to autoconnect, my scripts here are probably the most basic guide you can find:
http://www.murga-linux.com/puppy/viewtopic.php?p=673363
(Look for a post by me that starts "FYI: Debian uses a trick with wpa_cli that lets you run the DHCP client at the right time, consistently. "; I can't get it to jump to the right post).
Yes, I have tested that method since then. It's what I'm using now.

For wpa_supplicant.conf, if you use wpa_supplicant...

Code: Select all

ctrl_interface=DIR=/var/run/wpa_supplicant
update_config=1
network={
        ssid="any"
        key_mgmt=NONE
}
And then start a browser; if you want CLI only, you may need to install one.
I suggest looking at:
-Lynx: for text mode
-Links2: for text and fast-but-ugly graphics (including in the "framebuffer" and under X)
-elinks: for probably the best straight text mode you can get (including javascript).

w3m should not be used without reading the manual first.

User avatar
James186282
Posts: 270
Joined: Tue 08 Sep 2009, 19:14
Location: Minnesota

A curious boot up problem

#179 Post by James186282 »

I wanted to give Precise a try and have a frugal installation that I boot with a CD. I've tried all 3 of the methods to get a connection to the router. I'm using the ndiswrapper with a wg311v3 driver. *Which has worked at one time.

Hovering my mouse over the wifi icon (In the Tray) it tell me
Active interfaces: none
If I
iwconfig
I get a nice "correct" display about wlan0 being connected to the ESSID that I wanted. So I gave ifconfig a try and
only info for lo
wlan0 and eth0 are not showing up at all.
I looked into a lot of .log files. The /var/log/messages may provide a clue.

on eth0: /var/log has some odd messages at the end
dhcpcd-run-hooks PREINIT runs a again NOCARRIER

It does the same routine for wlan0
then it eth0 suddenly get carrier aqcquired *Note no wired connection
it runs the run-hooks routine and Reason NOCARRIER and then tries waiting for eth and wlan0 to get a carrier. Wlan0 announces it has one
it runs the dhcpcd-run-hooks program reason CARRIER and its lost. Now it run the run-hooks routine reason NOCARRIER and it ends with wlan0
waiting for carrier.
The final line is auth.notice su: + none root:spot

ndiswrapper -i wg311v3.inf tells me its already installed *Which is correct
lspci | grep Marvell *looks ok it has the version etc.

So.... I typed in ifconfig wlan0 up *And it worked!? I suppose I could make a one line bash script saying ifconfig wlan0 up but its making me goofy not understanding why its not working after booting up?

I just rebooted again and did the ifconfig wlan0 up trick. It goes into a series of repeated wlan0 down then requesting ip for router5 I lost count but half a dozen times. Wow its like 2 or 3 minutes of this I get the IP: 10.0.0.36 Aquired (Splexed?)
While this goes on and on I checked out things with iwconfig and saw something I've never seen before. On the last line
Encryption Key:2344.1234.etc it ends with "Security mode :restricted"
After the message about obtaining an ip address everything seems to work. My head is spinning...

Any ideas? Or things to check out that I've missed?

The computer is nothing special. Its a Gateway with a 3Ghz Pent 4. There is 1 Gig of ram.

Thanks for any ideas.
Science is what we understand well enough to explain to a computer.
Art is everything else we do.
[i]Donald Knuth [/i]

gcmartin

#180 Post by gcmartin »

In the last couple days several members have provided help with steps to get an interface running (wlan and eth).

This is very good information and guidances. I have use the command line steps in the past as well.

Questions
  • Doesn't Puppy already have some terminal scripts that can be invoked to do what is shared, herein? Maybe even some scripts which allow parms which carry out the functions automatically?
  • Are any of the current GUIs also command line with parm utilities such that they will run standalone without X or as a GUI in X? Are there explanations, or documents, or threads which outline the actions of these GUIs when run from the console?
I do realize that, both, the Puppy distros and their versions, as well as the GUI utility versions, themselves, can impact the responses to these questions. But, the issues that are asked may be being addressed as they are basic and generic.

Thanks in advance for any information or pointers to such.

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

#181 Post by Ibidem »

gcmartin wrote:In the last couple days several members have provided help with steps to get an interface running (wlan and eth).

This is very good information and guidances. I have use the command line steps in the past as well.

Questions
  • Doesn't Puppy already have some terminal scripts that can be invoked to do what is shared, herein? Maybe even some scripts which allow parms which carry out the functions automatically?
  • Are any of the current GUIs also command line with parm utilities such that they will run standalone without X or as a GUI in X? Are there explanations, or documents, or threads which outline the actions of these GUIs when run from the console?
I do realize that, both, the Puppy distros and their versions, as well as the GUI utility versions, themselves, can impact the responses to these questions. But, the issues that are asked may be being addressed as they are basic and generic.

Thanks in advance for any information or pointers to such.
Most of the scripts are based on the information in this thread, and many are linked from this thread at some point.

linus.cl
Posts: 126
Joined: Wed 02 Apr 2014, 14:09
Location: Germany
Contact:

#182 Post by linus.cl »

@tempestous: Can you put your tutorials to the Puppy linux wiki?
->http://puppylinux.org/wikka/HomePage

User avatar
Semme
Posts: 8399
Joined: Sun 07 Aug 2011, 20:07
Location: World_Hub

#183 Post by Semme »

:idea: For anyone that might struggle aboard Precise retro with the rt5370sta driver (wext), GO TO THE CMDLINE!

Running a WPA2 passkey connection, my /etc/network-wizard/wireless/wpa_profiles/wpa_supplicant2.conf reads:

Code: Select all

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

network={
	ssid="SSID_FROM:[iwlist YOUR_INTERFACE scan]"
	scan_ssid=1
	psk="MY_CONNECTIONS_PASSWORD"
	proto=WPA2
	key_mgmt=WPA-PSK
	pairwise=CCMP TKIP
	group=CCMP TKIP
}
My connection script in /root/my-applications/bin/*.sh:

Code: Select all

#!/bin/sh
ifconfig INTERFACE up
sleep 2
wpa_supplicant -i INTERFACE -D wext -c /etc/network-wizard/wireless/wpa_profiles/wpa_supplicant2.conf -dd -B
sleep 5
rm -f /var/lib/dhcpcd/*.info
rm -f /var/run/*.pid
dhcpcd -I '' -t 30 -h puppypcxxxxx -d INTERFACE
I don't know whether it's pretty or not, but it flies.
>>> Living with the immediacy of death helps you sort out your priorities. It helps you live a life less trivial <<<

s243a
Posts: 2580
Joined: Tue 02 Sep 2014, 04:48
Contact:

#184 Post by s243a »

I'll read the first post later but I wanted to add that I have a thread related to this topic called: "Turn net-setup.sh into a function library" (see also wikipage)

darry19662018
Posts: 721
Joined: Sat 31 Mar 2018, 08:01
Location: Rakaia
Contact:

CLInet

#185 Post by darry19662018 »

This is a script from Pup'n'go for wireless I have used it successfully I share it now.
Attachments
CLInet-0.8.pet
(11.95 KiB) Downloaded 445 times
Puppy Linux Wiki: [url]http://wikka.puppylinux.com/HomePage[/url]

[url]https://freemedia.neocities.org/[/url]

Post Reply