Tuesday, August 5, 2014

All about wifi

Most of the information presented here are taken from and are no richer than: https://wiki.archlinux.org/index.php/Wireless_network_configuration
But then again, it is a well known fact that setting up/reconfiguring the wifi on your laptop may be one of the most challenging tasks you had to go through at some point or the other in your life. At least I had to. For the first time when you get it working, you ask yourself, "How exactly did it work?" But it's the same as asking "How do magnets work?" and the answer always is "Magic".

So, when you are in the illusion that you have isolated the minimum number of steps to get it working again, you do not bother making them generic or don't care whether they work on other computers or wlan cards. You just stop asking questions, write the steps down and upload it to a place like a blog or something similarly eternal, hoping that you won't have to go through the same nightmare all over again. Until you buy a new laptop.

Anyways, the moral here is: life is too short to rediscover the steps to get your wifi working again.


Vague Theory:

Notation: We are using Arch Linux. The wlan card is: wlp6s0, the profile you want to connect to is: profile.

The program "netctl-auto" automates the connecting process.
"wifi-menu" creates the profile and keeps it in /etc/netctl.
"netctl-auto start/enable profile" attaches the profile to netctl and finally, 
"netctl-auto start/enable netctl-auto@wlp6s0.service" forces wlp6s0 to connect to the internet using the profile. 

This eases up several jobs: 


Setting up wifi for the first time:  
wifi-menu to create a profile,  
dhcpcd wlp6s0 to get ip through dhcp,  
systemctl enable dhcpcd.service to make it work over reboots.  

systemctl start netctl-auto@wlp6s0 to let netctl-auto handle the automatic connection,

systemctl enable netctl-auto@wlp6s0 to make it work over reboots. netctl-auto enable profile to make the profile work over reboots. 

Deleting a profile, while it is already enabled: 

The first step is to tell netctl-auto to stop using the profile. 

netctl-auto disable profile  
should do that. But unfortunately, it still uses the profile somehow. You can verify it by issuing "systemctl restart netctl-auto@wlp6s0" and see that it is again connecting to the same profile. The solution is to delete the profile. 

rm /etc/netctl/profile  
netctl-auto disable profile
systemctl restart netctl-auto@wlp6s0 
and "ifconfig" to verify that the wlp6s0 is free. 

Note that: there is no such method to stop the profile using a single netctl-auto command. (Or, is there?)

Setting up a new profile:

To set up the profile, issue  
wifi-menu

If you get error (maybe through journalctl -xn) that "the interface is already up", it means that the profile still exists somehow. Follow the previous steps of "Deleting a profile while it is already enabled". 

After wifi-menu finishes creating the profile, if "systemctl enable/start netctl-auto@wlp6s0" is already issued, you should be able to connect. Otherwise, issue
systemctl start netctl-auto@wlp6s0 
systemctl enable netctl-auto@wlp6s0 

Optionally, use 
netctl-auto enable profile
to make it an automatic profile. 

Switching to a new profile: 

Use wifi-menu to create a new profile and use  
netctl-auto switch-to new_profile.

No comments: