Enable Wi-Fi on Linux. How to enable wifi on a laptop? Creating an access point

💖 Do you like it? Share the link with your friends

There are certain problems with support for Wi-Fi adapters in Ubuntu. It’s good if you can choose in advance compatible model when purchasing, but more often you have to use the equipment that you have. In this case, you will have to install the adapter yourself. Today we will look at just such a case.

Looking ahead, let's say that there is nothing complicated about connecting unsupported Wi-Fi adapters. Despite the fact that a number of actions we perform can be performed using a graphical interface, we will work exclusively in the console, which will allow us to use the recommendations in this article for both desktop and server versions of Ubuntu.

For example, consider connecting an inexpensive USB adapter in Ubuntu 12.04 LTS TP-Link TL-WN725N.

Let's go to the home directory and download the repository archive, having previously elevated the rights to superuser:

Sudo-s
cd ~
wget "https://github.com/lwfinger/rtl8188eu/archive/master.zip"

Let's unpack the archive (if necessary, install unzip).

Unzip master.zip

As you can see from the command output, the contents of the archive were unpacked into the directory rtl8188eu-master, go to it and build the module:

Cd rtl8188eu-master
make

After building the module, it should appear in the directory file 8188eu.ko, this is the required kernel module. Now install it with the command:

Make install

All that remains is to enable our module by running the command:

Modprobe 8188eu

or simply disconnect and reconnect the adapter. On a desktop system, you will immediately see a message about the ability to connect to a wireless network.

Or run the command in the console:

Ifconfig

In the output you will see the wireless interface appear wlan0.

As you can see, there is nothing complicated. However, it should be remembered that the module is assembled and installed under current version kernel, and when updating it, it will be necessary to build and install the module again. If this is not possible, then you should hold Shift When loading, select and load the kernel version for which the module is built.

This guide explains how to connect your computer to the network using configuration files and console utilities. The main goal is to talk about in various ways connecting to the Internet without using a GUI (graphical interface). The manual does not cover topics such as setting up network filters or, for example, your own points Wi-Fi access. It is assumed that there is a certain method of connecting to the Internet provided by the provider, to use which you must follow the steps below.

The guide provides examples of editing configuration files using text editors"nano" and "gedit". Please note that the first editor is launched in the terminal and can be used as if starting Ubuntu with graphical interface, and without it, and “gedit” can only be used when the graphical environment is enabled.

System requirements

Any system installation option is suitable to reproduce the actions described in the manual. A graphical user interface is not required. All actions must be performed in the console. It is understood that commands starting with the $ symbol must be executed as a user, and those starting with # must be executed as a superuser (root).

Before you begin, make sure that:

    Various network filters (for example, iptables), and their configuration utilities (for example, Firestarter) are disabled/correctly configured and do not interfere with the operation of the network.

    You have all the necessary parameters for connecting on your network (for example, IP address, subnet mask and default gateway for a connection using a static IP).

    Network devices that filter by MAC address are correctly configured and “know” your network interface.

    The driver of your network device is installed correctly, the cable (for a wired connection) is working properly and connected.

For settings, you will definitely need the name of your network adapter. You can find it out from the command output:

$ sudo lshw -C network

It allows you to view connected network devices.

Example command output:

Ubuntu@ubuntu:~$ sudo lshw -C network *-network description: Ethernet interface # Device type product: L2 100 Mbit Ethernet Adapter # Adapter name vendor: Attansic Technology Corp. # Device manufacturer physical id: 0 bus info: pci@0000:03:00.0 logical name: eth0 # Network interface name version: a0 serial: 00:00:00:00:00:00 # Physical address of the device (mac address) size: 100MB/s capacity: 100MB/s width: 64 bits clock: 33MHz capabilities: pm msi pciexpress vpd bus_master cap_list ethernet physical tp 10bt 10bt-fd 100bt 100bt-fd autonegotiation configuration: autonegotiation=on broadcast=yes driver=atl2 # Used driver driverversion=2.2.3 # Driver version duplex=full firmware=L2 ip=192.168.0.5 latency=0 link=yes # Availability of link module=atl2 multicast=yes port=twisted pair speed=100MB/s # Current connection speed.

Pay attention to the line:

Logical name: eth0

eth0 is the desired name of the network interface.

The name eth0 will be further used to configure this particular network card. Where eth indicates that the Ethernet interface is used, and 0 is the device number. If you have several network devices installed, then, accordingly, they will be given names: eth0, eth1, eth2, etc.

After the implementation of SystemD (since Ubuntu 15.04), network interfaces may have other names (not ethX). This was done so that the names of network devices do not change when new adapters are connected to the machine (in Lately, some USB modems act as a network adapter). As a result, eth0 can be called for example enp0s4 or eno1, or even enx78e7d1ea46da. This is the name of the network adapter that should be used in setting up the network.

More details about the name network interfaces You can read it in SystemD (English).

This renaming can be disabled by adding /etc/default/grub, to a string with a variable GRUB_CMDLINE_LINUX_DEFAULT line net.ifnames=0. After this you need to do sudo update-grub

Setting up a wired network

Setting IP address, default gateway, subnet mask

/etc/network/interfaces, for example like this:

And add to it:
For static IP:

Iface eth0 inet static address 192.168.0.1 netmask 255.255.255.0 gateway 192.168.0.254 dns-nameservers 192.168.0.254 8.8.8.8 auto eth0

    Iface eth0 inet static - indicates that the interface (iface eth0) is in the IPv4 (inet) address range with a static ip (static);

    Address 192.168.0.1 - indicates that the IP address (address) of our network card is 192.168.0.1;

    Netmask 255.255.255.0 - indicates that our subnet mask (netmask) is 255.255.255.0;

    Gateway 192.168.0.254 - default gateway address 192.168.0.254;

    Dns-nameservers 192.168.0.254 8.8.8.8 - addresses DNS servers(we'll talk about the bottom later)

    Auto eth0 - indicates to the system that the eth0 interface should be enabled automatically when the system boots with the above parameters.

eth0- the name of your interface being connected. The list of interfaces can be viewed by typing:

$ip addr

As a result, the file /etc/network/interfaces should look something like this:
(for one wired connection with static IP)

# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # My wired network. iface eth0 inet static address 192.168.0.1 netmask 255.255.255.0 gateway 192.168.0.254 dns-nameservers 192.168.0.254 8.8.8.8 auto eth0

Save the file and close the editor. In this example (nano editor) - press Ctrl + X, then Y, make sure the “Filename to write” is /etc/network/interfaces and press Enter.

More details about file syntax /etc/network/interfaces can be read in the documentation.

Example configuration for dynamic IP:

Iface eth0 inet dhcp auto eth0

Temporarily setting the IP address and subnet mask

If you need to set test settings, do:

$ sudo ip addr add 192.168.0.1/24 dev eth0

Where 192.168.0.1 is our IP address, /24 is the number of bits in the prefix part of the address (corresponding to the subnet mask 255.255.255.0).
eth0- plug-in network interface.

These settings will disappear after a system reboot and will not affect the file /etc/network/interfaces

DNS Settings

The resolvconf utility, which works in tandem with a small DNS caching server dnsmasq, is responsible for the DNS configuration. resolvconf allows you to do DNS settings based on data from different subsystems.
One of the consequences of this useful innovation (the transition to this scheme occurred in Ubuntu starting with version 12.04) is that now the /etc/resolv.conf file is generated automatically, and not individually by each program that wants to change it (sometimes overwriting changes made earlier ). Automatic generation of /etc/resolv.conf means that manual changes made to it will be lost.
The automatically generated /etc/resolv.conf contains a link to the DNS server on the local interface (127.0.1.1), and there (on port 53) sits the dnsmasq service, which is responsible for resolving symbolic names into IP addresses. It should be noted that this port (53) is open in LISTEN mode, but since Since this is a local interface, this port is not accessible from the external network.
DNS information for static interfaces must now be entered in /etc/network/interfaces in the dns-nameservers, dns-search and dns-domain parameters (which correspond to the nameserver, search and domain parameters in /etc/resolv.conf)

Please note that in /etc/resolv.conf, when recording several servers, several nameserver keys are used, and in /etc/network/interfaces all DNS server addresses were written in one line after the dns-nameservers key, separated by spaces.

As a result, the description of the static interface in /etc/network/interfaces should look something like this:

Iface eth0 inet static address 192.168.0.1 netmask 255.255.255.0 gateway 192.168.0.254 dns-nameservers 8.8.8.8 192.168.0.254 auto eth0

Ubuntu up to version 12.04

In older ubuntu versions when there is a need to indicate static addresses DNS servers (if they are not provided automatically) run:

$ sudo gedit /etc/resolv.conf

and enter the DNS server addresses there (separate records for each server):

Nameserver 192.168.0.100 nameserver 192.168.0.200

Where 192.168.0.100 and 192.168.0.200 are the DNS server addresses. If you need to add more addresses, each address must start on a new line and with the phrase nameserver

Setting up ppp connections

The daemon is responsible for creating point-to-point connections in Ubuntu. pppd, more detailed information about which is available in the documentation. Within this manual examples of creating will be considered PPPoE connections via a DSL modem, PPTP connections (VPN connections) and DIAL-UP connections via a regular modem.

PPPoE connection

IN standard installation Ubuntu includes a utility for setting up PPPoE connections – pppoeconf, to launch it, type:

$ sudo pppoeconf

A “pseudographic” window will appear in the terminal. The utility will search for network devices and display them on the screen, then it will search for a modem on these devices. If at this stage pppoeconf gives a negative result, check the correct connection and power supply of the modem. The next step is choosing “popular options” - in most cases you should agree. Next, the utility will ask for your login and then a password. Now - choosing a method for specifying DNS servers. Again, in most cases you should agree to receive DNS server addresses automatically. Next, you will be asked to limit the MSS size to 1452 bytes - as a rule, you should agree. The next question is whether to establish a connection automatically when the computer boots. The last question from the utility is whether to establish a connection now. pppoeconf by default creates the name dsl-provider for the connection. You can manage the connection using the commands:

$ sudo pon dsl-provider # To connect or $ sudo poff dsl-provider # To disconnect

If in your case the options provided by the utility pppoeconf is not enough - consult the pppd or pppoeconf documentation.

Note: when setting up a connection using pppoeconf Some settings are written to /etc/network/interfaces, as a result of which Network Manager can no longer manage the network. Exit: either use only NM, or only console + configs. You can return control of Network Manager as follows. Bring /etc/network/interfaces to the following form (it is not necessary to delete the excess, just comment it out):

# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback

Restart the network:

Reboot or restart Network Manager:

$ sudo /etc/init.d/NetworkManager restart

PPTP connection

To make a VPN connection using pppd you will need to install the package pptp-linux, which can be found at installation disk Ubuntu. Next, create (as root) in the folder /etc/ppp/peers file with the name of your provider and edit it, for example like this:

$ sudo nano /etc/ppp/peers/my-provider

And add connection options there, for example:

Persist # If the connection is broken, reconnect again. maxfail 0 # Maximum number unsuccessful attempts connections. 0 - infinite. mtu 1476 # Value MTU name (login) # Your login. #nodefaultroute # Do not be the default gateway defaultroute # Be the default gateway replacedefaultroute # Replace the default gateway if it was remotename (vpn) # Name remote server(for us) can be anything. pty "pptp (server_address) --nolaunchpppd" # Command to launch pptp. # Server address - can be either an IP address or domain name, for example vpn.foo.bar

(login) (vpn) (password)

After the system reboots, you will be able to manage the connection using the commands:

The process of setting up a VPN connection can be greatly simplified by a script assistant.

Setting up DIAL-UP connection

To configure a modem connection, you can use the built-in configurator pppd - pppconfig or special utility wvdial .

Using pppconfig

Setup process using pppconfig looks a lot like a utility pppoeconfig, You will be asked one by one questions about the connection parameters, and will be asked to enter your phone number, login and password, as well as the connection name. You should run pppconfig with superuser rights. For example like this:

$sudo pppconfig

You can manage the connection like this:

$ sudo pon my-provider # To connect or $ sudo poff my-provider # To disconnect

Where my-provider is the name you assigned to the connection during setup.

Using wvdial

In some cases (for example, when connecting using mobile phone), more convenient to use wvdial. To do this, you need to install it first. For example like this:

$ sudo apt-get install wvdial

Included in the package wvdial includes an automatic configuration utility - wvdialconf .

$sudo wvdialconf

The output will be something like this:

Ubuntu@ubuntu:~$ sudo wvdialconf password for ubuntu: Editing `/etc/wvdial.conf". Scanning your serial ports for a modem. Modem Port Scan<*1>: S0 S1 S2 S3 WvModem<*1>: Cannot get information for serial port. ttyACM0<*1>: ATQ0 V1 E1 -- ​​OK ttyACM0<*1>: ATQ0 V1 E1 Z -- OK ttyACM0<*1>: ATQ0 V1 E1 S0=0 -- OK ttyACM0<*1>: ATQ0 V1 E1 S0=0 &C1 -- OK ttyACM0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 -- OK ttyACM0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK ttyACM0<*1>: Modem Identifier: ATI -- Manufacturer: QUALCOMM INCORPORATED ttyACM0<*1>: Speed ​​4800: AT -- OK ttyACM0<*1>: Speed ​​9600: AT -- OK ttyACM0<*1>: Speed ​​19200: AT -- OK ttyACM0<*1>: Speed ​​38400: AT -- OK ttyACM0<*1>: Speed ​​57600: AT -- OK ttyACM0<*1>: Speed ​​115200: AT -- OK ttyACM0<*1>: Speed ​​230400: AT -- OK ttyACM0<*1>: Speed ​​460800: AT -- OK ttyACM0<*1>: Max speed is 460800; that should be safe. ttyACM0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK Found an USB modem on /dev/ttyACM0. Modem configuration written to /etc/wvdial.conf. ttyACM0 : Speed ​​460800; init "ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0"

Now all that remains is to edit the file /etc/wvdial.conf and add your phone number, login and password to it.

$ sudo nano /etc/wvdial.conf

Init1 = ATZ Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 Modem Type = USB Modem ISDN = 0 Idle Seconds = 0 New PPPD = yes Dial Attempts = 0 Phone = #777 Modem = /dev/ttyACM0 Username = mobile Password = internet Baud = 460800 Idle Seconds = 0 # The time the connection is idle, # after which it will need to be disconnected. Value 0 - never. Dial Attempts = 0 # Number of dial attempts. 0 - infinite. Dial Command = ATDP # Dial command (P - pulse, T - tone). Makes sense for pulse dialing on older PBXs.

The /etc/wvdial.conf file is divided into sections, the separators of which are the section names themselves, preceded by the word Dialer, in square brackets. If you execute the command without parameters, then the settings listed in the Defaults section will be used. Otherwise, the commands specified in the additional sections will be additionally executed.

Now that everything is configured, the connection can be established by typing:

$sudo wvdial

If you need to start wvdial with pulse dialing, you can do this with the command

$ sudo wvdial pulse

You can terminate the connection by interrupting the execution of the wvdial command, i.e. in the same terminal you need to press Ctrl + C.

Automatic connection

Edit the configuration file /etc/network/interfaces, for example like this:

$ sudo nano /etc/network/interfaces

And add to it:
For pppoe, pptp, and modem connection without using wvdial :

Iface ppp0 inet ppp provider my-provider auto ppp0

Where my-provider- the name of your connection.
Using wvdial:

Iface ppp0 inet wvdial provider wvdial auto ppp0

Now when you restart network services, the connection will be automatically established.

Manual routing setup

If you do not receive the default gateway address from the server you are connecting to, or for any other reason you need to specify routes manually, you can create your own script in /etc/ppp/ip-up.d/, or according to the recommendation of the official documentation, create /etc/ppp/ip-up.local for example like this:

$ sudo nano /etc/ppp/ip-up.local

$ sudo nano /etc/ppp/ip-up.d/routing

with the following code:

#! /bin/sh # route del default route add default ppp0 # Ppp connection name. # here are the necessary routes, for example: route add -net 192.168.0.0 netmask 255.255.255.0 gw 192.168.0.1 dev eth0

$ sudo chmod ug+x /etc/ppp/ip-up.local

$ sudo chmod ug+x /etc/ppp/ip-up.d/routing

Now routes will be automatically connected when a ppp connection is established.

Setting MTU and TTL

MTU (Maximum Transfer Unit) - the parameter determines the value of the maximum transfer unit. This is the maximum number of octets (bytes) that the interface is capable of supporting in a single transmit/receive operation. For Ethernet, this default value is 1500 (the maximum Ethernet packet size).

TTL (Time To Live) - lifetime of an IP packet in seconds. Needed to avoid overloading the network with packets. Typically, each router through which the packet passed reduces the TTL by one. If TTL=0, the packet is removed from the system. Initially TTL=128 (for Windows) and TTL=64 (for Ubuntu). For DNS records TTL determines how long data is up to date when caching queries.

To change the MTU value, edit the configuration file /etc/network/interfaces, for example like this:

Auto eth0 iface eth0 inet static address 192.168.1.5 netmask 255.255.255.0 mtu 600

To change the TTL value, type:

$ sudo su then # echo "128" > /proc/sys/net/ipv4/ip_default_ttl

The TTL value changes only with administrator rights, to log out of the administrator account, enter exit

WiFi setup

Setting up Wi-Fi using wpa-supplicant and /etc/network/interfaces

This chapter will talk about setting up a connection to an existing Wi-Fi networks using WPA2, the most secure encryption and authentication standard available today. Additionally, examples of settings for less secure connections are provided.

If you can influence the settings of the access point, for example, if it is your home Wi-Fi router- try to configure authorization using WPA2, because it is the most secure authentication protocol in wireless networks Nowadays.

Notes

Problem solving

Wi-Fi/Ethernet connection with access point/router cannot be established

Symptoms: The network usually initially works fine, for a long or short time, and then suddenly disappears and does not appear after a reboot. This problem may not be permanent. The network starts working “by itself” and then disappears again. When restarting the network adapter this way:

Sudo ifdown wlan0 sudo ifup wlan0

similar text will be displayed in the console

Listening on LPF/wlan0/00-02-2A-E1-E0-6C Sending on LPF/wlan0/00-02-2A-E1-E0-6C Sending on Socket/fallback DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 8 DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 8 DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 15 No DHCPOFFERS received. No working leases in persistent database - sleeping.

Cause of the problem maybe that motherboard It is not completely de-energized when the computer is turned off. In this case, some peripheral equipment is probably not de-energized, incl. may not be de-energized usb ports. If you are using, for example, a Wi-Fi USB adapter, then you can notice the LED on the adapter is lit (if it is equipped with one). The problem probably occurs because the network equipment does not work entirely correctly in this mode.

A simple solution The problem is to turn off the computer and unplug the power cord from the outlet, then plug in the power cord and turn on the computer.

Difficult decision the problem is the setup BIOS parameters to complete blackout network equipment when turning off the computer.

Sometimes the Wi-Fi connection to the access point/router drops completely

Symptoms: the network initially works, and then after rebooting the access point/router it suddenly disappears, and does not appear either after a reboot or after dancing with a tambourine. Wherein wireless adapter he doesn’t see the access point point-blank (although it may be standing next to the computer), but he sees all the neighboring networks perfectly. Then, after the ~tenth~ reboot of the router, the network reappears by itself.

Cause of the problem It may be that some routers arbitrarily select the working channel number, ignoring the channel number selected in the router settings. If the channel number for the wireless interface is listed in the /etc/network/interfaces file, then this is likely the problem. Channel number 6 is indicated in the file something like this:

Auto wlan0 ... wireless-channel 6

A simple solution The problem is to comment out this parameter so that the adapter is not limited to only this channel, and restart the network

Auto wlan0 ... #wireless-channel 6

Difficult decision The problem is to register the bug on the website of the router manufacturer (firmware for it) and update the router firmware after (if) it is fixed.

Restarting the network

Now that all the necessary steps have been completed, you can restart the network and check the connection. For this:

$ sudo /etc/init.d/networking restart

Now, when you run the ip addr command, the eth0 connection with the configured parameters should be displayed. If the connection is visible, but the settings are not the same as those specified in the /etc/network/interfaces file, or any other errors occur, double-check this file for inaccuracies or typos and try restarting the network again.

Network FAQ

How to log into my computer from outside (via the Internet)?

First, you need to find out what IP address your provider gives you - gray or white (not to be confused with static/dynamic). If it's gray, then nothing will work. If white, then two options are possible:

    There is no router or it is operating in bridge mode. In this case, a white IP address is assigned to the computer itself. We enter the address - we get to the computer, everything is simple.

    The white address is assigned to the router. Accordingly, this address takes us to the router, and not to the computer. To get to the computer, you need to forward ports on the router (see below).

I think my network is too slow!

Measure the network speed between two computers using iperf. You can use this instruction. It suggests compiling the program from source, but you can simply install it from the repository. If iperf shows a value slightly lower than expected, then everything is fine with the network, the problem may be in the hardware (hard drive/processor cannot provide high speed), in the transfer method (for example, scp and ftp are very slow), in the settings ( speed may be limited, e.g. FTP settings-server) or something else. If iperf showed a value that is several times less than desired, then yes, there is a problem with the network. It’s worth checking whether the card is working in the required mode (for example, using ethtool), checking for “errors” in the ifconfig output, and testing the connection speed to a third computer.

How can I find out what programs are listening on ports on my computer?

To view a list of open ports and the names of programs listening to them, use the command:

Sudo netstat -nlpA inet,inet6

You can use grep to display information about a specific port. For example, for 80 port:

Sudo netstat -nlpA inet,inet6 | grep:80

It is not always clear from the netstat output which program is being referred to (for example, 2671/python), ps will tell you more about the process:

PS aux | grep 2671

How to assign two IP addresses to one network card?

For example, the interface eth0 need to add address 192.168.1.1 . Briefly, until the network is restarted:

Sudo ip addr add 192.168.1.1/24 dev eth0

Forever - add the following to /etc/network/interfaces:

#fix line auto auto eth0 eth0:1 # add alias iface eth0:1 inet static address 192.168.1.1 netmask 255.255.255.0

How to forward a port?

For example, you need to forward port 8081. Let's call the address to which the client accesses external_ip, and the address to which it should go is internal_ip.

Iptables -t nat -A PREROUTING -p tcp -d external_ir --dport 8081 -j DNAT --to-destination internal_ir:8081 iptables -t nat -A POSTROUTING -p tcp --dst internal_ir --dport 8081 -j SNAT - -to-source external_ir

And you definitely need something like

Iptables -t filter -A FORWARD -m conntrack --ctstate DNAT -j ACCEPT

Intel PRO/Wireless

WiFi card with appropriate software for Win - Intel PROSet/Wireless.
For example MSI laptop L745 everything worked without my intervention. Click on the NetworkManager icon - we get a list of all networks in the area.
Ubuntu 7.10, 7.04 I raised wifi using the example of an ASUS Pro 52RL laptop. There is no information on it anywhere, not even on the Asus website. Google gives only 4 links to it in Russian. It is sold only in the media market. Well, okay, closer to the point.
Ubuntu 7.10

It has an Atheros AR5006EG wireless card. Ubuntu finds and by default enables a proprietary driver that does not work. We need to turn it off. To do this, you need to add the line to the /etc/modprobe.d/blacklist-common file (if there is no such thing, then to the blacklist file):


Let's reboot:

In addition, we need a driver for Windows. You can take it for the specified card. Yes, there is also a program that will make it work, and then you can immediately install the driver.
$ sudo apt-get install ndiswrapper-common
$ sudo ndiswrapper -i net5416.inf
$ sudo ndiswrapper -m
$ sudo init 6

The new wlan0 interface should appear in the iwconfig list. Then everything is the same as in the case of Intel PRO. This beast was defeated by the chumric user on the HP Pavilion TX1350ER laptop (nothing like a toy :). According to him, the process is described in detail in

If you are the owner of any mobile device running OS Linux, then you will first have to think about completing task number one - setting up a connection to a Wifi wireless access point. By default, the standard tools for Linux desktops are reliable and easy to use. For example, Wifi Radar, Network Manager, and many other programs of this class. Of course, it is assumed that you are using environments like Gnome or KDE, which have very rich functionality and choice.

But what if you have something different and rarer - an E17, Fluxbox, ION, or even a bare console? In this case you should use classic way settings - command line.

Let's look at two cases of setting up a connection with a wireless access point:
- graphical application Wicd (for example);
- console utilities.

Introduction

This assumes that you have wireless network device(adapter) that runs under Linux. If you suddenly find that your device is not working, you can suggest, as one of the options for beginners, to install latest version Ubuntu distribution and install proprietary drivers for your wireless card. The proposed case is the simplest and most effective, compared to attempts to make the adapter work through the ndiswrapper driver.

It also assumes that you have two parameters available to connect to the wireless point: SSID and identification key. Without them (especially without the second one, since the first one can still be easily recognized) you will not be able to establish a connection.

Wicd

Graphical application written in Python. Flexible and easy-to-use program offering great functionality. Wicd is easy to install and easy to use. It only takes a few minutes to get acquainted with the program. It is also worth noting that Wicd, in addition to the graphical interface, also has a console version of “execution”, which is not inferior in functionality.

Command line

Let's now see how to set up a wifi connection through the command line. By the way, this method is universal, since it uses utilities that are standard for all Linux distributions. Moreover, all GUI applications are based on these utilities. Figuratively speaking, if we “remove” the GUI “roof” from any graphical application, then under it we will see the modest and inconspicuous workers of the console: ifconfig, wireless-tools, wpa_supplicant, ping, nmap and many others.

To complete our task you will need the following utilities:

  • - ifconfig: completely controls the operation of any network adapter on your computer (whether it is a wired or wireless interface);
  • - iwlist : displays a list of wireless access points available for connection (within range);
  • - iwconfig: utility for managing and configuring wireless network devices (adapters);
  • - dhclient (or its taxes): automatically obtains an IP address from the dhcp server of the wireless point;
  • - wpa_supplicant: utility for setting up encrypted connections.

Before you start setting up a wifi connection, it would be logical to check the presence of all these utilities in the system (although almost all of them are included in the standard set of Linux distributions). Let's, nevertheless, make sure that we have them by running very simple commands (see man which):

  • - which ifconfig
  • - which iwlist
  • - which iwconfig
  • - which dhclient
  • - which wpa_supplicant

When you run each of these commands, you will see the path where they are located in file system. If you suddenly don’t see it, you’ll have to install the missing ones. The simplest and most recommended is the package manager of that Linux distribution which you are using. As an alternative, you can offer installation from sources, but this path requires sufficient experience from the user.

Let's look at an example of connecting to a wifi point with WEP encryption

1 . The first thing we will do is look at what network adapters we have on our computer:

# ifconfig -a

The output will contain the names and detailed description all network interfaces that the ifconfig utility was able to detect. If the desired one was not found, then the reason is only one thing - there are no drivers for it and support for this interface is not enabled in the Linux kernel.

2. Launching wireless network adapter:

# ifconfig wlan0 up

Here :
- wlan0 - the standard name of the wifi card in most Linux systems;
- up - the option tells the ifconfig command to start up (“raise”) the network device.

3. Now we need to scan the air around us for available hot-spots:

# iwlist wlan0 scan

Here :

Wlan0 - name of the wireless adapter;
- scan - the iwlist command is launched in scan mode.

The result of iwlist will be a detailed report, from which at this stage we are only interested in one line: ESSID: "Some_Name". The value of the ESSID parameter ("Some_Name") is the name of the wireless access point. Now we know which specific wifi point we will connect to.

4 . Making the connection:

# iwconfig wlan0 essid Some_Name key Wireless_Key

Here :

Wlan0 - network adapter on which the connection is configured;
- essid - set the name of the access point to which we connect;
- key - indicate the encryption key used by this access point to transfer data.

Note:

The iwconfig command defaults to HEX data for the encryption key. If you want to specify the key in plain text (ASCII), you need to use the s option.

For example, like this:

# iwconfig wlan0 essid Some_Name key s:Wireless_Key

The connection has been established.

5 . The last step is to get the IP address from the wifi hotspot’s dhcp server:

# dhclient wlan0

Naturally, performing the above steps every time is tedious. We can simplify the connection setup process by writing a connection script in which we combine all these commands into one:

#! /bin/bash ifconfig wlan0 up iwconfig wlan0 essid Some_Name key s:Wireless_Key sleep 10 dhclient wlan0

Save this file under some name (for example, wireless_up) and make it executed by the command:

# chmod u+x wireless_up

Move wireless_up to /usr/local/bin to make it globally visible to the entire system.

Now you just need to dial in command line:

# wireless_up

And the connection will be established.

Let's consider a more complex case - connecting to an access point using WPA encryption

A connection with such encryption is supported only by the wpa_supplicant utility, so we will need it. Also, again, we assume that we know the encryption key (password) for this access point.

1 . We generate a password based on this key using the wpa_passphrase utility, which is part of the wpa_supplicant package. The fact is that the password that we will use further must be in the form of a hexadecimal number:

# wpa_passphrase ssid password

The utility will display the generated psk line, which we will insert into the wpa_supplicant.conf configuration file:

# sudo nano -w /etc/wpa_supplicant.conf Network=( ssid=SSID psk=PSK )

This is a very simplified configuration file, but it will work. You may need to add another line to the head of this file:

Ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=wheel

to provide necessary rights access.

2. "Raise" the wlan0 interface:

# ifconfig wlan0 up

3. We indicate which point we want to connect to:

# iwconfig wlan0 essid ssid

4 . Run the wpa_supplicant utility to establish a connection:

# wpa_supplicant -B -Dwext -i wlan0 -c /etc/wpa_supplicant.conf

Here :
-B - run the wpa_supplicant command in the background;
-Dwext - tell the wpa_supplicant utility to use the wext driver for the wlan0 interface;
-i - set a custom network interface (wlan0 in our case);
-с - specify the path to the wpa_supplicant.conf configuration file.

5 . We check that the connection is established:

# iwconfig wlan0

In the output we will see detailed information on the specified wlan0 interface.

6. We get the local IP address:

# dhclient wlan0

7. We simplify the process by creating an entry along the path /etc/network/interfaces that looks like this:

auto wlan0 iface wlan0 inet dhcp pre-up wpa_supplicant -Bw -Dwext -i wlan0 -c /etc/wpa_supplicant.conf post-down killall -q wpa_supplicant

Conclusion

Depending on the Linux distribution, there are many ways to set up wifi connections. It is thanks to this diversity that you can set up a connection on almost any Linux system.
The main thing is that the wireless adapter itself is supported in Linux at the driver level. But this already depends mainly on operating system developers.



tell friends