Linux restart one interface

Перезапуск сети в Ubuntu

В Ubuntu и Debian инициализацией сетевых интерфейсов и настройкой сети занимается специальная сетевая служба — networking. Информация о конфигурации сетевых интерфейсов хранится в файле /etc/network/interfaces.

Если вы что-либо измените в этом файле, нужно будет перезапустить сеть, чтобы применить изменения. В этой статье мы рассмотрим как выполнить перезапуск сети Ubuntu 16.04.

Перезагрузка сети в Ubuntu

Можно, конечно, выполнить полную перезагрузку компьютера, но это не совсем удобно если можно просто перезапустить сеть Ubuntu. Для перезапуска сети используйте следующую команду:

sudo service networking restart

В современных дистрибутивах уже давным давно используется система инициализации Systemd, поэтому можно использовать команду systemctl вместо команды service:

sudo systemctl restart networking.service

Кроме того, можно перезапустить NetworkManager, это тоже помогает, если сеть настроена через него:

sudo systemctl restart NetworkManager

Перезапуск сети в NetworkManager

Чаще всего, для управления сетью в современных дистрибутивах используется программа Network Manager. Можно сразу же использовать ещё для наших целей. Просто отключите, а затем включите сеть обратно следующими командами:

sudo nmcli networking off

sudo nmcli networking on

После отключения сети значок NetworkManager пропадёт с панели, а потом снова появится после включения. Аналогично, вы можете использовать NetworkManager в графическом интерфейсе. Кликните по его иконке, выберите нужное сетевое подключение и нажмите Выключить:

Затем включите его обратно.

Команды ifup и ifdown

Эти команды работают на более низком уровне, они управляют непосредственно самими сетевым интерфейсами. Для перезапуска сети мы можем отключить все интерфейсы, а затем включить обратно:

Вы не увидите никаких изменений в графическом интерфейсе, но когда сетевой интерфейс будет отключён, вы не будете иметь доступа к интернету.

Выводы

Как видите, не всегда обязательно перезагружать компьютер после изменений настроек, в большинстве случаев достаточно перезапустить только нужный сервис. Надеюсь, эта информация была вам полезной.

Источник

How to restart network interfaces on Linux

O nce you make changes in the network interface, they affect the network services manager of your system. To enable the system or machine to connect to the network, one needs to restart the network interface to apply the changes without rebooting your server.

This article will guide you on restarting the network interface in various Linux distributions.

Читайте также:  How to create new user in linux

Note: When running SSH/ VNC or other remote-based sessions, you should take precautions since restarting the network interface or service can result in network disconnectivity, resulting in connection loss.

We will handle the following topics.

  • What is a Network Interface?
  • How to List Network Interfaces on Linux
  • How to Turn ‘ON’ or ‘OFF’ Network Interfaces
  • How to Restart Network Interfaces on Linux
  • How to Check the Status of Network Services in Linux

What is a network interface?

A network interface refers to the point of connection between a computer and the network. It can be either software (especially with Virtual machines) or a hardware component. When dealing with network interfaces, there is one term that you will likely come across – NIC (Network Interface Card).

A Network Interface Card is a circuit board chip inserted/ soldered on the motherboard allowing your computer to connect to the internet. If you have worked with many earlier Desktop computers (even some today), you know that most cannot connect to a WiFi network, and that’s because they don’t have a wireless NIC. You are advised to purchase a USB Network Adapter that will act as your wireless interface connection in such a situation.

How to list network interfaces on Linux

You can use different ways to see all the available network interfaces on your system. You can use the GUI or the Command-line (CLI). In this post, we highly recommend using the Terminal (CLI) since the GUI settings app might not list specific interfaces.

We will use the following commands to list network interfaces on our system.

1. The ifconfig command

This command has long been used to list and configure network interfaces on Linux. Unfortunately, this command is marked as ‘deprecated’ and does not come pre-installed in certain distributions like recent Debian and Kali Linux releases.

To list network interfaces using ifconfig, execute the command below.

ifconfig command

Tip: If you get an error like ‘ifconfig command not found,‘ install the ifconfig utility with the command below.

In other systems like Debian, you will still get the error since the ifconfig will install in the /sbin path. Therefore, you will need to execute ifconfig with the syntax below.

2. The IP command

The IP command is the successor of the ifconfig command. You can use it to list network interfaces and configure routing and tunnels. This utility comes pre-installed in all Linux distributions.

To list network interfaces with the IP command, execute the command below.

IP command

3. The netstat command

Another utility you can use to list all network interfaces on your system is netstat. Execute the command below.

netstat command

4. The nmcli command

nmcli is a command-line utility that you can use to list and configure network interfaces. Execute the command below to list all interfaces present on your system.

nmcli command

How to Turn ‘ON’ or ‘OFF’ Network Interfaces

To turn on or off your network interface, we will use the ifconfig commands as shown below.

Note: Turning OFF an interface connection will disrupt/ close any active SSH connections.

Before executing any of the commands below, identify the network interface you want to turn ON or OFF. Use any commands discussed in the previous section to list the network interfaces on your system.

Читайте также:  Берег работа над ошибками

For example, our computer is connected to the internet via ethernet, which is listed as enp0s25.

    Turn ON a network interface.

The enp0s25 is the network interface.
To turn OFF the network interface, we will use the following command.

The enp0s25 is the network interface.

How to restart network interfaces on Linux

The following are methods on how to restart network interfaces in different distributions.

1. Debian /Ubuntu

To restart the network interface in Debian-based distributions using ‘init.d,’ execute the commands below.

To stop or start using the below commands.

To restart the network interface in Debian using systemctl, execute the command below.

Restart network service -ac Debian.

2. RHEL-based OS (centos, Fedora, etc.)

To restart a network interface in RHEL-based operating systems, you can use systemctl or the nmcli utility.

Run the commands below to start and stop the network interface using nmcli.

Use the following commands to restart the network interface in RHEL-based distributions using the systemctl command.

Restart network service RHEL

3. Slackware Linux

To restart the network interface in Slackware Linux use.

4. Gentoo

Type the command below to restart the network interface in Gentoo for a particular network interface.

5. Alpine Linux

To restart the network interface in Alpine Linux, run the following commands.

6. Arch Linux

To restart the network interface in Arch Linux, type the command below.

How to check the status of network services in Linux

Different Linux distributions have varying commands for checking network services. This article will explore some of the commands used to check the status of network services in various Linux distributions.

1. Debian/Ubuntu

Run the command below to check for network services status in Debian/ Ubuntu.

2. RHEL-based OS (centos, Fedora, etc.)

Use the command below to check the network service status in RHEL-based operating systems.

3. Suse/OpenSUSE

To check the network service in OpenSUSE, run the command below.

4. Alpine Linux

Run the following command to check the network service status on Alpine Linux.

Conclusion

This article has given you a step-by-step guide on how to restart and list the network interfaces on your system. We have tried to cover all the most popular Linux distributions. Is there any Linux distribution that you feel we left out? Or is there any command that throws an error on your system? Please, don’t hesitate to notify us in the comments below, and we will do our best to assist you.

Источник

How to restart Network Interface / Network Adapter on Linux & Windows Cloud Servers

Once you make changes in the server network configuration file, then require to restart the server networking service in order to reflect the changes.

This guide will describe the steps to restart the network interface or network adapter in the Linux and Windows servers.

Restarting Network interface/adapter in Linux OS

Ubuntu / Debian

Use the following command to restart the server networking service.

Читайте также:  Как заправить картридж кэнон лбп 2900

Once this is done, use the following command to check the server network status.

Ubuntu 17.10 and higher versions use NetPlan as the default network management tool and its configuration files are written in YAML syntax with a .yaml file extension .

Run the below command to update networking and then any changes that have been made to the network will take effect:

AlmaLinux

Use the following command to restart the server networking service.

Once this is done, use the following command to check the server network status.

Rocky Linux

Use the following command to restart the server networking service.

Either of the below commands can be executed to check the status of the networking service.

CentOS 8

Use the following command to restart the server networking service.

Either of the below commands can be executed to check the status of the networking service.

CentOS 7

Use the following command to restart the server networking service.

The status of the networking service can be checked by making use of any of the below commands.

CentOS 6

Use the following command to restart the server networking service.

Once this is done, use the following command to check the server network status.

Windows OS

Using the Enable/Disable mode of network adapter

Click on the Windows key to open start and search Settings and go to the Network and Internet then click on Change adapter option which is shown in the below image.

Then will get the below page:

Right-click the Ethernet device and click on Disable option.

Again, Right-click the Ethernet device and click on enable option.

Once this is done, Right-click the Ethernet device and click on status .

Using the netsh command

In Windows OS, the command line method involves using the netsh command for resetting the network and TCP/IP stack.

Go to Start and type CMD in the search window.

Once opened the Command Prompt , the command for restarting the network interface, as provided below, can be executed.

Regularize the networking process as indicated in the message after restarting the server.

In addition to the above command, may also use the command which resets the TCP/IP stack. The command is as follows.

The output will be as follows:

Using the Network Reset option (Windows 10/11)

The reset button method can be used in Windows 10 & 11 versions by which the user can restart the Network interface. The steps for this are given below.

Click on Windows Start Menu button and then select Settings .

From the Settings option, select Network & Internet option.

Here you would be able to see the adapter options i.e Advanced Network Settings , from which you can click on Network Reset option.

Click on the Reset Now button on the right side of Network reset option and you will be prompted for the confirmation. Choose Yes for proceeding with resetting the network settings.

Once clicked on Yes , the network adapter will start to reset and you will be able to restart the network interface.

Источник

Поделиться с друзьями
КомпСовет
Adblock
detector