Sometimes I boot into recovery kernel with CLI and networking for troubleshooting my laptop. So is there a way to connect to a wireless router or AP over command line? If it is possible what are the commands for the following:
- To list available networks.
- To connect to a network with: SSID, WPA2 key and DHCP mode.
- A command to connect with: SSID, ad-hoc mode, ip-address, netmask, gateway.
You will need the wpasupplicant package in order to connect to a network secured with wpa or wpa2.
Listed by order :
1 :
sudo iwlist scan
2 :
sudo iwconfig <interface> essid "my network"
iwpriv <interface> set AuthMode=<WPA2PSK or WPA2AES>
iwpriv <interface> set <WPA2PSK or WPA2AES>='WPA PASSPHRASE'
3 :
sudo iwconfig <interface> essid "my network"
ifconfig <interface> inet <ip> netmask <mask>
then set a route to your gatewayroute add <destination> gw <gateway ip>
nm-tool
orsudo iwlist scan
will show you all available wireless networks.There's a
cnetworkmanager
package that ought to let you control Network Manager from the command line. I've never used it myself.I think iwlist and iwconfig does this. Here is the forum that talks about this.