Setup a Wireless Internet Connection on Linux
Edited by Anabasis, Eng
Linux is an open source UNIX based operating system that is highly configurable and offers an alternative to the more familiar OS X and Windows operating systems. Several reasons for choosing Linux include greater modularity, heightened security, and endless customization. This article will show you how to setup a simple DHCP wireless internet connection on Linux. It's important to note that Linux currently does not support all network devices. It is assumed that systemd is installed on the system. It is also assumed that the user knows how to navigate the Linux file system, edit text files, and copy/move files. This article also only represents one method for setting up wireless networks on Linux, using the following programs:
Setting Up Wireless Networks on Linux
These programs are generally included in the repositories of most Linux package managers such as apt. Refer to your distribution's package manager for installation if these programs aren't already installed. Common package managers include yum, apt, rpm and pacman. These programs can also be compiled from their source
The following commands must be run in a shell with root privileges
Here's how to install these programs using the package manager apt:
apt-get install netctl wpa_supplicant iw ip
Here's how to install them using pacman:
pacman -S netctl wpa_supplicant iw ip
- 1Listing available wireless devices with iw
- In your shell, type the following command iw dev
- Here is an example output:
- The iw dev command lists all devices that can be used in wireless connections. In the example, you can see that "wlp6s0" is the name of my wireless interface. You can also view all network devices in the directory /sys/class/net. You'll want to either remember or copy the name of the interface as you'll need it later.
- 2Setting up netctl
- netctl is the program that is responsible for setting up the connection, using the service systemd-networkd, and the program wpa_supplicant.
- netctl uses profiles to specify which network to connect to. Example configuration files are found in the directory /etc/netctl/examples.
- Here is an example configuration file for an open wireless network:
- Here is an example configuration file for a WPA secured network:
- Copy one of the example configuration files from /etc/netctl/examples to /etc/netctl. The file wireless-open should be used for unsecured wireless networks, and wireless-wpa for a network secured by WPA. There are numerous other example configuration files for other network types, so it's up to you to choose the correct one. For example, if the wireless network you want to connect to is secured by WEP and not WPA, you would not use the wireless-wpa configuration file.
- 3Use iw to find the name (SSID) of the network you want to connect to.
- Enter the following command in your shell (with root privileges) to see all available wireless networks: iw dev wlp6s0 scan | grep SSID Be sure to substitute "wlp6s0" for the network device on your computer, and remember/copy the SSID of the network you want to connect to.
- 4Populate the netctl profile
- You've already copied an example profile to /etc/netctl, but it only contains example information. You'll need to add the SSID, and passphrase if the network is secured.
- Open the example profile with your favorite text editor, replace the SSID "MyNetwork" with the SSID (name) of the network you want to connect to, and if the network is secured, enter the passphrase in the section of the file labeled "passphrase." Here's another of an example file for reference:
- Write the changes to the file
- 5Starting the netctl profile and connecting to the internet
- Netctl profiles are started with the following syntax: netctl start wireless-open where "wireless-open" is the name of the profile. Netctl will then attempt to automatically establish a connection based on the information in the profile.
This article only serves as a glancing introduction to the programs that were used to configure a wireless internet connection. To find out more about how they work, you can use the man program to view the manual for each program for more detailed information, such as man netctl or man iw.
If you have problems with any of the steps in this article, please ask a question for more help, or post in the comments section below.
Categories : Networking
Recent edits by: Anabasis