Thursday, October 3, 2013

Connect to Wireless Network from Command Prompt or Terminal

Why?

If you're Windows o Mac OS X is not configured to connect automatically to your wireless network, it can be a bit tedious to use the GUI in either OS to connect to your WiFi. Here are two commands to connect to a a wife:

Windows:

The netsh command and its subcommands is a powerful way to interact with windows networking subsystem. Follow this http://technet.microsoft.com/en-us/library/cc755301(v=ws.10).aspx for more on this command. Here is how to connect to a WiFi:

The command:

netsh wlan connect name=your_wireless_network_profile_name ssid=your_wireless_network_ssid

If you are not sure about the network profile (normally it's the same as the ssid) you can use netsh command to list all profile:

netsh wlan show profiles

If you want to see the available networks then use:

netsh wlan show networks

Netsh is a great command and can do a lot more.

Mac OS X:

The networksetup command is a powerful command in the Mac OS X environment to deal with network setup. 

To connect to a wireless network for example:

networksetup -setairportnetwork hardware_port your_wireless_network_ssid your_password

A typical value for hardware_port (wireless) is en1 (ethernet interface # 1).

There is more to this command for sure.