Restart one interface linux

How to Restart Network Interfaces on Linux?

After making changes in the configuration of the network interfaces, it is recommended to restart the network interface. The network interface is the device responsible for connecting the network and the computer.

In this blog, different methods of restarting the network interface have been demonstrated for various Linux distributions, and the blog contents are:

  • For Debian-based Linux Distributions
  • For RHEL-based Linux Distributions
  • For Arch-based Linux Distributions
  • For Slackware Linux Distributions
  • For Gentoo Linux Distributions
  • For Alpine Linux Distributions

Let us start with the Ubuntu-based Distributions.

How to Restart Network Interfaces on Debian-based Linux Distributions?

In Debian-based Linux distributions, the network interfaces can be managed with the “NetworkManager”. To restart the Network interfaces on Linux, we will use the command:

$ sudo systemctl restart NetworkManager

The service has been restarted, and the status of the NetworkManager can be verified using the command:

$ sudo systemctl status NetworkManager

The Network Manager is in active status.

Alternative Method: Restart the Network Interfaces on Debian/Ubuntu with GUI

Another more convenient method is to restart the network interface with the GUI method. For it, launch the network manager with the nmtui command:

The application’s menu will be displayed on the screen:

Choose “Activate a connection” and then click on “OK”:

Now, select the interface and click on “Deactivate”:

Then, again click on “Activate” to restart the connection:

Then, close the nmtui tool by clicking on “Quit”:

The network interface has been restarted.

How to Restart Network Interfaces on RHEL-based Linux Distributions?

In the RHEL-based Linux distributions, including CentOS, the network interfaces can be managed either by using the nmcli command utility or the systemctl command utility. If the nmcli command is supposed to use, then execute the command to stop the service:

$ sudo nmcli networking off

After stopping the service, start it again with the command:

Similarly, the network manager can be restarted with using the systemctl command:

$ sudo systemctl restart NetworkManager.service

How to Restart Network Interfaces on Arch-based Linux Distributions?

In the Arch-based Linux distributions, including the Manjaro, the network interface can be restarted using the command:

$ sudo systemctl restart systemd-networkd.service

How to Restart Network Interfaces on Slackware Linux Distribution?

If the Slackware Linux distribution is being used, use the command:

$ sudo /etc/rc.d/rc.inet1 restart

How to Restart Network Interfaces on Gentoo Linux Distribution?

In Gentoo, the specific network interface can be restarted simultaneously. For example, we will restart the eth0 network interface, then use the command:

Читайте также:  Internal command in linux

How to Restart Network Interfaces on Alpine Linux Distribution?

To restart the network interface in the Alpine, run the command:

$ service networking restart

By the above commands, users can restart the network interfaces on different Linux distributions.

Conclusion

To restart the network interface on Linux, we must be familiar with the network service backing up the system. For instance, to restart the network interfaces on Debian/Ubuntu-based Linux distributions, use the command “sudo systemctl restart NetworkManager”.

This post has also presented a list of commands to restart the network interfaces on various Linux distributions.

Источник

How to «restart» particular network interface on RHEL?

In RHEL, instead of using service network restart command, how can i restart a particular network interface, lets say «eth1», with only one command. «Only one command» because that is the only interface where my ssh is working on also. So if i’m about to use: ifdown and then ifup , i will never be able to hit the ifup command as my ssh has been terminated once after ifdown eth1 command. So there should be a single command which allows me to altogether bring down and then bring up the interface which is serving my current ssh connection. So i do not need to worry about connection totally lost to my server. Any idea please?

4 Answers 4

As a single command. The && just runs one command, then the other if the first command succeeds. If you are required to use sudo make sure you use it before each command:

sudo ifdown eth1 && sudo ifup eth1 

As long as your interface is configured to have the neccessary IP and route to match the current configuration, your ssh connection won’t drop.

If you’re worried about using it on a production server that you don’t have another method of access to, that’s understandable. Though the command does exactly what you want, it’s very easy to have a configuration error that is only noticed after running this command. If you don’t have an alternate method of access (for example, out-of-band console, or SSHD running on another interface), it’s safest not to do this.

I use this technique often to perform a ‘restart’ of the interface, but I generally have a backup method of access available just in case when I do it.

Might I suggest ifdown eth1 && ifup eth1 , this way ifup doesn’t run unless ifdown was successful, whereas with a ; ifup will run regardless of how ifdown returned.

Читайте также:  Create mount points linux

You can ‘restart’ one interface by issuing following commands:

After that, you can verify that your new configuration is active

Sorry but i need .. «Only one command» because that is the only interface where my ssh is working on also. So if i’m about to use: ifdown and then ifup, i will never be able to hit the ifup command as my ssh has been terminated once after ifdown eth1 command. So there should be a single command which i can bring down and then bring up the interface which is serving my current ssh connection. So i do not need to worry about connection lost to my server.

You could make them a shell script and run that, your ssh-session should not get terminated, even though there will be short network blackout. Other option is to run that script inside of screen-session, where it will be executed to the end, even if your ssh-session would fail.

Are you trying to change the IP address (or any interface parameter for that matter) of an interface on a remote machine? If the answer is yes, then you can try one of the following:

A cool method is by using the screen utility to create a session by just typing ‘screen’. Once you restart the network service and your SSH connection drops, use screen -ls to check that the session is still active (but detached) and screen -r to resume the detached session. This will work in case there is no error in your interface configuration file, i.e. the network service is restarted successfully.

You can also use the following trick:

$ cp -v current_conf_file current_conf_file.bak $ echo "mv current_conf_file.bak current_conf_file && service network restart" | at now+10min 

And proceed with editing your interface configuration file and restarting the network service. In case of a mistake, you just have to wait 10 minutes, in order for the previous configuration to be reapplied and the network service to be restarted.

Источник

Перезапуск сети в 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. Можно сразу же использовать ещё для наших целей. Просто отключите, а затем включите сеть обратно следующими командами:

Читайте также:  Linux команда удалят файл

sudo nmcli networking off

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

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

Команды ifup и ifdown

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

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

Выводы

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

Обнаружили ошибку в тексте? Сообщите мне об этом. Выделите текст с ошибкой и нажмите Ctrl+Enter.

Источник

How to restart network interfaces on Linux

restart network interface

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.

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?

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.

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.

Источник

Оцените статью
Adblock
detector