After reviewing most of the thematic posts on Habré, I was immensely surprised by the fact that the topic of using the Unix / Linux operating system on the Internet service provider is extremely poorly covered. This article will partially try to fill this gap.

Why there is a complete absence of such articles on the Internet is not difficult to guess - everyone who uses Linux / FreeBSD in an ISP is immediately accused of poverty and advised to buy Cisco or, in a very extreme case, Juniper. That is why the second goal of this article is to show the reader that some technical solutions based on the Linux OS in many respects are orders of magnitude superior to branded solutions from the most famous vendors.

Shaping
Our first experience of "non-standard" use of Linux appeared immediately after the start of providing broadband access services for individuals. It was necessary to "cut" the external channel of each of our users with something. Here, due to the lack of own developments on this topic, I had to invent my own bicycle using cbq and my own strapping to it. This scheme worked for a couple of months until we realized all its disadvantages and ran into the performance of the machine.

The thing is that the system began to “eat up” too many soft interrupts even with not much traffic, for example, with transit traffic of 300 megabits and 30 kpps with 1000 cbq linear rules (2 entry / exit rules per user) on each interface in top si reached 100%.

If at the moment we were faced with the same task with the same technical means, we would solve it with the help of Linux htb tc + hash filters.

NAT
Since at that time we were a small local home provider, when connecting subscribers of individuals, we had an acute question whether to issue a “white” routable ip address to the client, or limit ourselves to issuing “gray” ip addresses.

We settled on “gray” addresses, because using them saved as much valuable material at that time as real addresses. Also, the security and comfort of our users' work was slightly increased, since their computers were not "directly" accessible to the entire Internet network from the outside.

We put together a scheme in which we “export” a copy of all user traffic (SPAN PORT) to the necessary network ports of the server with Linux OS on board, and then using ipt_NETFLOW we form a FLOWS stream to the desired server.

In more detail, along with the configs, the scheme of work is given.

P.S. We are aware that most Cisco equipment can pour an already formed NETFLOW stream into the specified Netflow collector, but in our network diagram at that time there simply could not be such equipment :)

Termination of user networks.
Initially, I wanted to give the user an ip address, subnet mask, and gateway and not load it with PPPoE, PPTP, VPN settings, which in the end should have somewhat relieved the technical support service (which happened in practice), since the network setup became quite trivial in any custom OS.

Deciding to apply our previous experience of using Linux OS, we came up with the following scheme, Linux servers with a pair of four-port network adapters are installed in key places of the network, one link “goes” towards the network core, the rest towards “clusters”. As a result, a bunch of VLANs with several networks in each of them rise on each interface.

In total, we had 4 servers for the entire network, approximately 10k subscribers each.

The peak traffic reached by each server during peak hours was about one and a half megapackets per second. The servers exchanged routes with each other using the ospf protocol.

Blocking of access to users was carried out by means of ipset.

Border
I would like to end on this happy note, but I would like to write about another “non-standard” application of Linux - as a border. It so happened that our Cisco ASR was out of order, performing the functions of a border, which received 2 full views from two uplinks.

Here follows a small lyrical digression. Cisco 100% kept its obligations and sent a replacement within a few hours after filling out the necessary documents, but as you understand, customers will not wait a day until the new hardware arrives in our area. The decision was spontaneous.

They took the server from the warehouse, installed Linux + quagga on it and successfully installed it instead of the failed Cisco.

At rush hour, this miracle of engineering “chewed” the incoming stream of 1.4Gb / s, with a total kpps on all interfaces of about 400.

P.S. In the course of our work, we have collected and tested many RPM packages for the CentOS 5 distribution, here is just a small list of them:

  • ipset
  • connlimit
  • conntrack-tools
  • ipt_netflow
  • flow-tools
  • quagga

You can download them from this repository.

P.P.S. If you have your own insights or notes about using *nix like OS on an ISP, you are welcome.

The user's article, unfortunately, he will have enough karma to post it himself, so I ask you to leave all the pros / cons in his karma

A modern computer provides the user with many features, without a good half of which he could easily do without. To this day, there is a debate on the net about whether it needs 3D graphics and high-quality sound. However, there is one function, the need for which is not disputed by anyone - this is access to the network.

Free OS connoisseurs argue that Linux is built for the web, like a bird for flight. True, they immediately make an allowance for the fact that only the elite will see the true power of this system, since setting up network interfaces is a difficult task and requires serious knowledge.

It is difficult to argue with this statement, since its comprehensive nature is obvious. Indeed, without having special skills, even stools cannot be put together. Nevertheless, here we are dealing with some exaggeration. Linux is a simple system. The Windows user has to keep much more information in memory in order to ensure comfortable work with it.

So that the last statement does not look unfounded, consider the procedure for setting up a network on a Linux system. Moreover, as is customary in the free software world, there is not one way, but several options. And the user himself will choose the one that he likes best.

ifconfig command

As a rule, network adapter drivers are connected during system installation. To verify this, just type ifconfig -a in the console. By the way, this name is not at all a mangled name for the ipconfig command familiar to Windows users. It's just short for Interface Configuration.

In response, the user will receive information about the characteristics of the Ethernet connection and the parameters of the so-called ring interface. The first is designated as eth0 (if there are several network adapters, then each will have its own eth[sequence number] section), and the second - as lo.

The same command can be used to activate the interface. Most often it looks like this:

ifconfig [interface name] netmask [netmask] broadcast [broadcast address] up.

However, in practice, all parameters may not be specified. For example, if the netmask and broadcast address are not set explicitly, then the system will use the default values ​​(network address with machine part 255 and mask 255.255.255.0).

The pointopoint option must be used to activate PLIP, SLIP and PPP. In this case, the interfaces will be named like this:

Plip[number starting from zero] - for PLIP;

– slip[serial number starting from zero] - for SLIP;

– ppp[sequence number starting from zero] - for PPP.

For example, to configure a PLIP interface that connects two computers at addresses [address1] and [address2], type in the console:

ifconfig plip0 [address1] pointopoint [address2].

Disabling an interface is done with the ifconfig [interface designation] down command. Thus, using just one command, you can control a network device. And of course, there is no point in keeping all its options in memory - if you forgot something, then man ifconfig will always come to the rescue.

route command

The route command is responsible for routing. That is, it tells the system to which network computer packets should be sent in order to reach their destination.

This command displays the routing table. In addition, each entry consists of several fields:

– Destination - IP address of the destination of the route;

– Gateway - IP address or name of the gateway (if it is not present, then the symbol “*” is used);

– Genmask - route network mask;

– Flags - route type or state indicator (can take the following values: U - active, H - host, C - gateway, D - dynamic, M - modified);

– MSS - maximum amount of data transmitted at one time;

– Metric - number of hops to the gateway;

– Ref - number of requests to the route at a certain point in time;

Window - the maximum amount of data for the receiving side;

– Use - number of packets transmitted along the route;

– Iface - interface type.

To add an address to the routing table, use the route command with the add option. It should be noted that if the corresponding interface has already been configured using ifconfig, then the system itself can obtain information about it. In this case, there is no point in using specifiers - it is enough to specify the address of the destination. All other data will be redundant, and therefore optional.

Obviously, at least one entry must be made in the routing table in order to work on the network. The default destination is indicated by the default label.

Use the route del -net command to delete a route.

Other commands

If the interface settings are stored in the system, then the ifup and ifdown commands can be used to quickly activate and deactivate, as follows:

– ifup [interface designation] - to enable.

– ifdown [interface designation] - to disable.

The netstat command is used to display a list of network connections, routing tables, interface statistics, and so on. Among other things, it allows you to display the status of the connection, which is useful when analyzing the system for its security.

For example, LISTEN means that the service is waiting for a connection to another machine, and ESTABLISHED means that it has already been established. If there are no running programs for which this state is normal, then this may be unsafe and indicate an attack on the host.

Configuration files

The above commands are enough to configure the network. However, these utilities have one significant drawback: the result of their work will be valid for only one session. After the reboot, everything will have to start over. For this reason, it is much more convenient to edit the configuration files once.

Despite the fact that their device is independent of the distribution, they can be located in different places. For example, in Debian, /etc/init.d/network is responsible for setting up interfaces and routing, and in Slackware (MOPS, Zenwalk) - /etc/rc.d/rc.inet1. There is only one universal piece of advice that can be given in this regard: when starting to work with a particular product, be sure to read the technical documentation.

As an example, consider the ASPLinux distribution. The /etc/sysconfig/network-scripts/ directory is used to store network interface settings. Each of them is defined by the ifcfg-[interface designator] file.

This file consists of lines of the form: [parameter]=[value]. The parameters can be the following:

– NAME - arbitrary connection name;

– DEVICE - interface designation;

– IPADDR - interface IP address;

– NETMASK - network mask;

– GATEWAY - gateway IP address;

– ONBOOT - a pointer to the need to activate during boot;

– USERCTL - indicates that an ordinary user can activate the interface;

– MTU - MTU value (maximum packet size transmitted through the interface);

– PEERDNS—indicates the need to use DNS servers obtained upon interface activation;

– DNS1, DNS2 - IP addresses of primary and secondary DNS servers;

– BOOTPROTO - interface configuration mode indicator (none - using user parameters, boottp or dhcp - using appropriate protocols).

The /etc/host.conf and /etc/resolv.conf files are responsible for configuring DNS. The first of them is a plain text file, which specifies the rules for the operation of the node name and address search subsystem. Its structure is typical for all objects of this type - each line contains a parameter and its values ​​(there may be several of them).

The order parameter specifies the method for finding the node's IP address. It can take the following values: bind (use DNS server), hosts (use local address database), nis (use NIS server). They must be in the order in which the search will be performed.

The trim parameter is used to describe exceptions. The corresponding line specifies the domain that will be automatically removed from the name.

The reorder parameter can take on/off values. It is responsible for enabling the mode of operation in which local addresses take precedence over all found ones. Spoofalert turns on the mode of writing the results of checking for false names to the system log. And multi allows you to customize the method of processing the local base of nodes. Of course, it is not necessary to specify all parameters. In practice, there are often /etc/host.conf files that consist of two lines.

The /etc/resolv.conf file describes some of the options that are used by the name lookup subsystem. It may consist of the following lines:

– nameserver - addresses of DNS servers;

– domain - local domain name to search for addresses in the local network;

– search - list of domains to search for addresses.

Obviously, the domain and search parameters cannot be relevant at the same time. If the system detects this contradiction, it will consider only the last record.

Or can Linux not use a nameserver at all? Theoretically - yes, although in practice the method described below is used only in very small networks, where other methods are not justified.

The way is to use the /etc/hosts file. It is a list of hostnames and their IP addresses, and more than one name can be specified for one address.

Graphical customization tools

Although setting up a network by directly editing configuration files is not a very difficult task, almost all modern distributions offer the user graphical tools designed to solve it. Even Zenwalk, which is not usually considered friendly in the Windows sense of the word, allows you to configure network interfaces without using the command line.

And today we have the right to say that in addition to elementary settings, the user can perform quite complex operations. In particular, a few years ago, the topic of setting up a VPN connection in Linux occupied a prominent place on the technical support forums, and all the proposed solutions to this problem could not be called simple. But times are changing.

For example, users of the Linux XP Desktop distribution set up a VPN connection using a convenient GUI tool that is even simpler than the similar tool in Windows. Approximately the same is offered to the consumer by ASPLinux, Mandriva and SuSE Linux.

All in all, Linux is truly built for the web. And this can be appreciated not only by experienced users, but also by beginners.

Linux has many tools for monitoring network activity. But most of them allow you to control only network traffic from your computer or a specific interface. There are times when you need to understand which program uses the network connection most actively, for example, if you, with your slow Internet, want to calmly look at your favorite sites, and then some program starts downloading something, and it’s not clear which one. For such cases, there is a NetHogs tool.

In this article, we will discuss the installation, configuration and features of working with NetHogs.

As the utility's man page says, NetHogs is a small network monitor. The program groups network activity not by protocol or network, but by process groups.

If suddenly something starts to actively use the Internet connection, you can simply run NetHogs and you will immediately see the PID of the culprit. Since the utility is based on the proc subsystem, there is currently a Linux-only version.

Debian users of similar systems, including Ubuntu, can install the utility with the following command:

sudo apt-get install nethogs

If you are using a different distribution, see the installation details on the official NetHogs website. The utility requires the pcap and ncurses libraries to work, make sure that the libncurses5-dev and libpcap0.8-dev packages are installed.

Who is using the network

NetHogs is very easy to use. Just run the nethogs command in a terminal without any options and the utility will display the network activity for each process.

As you can see, the program shows details such as PID, user, network interface, amount of data, and transmit or receive speed.

Data update

By default, NetHogs updates the information every second, but you can use the -d option to specify the update interval. For example, to update every three seconds, type:

sudo nethogs -d 3

Specify the network interface

You can tell NetHogs which network interface to work with by simply typing the interface name on the command line. For example, to monitor traffic on eth1 use:

sudo nethogs eth1

You can use the -p option to capture traffic in promiscuous mode (called monitor mode), but this is not recommended.

Hotkeys

The utility provides hotkeys with which you can control the presentation method. For example, press M while the program is running to change the format for transmitting or receiving data. Options are available in kb/s, kb, b mb.

For example, displaying in megabytes:

You can also press R or S to sort by the amount of received or transmitted data. And as always Q to exit the program.

conclusions

NetHogs is perfect for when you want to catch and kill a process that is eating up a lot of internet traffic. Plus, it's an open source utility, which means you can try to figure out how it works or even rewrite it for yourself.

Have you used NetHogs or another similar tool before? Share your thoughts in the comments.

Related posts:


A modern computer provides the user with many features, without a good half of which he could easily do without. To this day, there is a debate on the net about whether it needs 3D graphics and high-quality sound. However, there is one function, the need for which is not disputed by anyone - this is access to the network.

Free OS connoisseurs argue that Linux is built for the web, like a bird for flight. True, they immediately make an allowance for the fact that only the elite will see the true power of this system, since setting up network interfaces is a difficult task and requires serious knowledge.

It is difficult to argue with this statement, since its comprehensive nature is obvious. Indeed, without having special skills, even stools cannot be put together. Nevertheless, here we are dealing with some exaggeration. Linux is a simple system. The Windows user has to keep much more information in memory in order to ensure comfortable work with it.

So that the last statement does not look unfounded, consider the procedure for setting up a network on a Linux system. Moreover, as is customary in the free software world, there is not one way, but several options. And the user himself will choose the one that he likes best.

ifconfig command

As a rule, network adapter drivers are connected during system installation. To verify this, just type ifconfig -a in the console. By the way, this name is not at all a mangled name for the ipconfig command familiar to Windows users. It's just short for Interface Configuration.

In response, the user will receive information about the characteristics of the Ethernet connection and the parameters of the so-called ring interface. The first is designated as eth0 (if there are several network adapters, then each will have its own eth[sequence number] section), and the second as lo.

The same command can be used to activate the interface. Most often it looks like this:

ifconfig [interface name] netmask [netmask] broadcast [broadcast address] up.

However, in practice, all parameters may not be specified. For example, if the netmask and broadcast address are not set explicitly, then the system will use the default values ​​(network address with machine part 255 and mask 255.255.255.0).

The pointopoint option must be used to activate PLIP, SLIP and PPP. In this case, the interfaces will be named like this:

– plip[sequence number starting from zero] — for PLIP;

– slip[sequence number starting from zero] — for SLIP;

– ppp[sequence number starting from zero] — for PPP.

For example, to configure a PLIP interface that connects two computers at addresses [address1] and [address2], type in the console:

ifconfig plip0 [address1] pointopoint [address2].

Disabling an interface is done with the ifconfig [interface designation] down command. Thus, using just one command, you can control a network device. And of course, there is no point in keeping all its options in memory - if you forgot something, then man ifconfig will always come to the rescue.

route command

The route command is responsible for routing. That is, it tells the system to which network computer packets should be sent in order to reach their destination.

This command displays the routing table. In addition, each entry consists of several fields:

– Destination—IP address of the route's destination;

– Gateway — IP address or name of the gateway (if it is not present, then the symbol “*” is used);

– Genmask — route network mask;

– Flags — route type or state indicator (can take the following values: U—active, H—host, C—gateway, D—dynamic, M—modified);

– MSS is the maximum amount of data transmitted at one time;

– Metric—number of hops to the gateway;

– Ref—number of requests to the route at a certain point in time;

Window - the maximum amount of data for the receiving side;

– Use—number of packets transmitted along the route;

– Iface—interface type.

To add an address to the routing table, use the route command with the add option. It should be noted that if the corresponding interface has already been configured using ifconfig, then the system itself can obtain information about it. In this case, there is no point in using specifiers - it is enough to specify the address of the destination. All other data will be redundant, and therefore optional.

Obviously, at least one entry must be made in the routing table in order to work on the network. The default destination is indicated by the default label.

Use the route del -net command to delete a route.

Other commands

If the interface settings are stored in the system, then the ifup and ifdown commands can be used to quickly activate and deactivate, as follows:

– ifup [interface designation] — to enable.

– ifdown [interface designation] — to disable.

The netstat command is used to display a list of network connections, routing tables, interface statistics, and so on. Among other things, it allows you to display the status of the connection, which is useful when analyzing the system for its security.

For example, LISTEN means that the service is waiting for a connection to another machine, and ESTABLISHED means that it has already been established. If there are no running programs for which this state is normal, then this may be unsafe and indicate an attack on the host.

Configuration files

The above commands are enough to configure the network. However, these utilities have one significant drawback: the result of their work will be valid for only one session. After the reboot, everything will have to start over. For this reason, it is much more convenient to edit the configuration files once.

Despite the fact that their device is independent of the distribution, they can be located in different places. For example, in Debian, the /etc/init.d/network file is responsible for setting up interfaces and routing, and in Slackware (MOPS, Zenwalk) it is /etc/rc.d/rc.inet1. There is only one universal piece of advice that can be given in this regard: when starting to work with a particular product, be sure to read the technical documentation.

As an example, consider the ASPLinux distribution. The /etc/sysconfig/network-scripts/ directory is used to store network interface settings. Each of them is defined by the ifcfg-[interface designator] file.

This file consists of lines of the form: [parameter]=[value]. The parameters can be the following:

– NAME—arbitrary connection name;

– DEVICE—interface designation;

– IPADDR — interface IP address;

– NETMASK—network mask;

– GATEWAY — gateway IP address;

– ONBOOT — pointer to the need to activate during boot;

– USERCTL—indicates that an ordinary user can activate the interface;

– MTU — MTU value (maximum packet size transmitted through the interface);

– PEERDNS—indicates the need to use the DNS servers obtained when the interface was activated;

– DNS1, DNS2 — IP addresses of primary and secondary DNS servers;

– BOOTPROTO — interface configuration mode indicator (none — using user parameters, boottp or dhcp — using appropriate protocols).

The /etc/host.conf and /etc/resolv.conf files are responsible for configuring DNS. The first of them is a plain text file, which specifies the rules for the operation of the node name and address search subsystem. Its structure is typical for all objects of this type - each line contains a parameter and its values ​​(there may be several of them).

The order parameter specifies the method for finding the node's IP address. It can take the following values: bind (use DNS server), hosts (use local address database), nis (use NIS server). They must be in the order in which the search will be performed.

The trim parameter is used to describe exceptions. The corresponding line specifies the domain that will be automatically removed from the name.

The reorder parameter can take on/off values. It is responsible for enabling the mode of operation in which local addresses take precedence over all found ones. Spoofalert turns on the mode of writing the results of checking for false names to the system log. And multi allows you to customize the method of processing the local base of nodes. Of course, it is not necessary to specify all parameters. In practice, there are often /etc/host.conf files that consist of two lines.

The /etc/resolv.conf file describes some of the options that are used by the name lookup subsystem. It may consist of the following lines:

– nameserver—addresses of DNS servers;

– domain — name of the local domain to search for addresses in the local network;

– search — list of domains to search for addresses.

Obviously, the domain and search parameters cannot be relevant at the same time. If the system detects this contradiction, it will consider only the last record.

Or can Linux not use a nameserver at all? Theoretically, yes, although in practice the method described below is used only in very small networks, where other methods are not justified.

The way is to use the /etc/hosts file. It is a list of hostnames and their IP addresses, and more than one name can be specified for one address.

Graphical customization tools

Although setting up a network by directly editing configuration files is not a very difficult task, almost all modern distributions offer the user graphical tools designed to solve it. Even Zenwalk, which is not usually considered friendly in the Windows sense of the word, allows you to configure network interfaces without using the command line.

And today we have the right to say that in addition to elementary settings, the user can perform quite complex operations. In particular, a few years ago, the topic of setting up a VPN connection in Linux occupied a prominent place on the technical support forums, and all the proposed solutions to this problem could not be called simple. But times are changing.

For example, users of the Linux XP Desktop distribution set up a VPN connection using a convenient GUI tool that is even simpler than the similar tool in Windows. Approximately the same is offered to the consumer by ASPLinux, Mandriva and SuSE Linux.

All in all, Linux is truly built for the web. And this can be appreciated not only by experienced users, but also by beginners.

To systematize information on setting up a network in Linux OS, it was decided to write this note. Here, in an accessible form, the process of setting up a network interface is described using the Ubuntu OS as an example. Also, this guide will help you "raise" the local network on any other Linux distribution.

To view the current network settings and the status of network interfaces in Linux OS, there is a command:

Sample output:

eth0 Link encap:Ethernet Hwaddr 00:11:5b:91:25:3e

inet addr:192.168.1.18 bcast:192.168.255.255 Mask:255.255.0.0
inet6 addr: fe80::211:5bff:fe91:253e/64 Range:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:648009 errors:0 dropped:0 overruns:0 frame:0
TX packets:1075413 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:70177943 (70.1 MB) TX bytes:1536487024 (1.5 GB)
Aborted:19 Base address:0xd000

lo Link encap:Loopback

inet addr:127.0.0.1Mask:255.0.0.0
inet6 addr: ::1/128 Range:Node
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:106 errors:0 dropped:0 overruns:0 frame:0
TX packets:106 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:13776 (13.7 KB) TX bytes:13776 (13.7 KB)

To view absolutely all network interfaces, run the command with the key -a:

# sudo ifconfig -a

From the above example, you can see that the computer uses two network interfaces: eth0 and lo.

Interface lo is a local loop that has an IP address of 127.0.0.1 and is intended for network access to its own computer. Further, this interface will not be considered, since it does not require additional configuration for effective operation.

Interface eth0 is an Ethernet network card that has network parameters: IP address - 192.168.1.18 , netmask - 255.255.0.0 and MAC address - 00:11:5b:91:25:3e. Meaning RUNNING indicates that the network interface eth0 is currently up.

To view the connection type, speed and parameters supported by the eth0 network interface, type the command:

# sudo ethtool eth0

Conclusion:

Supported ports: [ TP MII ]
Supported link modes:10baseT/Half 10baseT/Full

100baseT/Half 100baseT/Full

Supports auto negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full

100baseT/Half 100baseT/Full

Advertised auto-negotiation: Yes
Speed: 100Mb/s
Duplex: Full
Port: MII
PHYAD: 1
Transceiver: internal
Auto negotiation: on
Supports Wake-on: pg
Wake-on: d
Current message level: 0x000000c5 (197)
Link detected: yes

From the output, you can see that the eth0 network interface is running at 100Mbps with Full Duplex enabled. Full duplex differs from half duplex (Half Duplex) in that the first provides data transfer in both directions at the same time, and the second transfers incoming and outgoing data alternately.

2. How to stop/start or restart the network interface?

To stop the network interface eth0, there is a command:

# sudo ifconfig eth0 down

The command is easy to remember, since after the name of the command itself comes the name of the interface and after the action to be performed on it (down or up).

To resume network interface eth0:

# sudo ifconfig eth0 up

To restart all network interfaces of the OS, enter the command:

# sudo /etc/init.d/networking restart

This line runs the networking bash script, which restarts the system's network interfaces.

Similarly, by analogy, all interfaces are stopped:

# sudo /etc/init.d/networking stop

And running them:

# sudo /etc/init.d/networking start

3. How to change network settings?

There are two ways to change network settings in Linux OS:
  1. use commands to assign network interface parameters;
  2. edit the configuration file containing the parameters of network interfaces.

You can set up the network using one of the above methods. These two methods are completely interchangeable. Who is more accustomed to

  1. Network setup using commands.

    To configure the network interface without getting into the jungle of the configuration file, you need to use special commands.

    To set the primary IP address and netmask for the eth0 interface:

    # sudo ifconfig eth0 192.168.0.1 netmask 255.255.255.0

    To assign an additional IP address to the eth0 interface:

    # sudo ifconfig eth0:0 10.10.0.1 netmask 255.255.255.0

  2. Network setup by editing the configuration file.

    Let's edit the configuration file /etc/network/interfaces. To display the contents of the config, type the command:

    # sudo nano /etc/network/interfaces

    If the local network to which we are connecting involves manually setting the IP address, then the contents of the configuration file should look something like this:

    iface lo inet loopback

    auto eth0
    iface eth0 inet static
    address 192.168.1.18
    netmask 255.255.0.0
    gateway 192.168.1.253

    We leave the first lines as they are, since their additional configuration is not required.

    Line auto eth0 says that the eth0 network interface should start when the OS boots.

    Second line iface eth0 inet static says that the IP address of the eth0 network interface is set manually.

    Line address 192.168.1.18 says that the eth0 network interface is assigned the IP address 192.168.1.18 (this network address is taken as an example and can be any other in its place).

    Line netmask 255.255.0.0 says the netmask is 255.255.0.0.

    Last line gateway 192.168.1.253 indicates that the network gateway is a computer with an IP address of 192.168.1.253. This line may be absent, since its presence in the configuration file depends on the settings of the local network to which the configured computer is connected.

    If the connected local network uses automatic distribution of network settings by a DHCP server, then the configuration file /etc/network/interfaces should be rendered as:

    iface lo inet loopback

    auto eth0
    iface eth0 inet dhcp

4. Additional network settings: DNS servers, MAC addresses and network interface speed.

Setting up a DNS server.

Also, in many cases, for the correct operation of the local network on the computer being configured, you will need to enter the IP address of the DNS server used.

To do this, open the configuration file with the command:

# sudo nano /etc/resolv.conf

Conclusion:

# Generated by NetworkManager
nameserver 192.168.1.253

Line nameserver 192.168.1.253 says that the computer with the IP address 192.168.1.253 is used as the DNS server.

Change the MAC address of the network card.

To temporarily change the MAC address of the eth0 network card, you need to use the command:

# sudo ifconfig eth0 hw ether 00:01:02:03:04:05

The last number is the new MAC address.

To change the MAC address permanently, you need in the configuration file /etc/network/interfaces add a line with a new MAC address to the network interface settings:

iface eth0 inet dhcp

pre-up ifconfig eth0 hw ether 00:01:02:03:04:05

Change the speed of the network interface.

To strictly set the network card speed:

# sudo ethtool -s eth0 speed 100 duplex full autoneg off

# Force network interface speed to 100Mbit and Full Duplex mode and disable auto-detection

# sudo ethtool -s eth0 speed 10 duplex half autoneg off

# Force network interface speed to 10Mbit and Half Duplex mode and disable auto-detection

Random 7 articles:

Comments

  1. Sergo
    1 November, 23:27

    thanks a lot for the article! in Linux recently, it helped a lot, can you tell me if there are two network dns-servers in the computer, one has a network dns-server 192.168.0.9, and the other has 192.168.1.9, for example, it would be correct to write
    nameserver 192.168.0.9
    nameserver 192.168.1.9
    Setevukha to whom what dns will understand?
    And is it possible to assign a name to a network card in Linux, for example, eth0 is loc, and eth1 is prov?

  2. [email protected]
    November 2, 00:07

    1. DNS can specify both, but network masks should be specified as 255.255.255.0. Then they will go to their DNS `am.

    2. I don't know about network names. I think you can, it's Linux!!

  3. Sergo
    November 2, 03:44

    turn off the interface
    ifconfig eth0 down
    give a command
    ifrename -i eth0 -n new_name (e.g. local)
    ifconfig local up
    then in your Linux it will probably be necessary to change some eth0 to local in the /etc/network/interfaces file, I just have an alt, and this file does not exist at all, I have /etc/net/ifaces/folders_with_interfaces, and now I need the eth0 folder rename to local, and then
    service network restart :)

  4. [email protected]
    November 2, 08:45

    Will need to add to the article, thanks))

  5. gpns
    14 May, 17:36

    I think it's worth correcting the line: sudo ifconfig eth0:0 10.10.0.1 netmask 255.255.255.0
    alias cannot have /24 mask (255.255.255.0), this is not an error, because in any case, the eth0:0 interface will be assigned the mask /32 (255.255.255.255)
    In your case it would be: sudo ifconfig eth0:0 10.10.0.1/32

  6. [email protected]
    16 May, 12:02

    gps: I think it's worth correcting the line: sudo ifconfig eth0:0 10.10.0.1 netmask 255.255.255.0 in any case, the eth0:0 interface will be given the mask /32 (255.255.255.255) In your case it will be: sudo ifconfig eth0:0 10.10.0.1/32

    Damn, you turned my whole mind upside down. You will have to redo the network interface settings on the computer, which have been working for almost 2 years.
    Why then the team ifconfig the mask that I set is shown?

  7. HydruS
    13 September, 23:32

    Plain language! Clear and understandable! Thank you so much!
    P.S. Only in command entry listings would it be nice to make a font where 0 is visually different from O.

  8. [email protected]
    14 September, 18:34

    HydroS: P.S. Only in command entry listings would it be nice to make a font where 0 is visually different from O.

    Thanks, I'll take it into account. Although there seems to be a difference, to the point)

  9. andrey
    18 September, 23:50

    thanks for your site. I like! everything is intelligible and understandable
    I have a question for you. if possible, please tell me how to set up the network so that the LAN and DSL connection work at the same time.
    I can't figure out how to do this???

  10. [email protected]
    20 September, 07:18

    andrey: thanks for your site. I like! Everything is intelligible and understandable, I have a question for you. if possible, please tell me how to set up the network so that the LAN and DSL connection work at the same time.

    To be honest, I have not come across DSL connections for a long time. Tell me more:
    1. What is the local network? Behind the modem or on another network?

  11. andrey
    20 September, 18:38

    the most common connection is the city network
    computer connected via network card
    Internet access is connected via a DSL connection

  12. [email protected]
    21 September, 17:22

    andrey: the most common connection is a city network the computer is connected via a network card Internet access is connected via a DSL connection

    In my opinion, you need to configure the modem itself. Look to the side Dual PPPOE
    I did something similar on the D-Link DIR -320 router, but not once on the modem.

  13. andrey
    21 September, 18:22

    Thanks!!! I will look for!

  14. Serpent22
    November 3, 06:21

    To the words about DSL through a local network: I took a lot of steam, rummaged through a bunch of mana (I have Debian Lenny) and in order to save other people from the same rake I’ll say that pppoeconf does not help everyone, for example, for me, the Internet appeared for a couple of seconds and disappeared miraculously . Configs, logs did not help. But after two weeks and a pile of torn hair, I came across a simple ifconfig ppp0 mtu 1372 command. I hope this helps someone. I spoke out, it became easier)))

  15. Nick
    7 December, 09:17

    Good afternoon, in my etc folder there is neither a network folder nor a net folder, it costs centos 5.7, tell me what to do

  16. Marina
    27 December, 21:12

    Hello, this problem happened. The computer is connected to the Internet through a router .. The problem is that some sites do not open - it writes a dns conversion error .. What needs to be done. for everything to work properly? Thanks in advance!!

  17. papick
    30 July, 17:05

    Artem: 2 network cards. on one screw network with the domain. in the second, an adsl modem with a PPPoE connection is plugged in. how to make it possible to work on the network and on the internet ?!

    for example, write routing rules on the machine in such a way that packets destined for the local network are sent to etn0, and all the rest to etn1
    but this topic is beyond the scope of this article.

  18. Compomer
    29 August, 03:01

    Quite a good article. Thanks a lot

  19. valera
    21 January, 07:20

    I’ve only been on linux for the 3rd month, but I’ve already tried 17 pieces, but no one wants to connect dsl \ immediately breaks the LAN \ left zorin and put ALT - I work like homework, but for the Piggy network \ 7 - demolished like everyone else \.if- If I had a network on ALT, then until the end of my life ... I've only mastered the computer for 7 years - it's already old.