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:

Was this helpful? Yes | No| I need help
  • netctl
  • wpa_supplicant
  • systemd
  • iw
  • ip

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

Was this helpful? Yes | No| I need help

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



  1. 1
    Listing available wireless devices with iw
    Advertisement
     
    1. In your shell, type the following command iw dev
    2. Here is an example output:
    3. 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.
    Was this step helpful? Yes | No| I need help
  2. 2
    Setting up netctl
    Advertisement
     
    1. netctl is the program that is responsible for setting up the connection, using the service systemd-networkd, and the program wpa_supplicant.
    2. netctl uses profiles to specify which network to connect to. Example configuration files are found in the directory /etc/netctl/examples.
    3. Here is an example configuration file for an open wireless network:
    4. Here is an example configuration file for a WPA secured network:
    5. 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.
    Was this step helpful? Yes | No| I need help
  3. 3
    Use iw to find the name (SSID) of the network you want to connect to.  
    1. 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.
    Was this step helpful? Yes | No| I need help
  4. 4
    Populate the netctl profile  
    1. 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.
    2. 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:
    3. Write the changes to the file
    Was this step helpful? Yes | No| I need help
  5. 5
    Starting the netctl profile and connecting to the internet  
    1. 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.
    Was this step helpful? Yes | No| I need help

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.

Was this helpful? Yes | No| I need help

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.

Comments

VisiHow welcomes all comments. If you do not want to be anonymous, register or log in. It is free.

User Reviews

There is no user reviews.

Article Info

Categories : Networking

Recent edits by: Anabasis

Share this Article:

Thanks to all authors for creating a page that has been read 52 times.

Did this article help you?
 
x

Thank Our Volunteer Authors.

Would you like to give back to the community by fixing a spelling mistake? Yes | No