Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
How to do wifi conveniently from CLI?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
Punchcutter
Guru
Guru


Joined: 11 Feb 2007
Posts: 336

PostPosted: Wed Feb 03, 2010 12:40 am    Post subject: How to do wifi conveniently from CLI? Reply with quote

Hi.... I've lately had very bad luck trying to find a convenient GUI tool to manage wifi connections (long story... closely related to KDE and its dumping of 3.5.x, but let's not go there....) I need to take a business trip very soon, and use wifi on the road. I'm quite sufficiently techie, however, and not afraid to use the command line to manage my wifi connections (using /etc/init.d/net.wlan0, ifconfig, wpa_supplicant command, etc). There are just a few things I don't know:

In a case where there may be multiple networks present, how can I ensure that the ESSID I want to use is the one chosen to attach to?

How can I easily check which ESSID I am connected to at any given time?

The tools I know about don't seem to offer this capability. Is there another tool that deals at the ESSID level? If not, this seems like an odd gap in functional coverage...

Thanks very much in advance for any help. Any and all tips on best practices for managing wifi from CLI are most appreciated!

EDIT:
Of course it's only as soon as you've posted something like this that you think to google and then find some useful info. Googling reminded me of "iwconfig", which I had long forgotten about. I see that you can "set" the essid with this. But if I can get /etc/init.d/net.wlan0 to handle underlying details for me, including interfacing with wpa_supplicant, how would iwconfig fit into this scheme? Or would I need to specify ESSIDs in /etc/conf.d/net? (don't know the syntax for that - if there's a man page for this file, I can't find it).

Too many questions.... and much info on the web is specific to non-Gentoo distros, so I suppose asking here will have been worthwhile in the long run.... thanks again.
Back to top
View user's profile Send private message
mikegpitt
Advocate
Advocate


Joined: 22 May 2004
Posts: 3224

PostPosted: Wed Feb 03, 2010 1:07 am    Post subject: Reply with quote

A well set up /etc/wpa_supplicant/wpa_supplicant.conf should handle most things for your automatically. Others may recommend using wicd, but I don't have any experience with wicd. I find the easiest way to configure wpa_supplicant is to use the wpa_gui tool.

As for controlling things through the command line, you can use iwconfig as you noted above. You can also use wpa_cli. The wpa_cli documentation is severely lacking, but I've been able to figure out the following:

Code:
# perform a scan and list the results
wpa_cli SCAN
wpa_cli SCAN_RESULTS

# disconnect from an ap
wpa_cli DISCONNECT

# connect to a new ap
wpa_cli SELECT_NETWORK myessid
wpa_cli REASSOCIATE

# get the status of your connection
wpa_cli STATUS

[/code]
Back to top
View user's profile Send private message
DONAHUE
Watchman
Watchman


Joined: 09 Dec 2006
Posts: 7635
Location: Goose Creek SC

PostPosted: Wed Feb 03, 2010 1:20 am    Post subject: Reply with quote

How can I easily check which ESSID I am connected to at any given time? -- iwconfig
what's available -- iwlist scan
In a case where there may be multiple networks present, how can I ensure that the ESSID I want to use is the one chosen to attach to? set ssid= in wpa-supplicant.conf
you don't have a wpa supplicant administration gui as a result of emerge wpa-supplicant?
Back to top
View user's profile Send private message
poly_poly-man
Advocate
Advocate


Joined: 06 Dec 2006
Posts: 2477
Location: RIT, NY, US

PostPosted: Wed Feb 03, 2010 3:36 am    Post subject: Reply with quote

if you want a gui back (or not - it's still, in the opinions of many networkmanager converts, a useful tool), use wicd.
_________________
iVBORw0KGgoAAAANSUhEUgAAA

avatar: new version of logo - see topic 838248. Potentially still a WiP.
Back to top
View user's profile Send private message
Punchcutter
Guru
Guru


Joined: 11 Feb 2007
Posts: 336

PostPosted: Wed Feb 03, 2010 8:21 am    Post subject: Reply with quote

Thanks for all the great suggestions. I had no idea that wpa_gui existed. However I'm having some trouble. The gui will show the successful connection if one was made elsewhere, but I can't get it to show anything on a scan, or to make a connection itself. This is even when iwlist wlan0 scan will give scan output. I tried the wpa_cli commands above as well, but not with much success. It often just comes back and tells me it can't connect to the supplicant (sorry don't have exact messages now! :oops: )

One thing I've noticed is that the interface seems to go up and down by itself. I had terrible trouble in the past when using my wired ethernet with wlan0 coming up and trying to make connections, stealing my DNS configuration, etc. I thought it was networkmanager causing the trouble, so I unmerged it, but it didn't stop. wlan0 was like some kind of demonic toy in a slasher movie... I had to keep crushing it down until it would finally leave me alone and let me use the wired port. That was a while ago, but recently.

Now, as I say, I've got this weirdness where I can bring it up with ifconfig wlan0 up (or iwconfig wlan0 up?), and then try to scan and connect, but it just drops out from under me. I have no reason to think there's anything wrong with my kernel/drivers. I have one network fully listed in wpa_supplicant.conf (at my workplace), and this one will connect up and stay up with no problem.

I realize this is all kinda fragmented and hard to make sense of. For me too. I'm hoping it'll ring bells for someone. If not, I'll just have to keep trying over and over every trick in my book until I manage to make connections. Leaving on my trip tomorrow....

(p.s. I have tried wicd, as a matter of fact, and it just didn't work for me. Very unstable and more trouble than it was worth. I'll keep it in mind to try again in the future).
Back to top
View user's profile Send private message
depontius
Advocate
Advocate


Joined: 05 May 2004
Posts: 3450

PostPosted: Wed Feb 03, 2010 1:48 pm    Post subject: Reply with quote

The button on the right on wpa_gui is "scan". Press that and it'll pop up a new panel that shows you the networks it can find. You can then pick one of those, click the "add" button and that network will get added to the main wpa_gui network pulldown. (At this point you can close the scan panel, if you want.) Meanwhile the main wpa_gui is cycling through its possible connections, and will eventually get to the one you added. My wireless isn't active now, so I can't give you the whole works exactly, but from somewhere in these panels you can also configure the newly added network, in case you have a key or some such.

I normally keep networks set up in wpa_supplicant.conf for home, work, and Hilton hotels. (My wife is quite fond of Hampton Inns, when we travel.) Anything else, like an airport or other open wifi, I add ad-hoc through the gui.
_________________
.sigs waste space and bandwidth
Back to top
View user's profile Send private message
mikegpitt
Advocate
Advocate


Joined: 22 May 2004
Posts: 3224

PostPosted: Wed Feb 03, 2010 2:18 pm    Post subject: Reply with quote

Punchcutter wrote:
It often just comes back and tells me it can't connect to the supplicant (sorry don't have exact messages now! :oops: )
Is wpa_supplicant started? You will need the following in your /etc/conf.d/net:
Code:
modules=( "wpa_supplicant" )
wpa_supplicant_wlan0="-Dwext"
...and then run the follow to start wpa_supplicant:
Code:
/etc/init.d/net.wlan0 restart
Back to top
View user's profile Send private message
doctork
Guru
Guru


Joined: 25 Apr 2004
Posts: 370
Location: Cleveland, OH

PostPosted: Wed Feb 03, 2010 5:37 pm    Post subject: Reply with quote

Punchcutter wrote:
Thanks for all the great suggestions. I had no idea that wpa_gui existed. However I'm having some trouble. The gui will show the successful connection if one was made elsewhere, but I can't get it to show anything on a scan, or to make a connection itself. This is even when iwlist wlan0 scan will give scan output. I tried the wpa_cli commands above as well, but not with much success. It often just comes back and tells me it can't connect
o the supplicant (sorry don't have exact messages now! :oops: )
.

wpa_cli and wpa_gui need to run as root or by a user in a group specified in wpa_supplicant.conf by a statement like:
Code:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=wheel

As far as wireless stealing your wired connections, you can prevent that with a statement like this in /etc/conf.d/net:
Code:
dhcp_wlan0="nodns nontp nogateway nodomain"

--
doc
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum