How to set up a Wifi connection on any Linux desktop. Configuring, installing, connecting Wi-Fi in Ubuntu: through the console and interface of Ubuntu server setting up wifi connection through the terminal

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 and - we get a list of all networks in the area.
Ubuntu 7.10, 7.04 Raised wifi using the ASUS Pro 52RL laptop as an example. There is no information on it anywhere, even on the Asus website. Google gives only 4 links to it in Russian. It is sold only in the media market. Okay, let's get down to business.
Ubuntu 7.10

It has an Atheros AR5006EG wireless card on it. Ubuntu finds and by default includes a proprietary driver that doesn't work. Gotta turn it off. To do this, add the following line to the /etc/modprobe.d/blacklist-common file (if there is none, then to the blacklist file):


Let's reboot:

In addition, we need a driver for Windows. For the specified card, you can take it. 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 as in the case of Intel PRO. This beast was defeated by the chumric habrauser on the HP Pavilion TX1350ER laptop (nothing like a toy :). According to him, the process is described in detail in

There are some problems with support for W-Fi adapters in Ubuntu. It's good if you can choose a known compatible model when buying, but more often you have to use the equipment that is. In this case, you will have to install the adapter yourself. Today we will consider just such a case.

Looking ahead, let's say that there is nothing difficult in connecting unsupported Wi-Fi adapters. While some of the steps we'll perform can be performed using the GUI, we'll be working exclusively in the console, so the recommendations in this article can be used 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 archive of the repository, after elevating the rights to the superuser:

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

Unpack the archive (if necessary, install unzip).

Unzip master.zip

As you can see from the output of the command, 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 in the directory should appear file 8188eu.ko, this is the desired kernel module. Now let's install it with the command:

make install

It remains to enable our module by running the command:

Modprobe 8188eu

or just disconnect and reconnect the adapter. On a desktop system, you will immediately see a message that you can 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 built and installed under the current kernel version, and when it is updated, it will be necessary to build and install the module again. If this is not possible, then you should, holding Shift when loading, select and load the kernel version for which the module is built.

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

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

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

Introduction

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

It also assumes that you have two options for connecting to a 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. A flexible and easy-to-use program that offers great functionality. Wicd is easy to install and also easy to use. It only takes a few minutes to familiarize yourself with the program. It is also worth noting that Wicd, in addition to the graphical interface, also has a console version of the "execution" that 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 applications with a graphical interface (GUI) are based on the work of these utilities. Figuratively speaking, if we "remove" the "roof" of the GUI from any graphical application, then under it we will see modest and inconspicuous console workers: ifconfig, wireless-tools, wpa_supplicant, ping, nmap and many others.

To complete our task, we need the following utilities:

  • - ifconfig : fully manages the operation of any network adapter on your computer (be it a wired or wireless interface);
  • - iwlist : gives a list of available for connection (located within range) wireless access daughters;
  • - iwconfig : utility for managing and configuring wireless network devices (adapters);
  • - dhclient (or its taxes): automatically obtains an IP address from the wireless point's dhcp server;
  • - wpa_supplicant : utility for configuring encrypted connections.

Before setting up a wifi connection, it would be logical to check the availability 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 will have to install the missing ones. The easiest and most recommended is the package manager of the Linux distribution you are using. As an alternative, you can offer installation from source, but this way requires sufficient experience from the user.

Consider an example of connecting to a wifi point with WEP encryption

one . The first thing we will do is see what network adapters we have on our computer:

# ifconfig -a

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

2. Launching the wireless network adapter:

# ifconfig wlan0 up

here :
- wlan0 - the name of the wifi card, standard in most Linux systems;
- up - the option tells the ifconfig command to start ("up") the network device.

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

# iwlist wlan0 scan

here :

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

The result of the iwlist operation will be a detailed report, of 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.

four . 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 are connecting;
- key - specify the encryption key used by this access point for data transfer.

Remark :

The iwconfig command uses HEX data for the encryption key by default. 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

Connection established.

5 . The last step is to get an IP address from the dhcp server of the wifi point:

# dhclient wlan0

Naturally, the above steps are tedious to perform every time. We can simplify the process of establishing a connection 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

We save this file under some name (for example, wireless_up) and make it executable with 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 type in command line:

# wireless_up

And the connection will be established.

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

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

one . 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 next must be in the form of a hexadecimal number:

# wpa_passphrase ssid password

The utility will output the generated psk string, which we will paste into the wpa_supplicant.conf configuration file:

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

This is a very simplified config file, but it will work. You may need to add one more line to the header of this file:

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

to grant the necessary access rights.

2. "Raise" the wlan0 interface:

# ifconfig wlan0 up

3. Specify which point we want to connect to:

# iwconfig wlan0 essid ssid

four . 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);
-c - specify the path to the wpa_supplicant.conf configuration file.

5 . Check that the connection is established:

# iwconfig wlan0

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

6. Get the local IP address:

# dhclient wlan0

7. We simplify the process by creating an entry in the /etc/network/interfaces path 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 your 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 the developers of operating systems.

If your computer or laptop has a Wi-Fi card, then it would be foolish not to use wireless communication. In this article, we will look at how to set up a Wi-Fi connection in Linux Mint 17 and what problems may arise with this.

Setting up Wi-Fi connection in Linux Mint 17

Our example will be based on the example of Linux Mint MATA 17.1, but all operations look the same on other versions. Find the network connection indicator on the bottom panel in the right corner.

Click on it with the left mouse button and you will see a list of available networks.

Find yours among them and click on its name. The system will ask you to enter a secret password, and after entering it, click on "ok".

Now the network indicator has taken this form and you can see the Wi-Fi signal strength by the number of dark bars.

How to enable Wi-Fi

If for some reason Wi-Fi does not work and you do not see a list of available networks, then there may be several reasons for this.

  1. Check the connection of the wi-fi adapter to the computer.
  2. Check if your router is turned on and check its settings
  3. Check if the driver for your wi-fi adapter is installed

The third item can be checked from the terminal with the commands

sudo iwconfig

sudo lspci

Most often, the driver can be found on the adapter manufacturer's website, so look for it there. There are cases when it is possible to connect Wi-Fi, but the connection is constantly disconnected (falls off). In such a situation, you will need to reinstall the driver, but in each case this is done differently. Ask your question on the forum and together we will try to solve your problem.

How to set up a hidden Wi-Fi network

To create or connect to a hidden Wi-Fi network, there are corresponding lines in the network connection manager.

Click on "connect to a hidden wireless network" and fill in the following fields:

If you want to create a new hidden network then fill in the fields as in the image below

As you can see, nothing complicated and we hope that this article helped you connect to the Internet and fully use operating system Linux Mint.

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

The manual provides examples of editing configuration files using the "nano" and "gedit" text editors. Note that the first editor is run in a terminal and can be used both when running Ubuntu with or without a GUI, while "gedit" can only be used when the graphical environment is enabled.

System requirements

Any system installation option is suitable for reproducing 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 that begin with the $ symbol must be executed as a user, and those that begin with # must be executed from the superuser (root).

Before you begin, make sure that:

    Various network filters (eg iptables) and their configuration utilities (eg Firestarter) are disabled/correctly configured and do not interfere with the network.

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

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

    Your network device driver is correctly installed, the cable (when connected by wire) is OK and connected.

For settings, you will definitely need the name of your network adapter. It can be found from the output of the command:

$ sudo lshw -C network

It allows you to view connected network devices.

Example command output:

[email protected]:~$ 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: [email protected]:03:00.0 logical name: eth0 # Network interface name version: a0 serial: 00:00:00:00:00:00 # Device physical address (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 # Driver used driverversion=2.2.3 # Driver version duplex=full firmware =L2 ip=192.168.0.5 latency=0 link=yes # Link available module=atl2 multicast=yes port=twisted pair speed=100MB/s # Current connection speed.

Pay attention to the line:

Logical name: eth0

eth0 is the name of the network interface you are looking for.

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

Since the introduction of SystemD (as of Ubuntu 15.04), network interfaces may have other names (not ethX). This is done so that the names of network devices do not change when new adapters are connected to the machine (recently, some USB modems act as a network adapter). As a result, eth0 might be called enp0s4 or eno1, or even enx78e7d1ea46da, for example. It is this name of the network adapter that must be used in the network setup.

You can read more about naming network interfaces in SystemD.

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

Wired network setup

Setting the 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 address range (inet) 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 of DNS servers (we will talk about below later)

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

eth0- the name of the connected interface. 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 "Filename to write" is /etc/network/interfaces and press Enter .

Learn more about file syntax /etc/network/interfaces can be read in the documentation.

Configuration example for dynamic IP:

face eth0 inet dhcp auto eth0

Temporarily setting the IP address and subnet mask

If you need to set trial settings, run:

$ 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- pluggable network interface.

These settings will disappear after the system is rebooted and will not affect the file. /etc/network/interfaces

DNS setting

DNS configuration is handled by the resolvconf utility, which works in tandem with a small caching DNS server, dnsmasq. resolvconf allows you to configure DNS based on data from different subsystems.
One consequence of this useful change (a change to this scheme in Ubuntu since version 12.04) is that the /etc/resolv.conf file is now generated automatically, rather than individually by each program that wants to change it (sometimes overwriting edits made earlier). ). Automatic generation of /etc/resolv.conf means that manual changes 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) the dnsmasq service sits, which is responsible for resolving symbolic names to 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 options (which correspond to the nameserver, search and domain options in /etc/resolv.conf)

Please note - in /etc/resolv.conf, when writing several servers, several nameserver keys are used, and in /etc/network/interfaces, all DNS server addresses are 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 prior to version 12.04

In older versions of ubuntu, when there is a need to specify static DNS server addresses (if they are not given automatically), run:

$ sudo gedit /etc/resolv.conf

and enter the addresses of DNS servers there (separate entries for each server):

Nameserver 192.168.0.100 nameserver 192.168.0.200

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

Configuring ppp connections

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

PPPoE connection

to standard installing Ubuntu includes a utility for configuring PPPoE connections - pppoeconf, to run it, type:

$ sudo pppoeconf

A "pseudo-graphic" 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 connection, power supply of the modem. The next step is choosing "popular options" - in most cases, it's worth agreeing. Next, the utility will ask for your username and then a password. Now - the choice of how to specify 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 the connection automatically when the computer boots. The last question of the utility is whether to establish a connection now. pppoeconf creates the name dsl-provider for the connection by default. 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 not enough - refer to pppd or pppoeconf documentation.

Note: When setting up a connection using pppoeconf part of the settings is written to /etc/network/interfaces , as a result of which Network Manager can no longer manage the network. Output: either use only NM, or only console + configs. You can take back control of Network Manager as follows. Lead /etc/network/interfaces to the following form (it is not necessary to delete the excess, it is enough to 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 network:

Reboot or restart Network Manager:

$ sudo /etc/init.d/NetworkManager restart

PPTP connection

To make a VPN connection with pppd you need to install the package pptp-linux, which can be found on 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 # When the connection is broken, reconnect. maxfail 0 # Maximum number of failed connection attempts. 0 - infinite. mtu 1476 # MTU value name (login) # Your login. #nodefaultroute # Not be a default gateway defaultroute # Be a default gateway replacedefaultroute # Replace default gateway if it was remotename (vpn) # Remote server name (for us), can be anything. pty "pptp (server_address) --nolaunchpppd" # Start pptp command. # Server address - can be either an IP address or a domain name, for example vpn.foo.bar

(login) (vpn) (password)

After rebooting the system, you can manage the connection using the commands:

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

Setting up a DIAL-UP connection

To set up a modem connection, you can use the built-in configurator pppd - pppconfig or special tool wvdial .

Using pppconfig

The setup process with pppconfig much like utility pppoeconfig, You will be asked in turn questions about the connection parameters, and you will be asked to enter a phone number, login and password, and a connection name. 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), it is more convenient to use wvdial. To do this, you must first install it. For example like this:

$ sudo apt-get install wvdial

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

$ sudo wvdialconf

The output will be something like this:

[email protected]:~$ 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 it remains only to edit the file /etc/wvdial.conf and add your phone number, username 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 # Connection idle time, # after which it will need to be terminated. The value 0 is never. Dial Attempts = 0 # Number of dialing attempts. 0 - infinite. Dial Command = ATDP # Dial command (P - pulse, T - tone). It makes sense for dialing in pulse mode on older PBXs.

The /etc/wvdial.conf file is divided into sections, whose separators 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 come into play. Otherwise, the commands specified in the additional sections will be additionally executed.

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

$ sudo wvdial

If you need to run wvdial with dialing in pulse mode, then this can be done with the command

$ sudo wvdial pulse

You can terminate the connection by aborting 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 dial-up connections 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 on restart network services the connection will be automatically established.

Manual routing setup

If you do not get the default gateway address from the server you are connecting to, or for some other reason you need to specify routes manually - you can create your own script in /etc/ppp/ip-up.d/, or on 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 required 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 automatically connect 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 can support in a single transmit/receive operation. For Ethernet, this default value is 1500 ( maximum size Ethernet packet).

TTL (Time To Live) - IP packet lifetime in seconds. Needed to avoid network overload with packets. Usually, each router through which the packet passes 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 defines the data validity time when caching requests.

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

Wi-Fi setup with wpa-supplicant and /etc/network/interfaces

This chapter will discuss how to set up a connection to an existing WiFi networks using WPA2, the world's most secure encryption and authentication standard. Additionally, examples of settings for less secure connections are given.

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

Remarks

Solution of problems

Wi-Fi/Ethernet connection not established with access point/router

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 issue may not be permanent. The network "by itself" starts to work, and then disappears again. When restarting the network adapter in this way:

sudo ifdown wlan0 sudo ifup wlan0

will output similar text to 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 does not completely de-energize when the computer is turned off. At the same time, some peripheral equipment is probably not de-energized, incl. usb ports may not be de-energized. If you are using, for example, a Wi-Fi usb adapter, then in this case you can notice the LED on the adapter (if equipped with it). Probably the problem occurs due to the fact that the network equipment in this mode does not work quite correctly.

A simple solution The problem is turning off the computer and unplugging the power cord from the outlet, then plugging in the power cord and turning on the computer.

Difficult decision The problem lies in setting the BIOS parameters for a complete blackout of the network equipment when the computer is turned off.

Sometimes the Wi-Fi connection with the access point / router disappears tightly

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. At the same time, the wireless adapter does not see the access point at point-blank range (although it can stand next to the computer), but it perfectly sees all neighboring networks. Then, after the ~twentieth~ reboot of the router, the network reappears by itself.

Cause of the problem it may be that some routers arbitrarily choose a working channel number, ignoring the channel number selected in the router settings. If the /etc/network/interfaces file contains the channel number for the wireless interface, then this is probably the problem. Channel number 6 is indicated in the file 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 this channel only, and restart the network

Auto wlan0 ... #wireless-channel 6

Difficult decision The problem consists in registering a bug on the website of the router manufacturer (firmware for it) and updating the router firmware after (in case) it is fixed.

Network restart

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

$ sudo /etc/init.d/networking restart

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

Networking FAQ

How can I access my computer from the outside (via the Internet)?

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

    There is no router or it works in bridge (bridge) mode. In this case, the 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, at this address we get 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 guide. It suggests compiling the program from source, but you can simply install it from the . If iperf shows a value a little less than expected, then everything is fine with the network, the problem may be in the hardware (the hard disk / processor cannot provide high speed), in the transfer method (for example, scp and ftp are very slow), in the settings ( the speed can be limited, for example, by the FTP server settings) 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 is worth seeing if the card is in the correct mode (for example, using ethtool), check for "errors" in the ifconfig output, and test the connection speed to some third computer.

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

To see 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

From the output of netstat it is not always clear which program is in question (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 add an address 192.168.1.1 . For a short time, 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 that the client accesses external_ip, and the address to which it should go - internal_ip.

iptables -t nat -A PREROUTING -p tcp -d externalip --dport 8081 -j DNAT --to-destination internalip:8081 iptables -t nat -A POSTROUTING -p tcp --dst internalip --dport 8081 -j SNAT - -to-source external_ip

And you need something like

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