Рестарт сетевого интерфейса linux

How to Restart Network in Ubuntu

Here are 6 ways you can restart the network in Ubuntu and other Linux distros. Also learn to refresh wireless network connection in Ubuntu Linux.

Restart the network in Ubuntu via the command line

If you are using the Ubuntu server edition, you are already in the terminal. If you are using the desktop edition, you can access the terminal using Ctrl + Alt + T keyboard shortcut in Ubuntu.

Now you have several commands to restart the network in Ubuntu. Some (or perhaps most) commands mentioned here should also be applicable for restarting the network in Debian and other Linux distributions.

1. Restarting the Network Manager Service

This is the easiest way to restart your network using the command line. It’s equivalent to the graphical way of doing it (restarts the Network-Manager service).

sudo systemctl restart NetworkManager.service

The network icon should disappear for a moment and then reappear.

2. nmcli

This is yet another tool for handling networks on a Linux machine. It is a pretty powerful tool that I find very practical. Many sysadmins prefer it since it is easy to use. This tool is a part of the NetworkManager package.

There are two steps to this method: turning the network off and then turning it back on.

sudo nmcli networking off

The network will shut down and the icon will disappear. To turn it back on:

You can check out the man page of nmcli for more options.

3. nmtui

This is another method often used by system administrators. It is a text menu (in a Terminal User Interface) for managing networks right in your terminal. It is also a part of the Network Manager tool.

This should open up the following menu:

The interface of nmtui

Note that in nmtui, you can select another option by using the up and down arrow keys.

Select Activate a connection:

Activate a connection

Press Enter. This should now open the connections menu.

The list of connections

Here, go ahead and select the network with a star (*) next to it. In my case, it’s MGEO72.

Select the interface highlighted with a star

Press Enter. This should deactivate your connection.

Connection deactivated

Select the connection you want to activate and press Enter. This should activate the desired connection.

Activate again by selecting desired connection

Press Tab twice to select the button, and exit from the main menu. This is how you can restart a connection with nmtui.

4. ifup & ifdown

These commands handle a network interface directly, changing its state to one in which it either can or can not transmit and receive data. It’s one of the must-know networking commands in Linux.

To shut down all network interfaces, use ifdown and then use ifup to turn all network interfaces back on.

Читайте также:  How to get cpu temperature in linux

A good practice would be to combine both of these commands:

sudo ifdown -a && sudo ifup -a

Note: This method will not make the network icon in your systray disappear, and yet you won’t be able to have a connection of any sort.

That’s it! You have successfully restarted your network.

Restart the network in Ubuntu graphically

This is, of course, the easiest way of restarting the network for Ubuntu desktop users. If this one doesn’t work, you can of course check the command line options mentioned in the previous section.

NM-applet is the system tray applet indicator for NetworkManager. That’s what we’re going to use to restart our network.

First of all, check out your top panel. You should find a network icon in your system tray (in my case, it is a Wi-Fi icon, since that’s what I use).

Go ahead and click on that icon (or the sound or battery icon). This will open up the menu. Select “Turn Off” here.

Restart network in Ubuntu

The network icon should now disappear from the top panel. This means the network has been successfully turned off.

Click again on your systray to reopen the menu. Select “Turn On”.

Restarting network in Ubuntu

Congratulations! You have now restarted your network.

Bonus Tip: Refresh the available network list

Suppose you are connected to a network already but you want to connect to another network. How do you refresh the WiFi to see what other networks are available? Let me show you that.

Ubuntu doesn’t have a ‘refresh wifi networks’ option directly. It’s sort of hidden.

You’ll have to open the setting menu again and this time, click on “Select Network”.

Refresh wifi network list in Ubuntu

Now, you won’t see the list of available wireless networks immediately. When you open the networks list, it takes around 5 seconds to refresh and show up other available wireless networks.

Select another wifi network in Ubuntu

And here, you can select the network of your choice and click «Connect». That’s it.

Wrapping Up

Restarting your network or connection is something that every Linux user has to go through at some point in their experience. These tools can come in handy for doing the same.

But, if you’re stranded with not finding any wireless interface to connect with (no Wi-fi hardware detected), you can refer to this article.

You can also check out some of the most important networking commands in Linux:

We hope that we have helped you with plenty of methods for handling such issues!

What do you use to restart/handle your network? Is there something we missed? Leave us a comment below.

Источник

How to Restart Network on Ubuntu 20.04

There are various situations where you may have to restart the network on Ubuntu. It may be because the network settings were changed. It may be because the network connection is acting weird. Generally, whenever there’s a problem with the system, a common treatment is performing a reboot. However, if it’s a problem related to the network, then it’s possible to just restart the network.In this guide, check out how to restart the network on Ubuntu 20.04. There are various methods you can follow to restart the network on Ubuntu. It can be performed directly from the GUI or through the terminal. Depending on your preference, follow the one that suits you.

Читайте также:  Linux где файлы сервисов

Restart network from GUI

In this section, I’ll be assuming that you’re using Ubuntu 20.04 with the default GNOME desktop.

Restart network from the desktop

Click on the top-right network icon on the screen.

Select the network connection and press “Turn Off”. It will disable the network connection.

To enable it again, go through the same process. This time, there’ll be a different option “Connect”. Click “Connect” to re-establish the network connection.

Restart network from GNOME Settings

You can also do this directly from the GNOME “Settings”.

From the left panel, select “Network”.

Disable and enable the connected network(s).

Restart network from CLI

When working with the CLI, there are multiple ways of taking action. We can take action on the network manager service or use other tools like nmcli, ifup, nmtui, etc.

Restart network manager service

This is one of the easiest ways of restarting the network service. It’s equivalent to the graphical method demonstrated above.

Fire up a terminal and run the following command.

Restart network service using systemd

Systemd offers an array of system components to the system. Part of it is handling the services. The previous method is only an alternative one of this method. Systemd is directly told to restart the service rather than going through any hoops.

Restart network using nmcli

The nmcli tool is a powerful tool for managing the network connection on Linux machines. It’s a popular one among system admins because of its ease of use.

First, turn off the network connection.

Restart network using ifup and ifdown

The ifup and ifdown commands handle a network interface directly. It’s one of the most basic networking commands on Linux. The ifdown command turns off all network interfaces and the ifup command turns them on.

The ifup and ifdown commands come with the ifupdown package. By default, it doesn’t come with Ubuntu. Thankfully, it’s directly available from the official Ubuntu repo. Install them right away.

Once the installation is complete, perform the network restart.

It’s a good practice to combine both commands in a single line.

Restart network using nmtui

The nmtui tool is yet another network management tool that’s widely popular among system admins. Unlike the other CLI tools, it offers an interactive way of managing network connections that’s similar to the GUI method.

In the case of Ubuntu 20.04, it comes by default. Launch the tool.

To navigate the tool, use the arrow keys. Select “Activate a connection”.

You’ll land on a screen with a list with all the network connections. Select the appropriate one and select “Deactivate”.

Once deactivated, activate the connection.

The network has been successfully restarted. Quit the application.

Restart network using IP command

The ip command is a powerful way of managing the network connections on Linux. It can be used for restarting the network connection. This method is applicable to any Linux distro.

To work with the ip command, first, we need to know the target network interface. Use the following command for the network interface.

In my case, the target network interface is enp0s3. Let’s restart the network.

Final thoughts

Restarting the network is a common solution to various network-related problems. If it didn’t yet solve the issue, then the next recommended action is restarting the system. If the problem persists, then it’s worth investigating further.

Читайте также:  Linux command line parameters

Interested in learning more about network configuration? Check out this guide on Ubuntu 20.04 network configuration.

About the author

Sidratul Muntaha

Student of CSE. I love Linux and playing with tech and gadgets. I use both Ubuntu and Linux Mint.

Источник

Как перезагрузить сеть в Ubuntu?

img

Вы используете систему на основе Ubuntu и просто не можете подключиться к своей сети? Вы будете удивлены, сколько проблем можно исправить простым перезапуском.

Nmtui

Перезагрузка сети в Ubuntu с помощью командной строки

Если вы используете Ubuntu Server Edition, вы уже находитесь в терминале. Если вы используете настольную версию, вы можете получить доступ к терминалу с помощью сочетания клавиш Ctrl + Alt + T в Ubuntu.

Теперь у вас есть несколько команд для перезагрузки сети в Ubuntu. Некоторые (или, возможно, большинство) упомянутые здесь команды должны быть применимы для перезапуска сети в Debian и других дистрибутивах Linux.

Network manager service

Это самый простой способ перезагрузить сеть с помощью командной строки. Это эквивалентно графическому способу сделать это (перезапускает службу Network-Manager).

sudo service network-manager restart

Значок сети должен на мгновение исчезнуть, а затем снова появиться.

systemd

Второй способ – это команда systemctl, которая гораздо более универсальна, чем service.

sudo systemctl restart NetworkManager.service

Значок сети снова должен исчезнуть на мгновение. Чтобы проверить другие параметры systemctl, вы можете обратиться к его справочной странице.

nmcli

Это еще один инструмент для работы с сетями на компьютере с Linux. Это довольно мощный инструмент, и многие системные администраторы предпочитают его, поскольку он прост в использовании.

Этот метод состоит из двух шагов: выключить сеть, а затем снова включить ее.

sudo nmcli networking off

Сеть отключится и значок исчезнет. Чтобы включить его снова:

Вы можете проверить справочную страницу nmcli для большего количества вариантов.

ifup & ifdown

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

Чтобы закрыть все сетевые интерфейсы, используйте ifdown, а затем используйте ifup, чтобы снова включить все сетевые интерфейсы.

Хорошей практикой было бы объединить обе эти команды:

sudo ifdown -a && sudo ifup -a
nmtui

Это еще один метод, часто используемый системными администраторами. Это текстовое меню для управления сетями прямо в вашем терминале.

Это должно открыть следующее меню:

Nmtui

Обратите внимание, что в nmtui вы можете выбрать другой вариант, используя клавиши со стрелками вверх и вниз.

Выберите Activate a connection

Nmtui

Нажмите Enter. Должно открыться меню с соединениями.

Nmtui

Далее, выберите сеть со звездочкой (*) рядом с ней и нажмите Enter. Это должно деактивировать это соединение.

Nmtui

Выберите соединение, которое вы хотите активировать

Nmtui

Нажмите Enter, соединение должно снова стать активным.

Nmtui

Дважды нажмите Tab чтобы выбрать пункт Back

Nmtui

Нажмите Enter, это вернет вас в главное меню.

Nmtui

Nmtui

Это должно закрыть приложение и вернуть вас в ваш терминал.

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

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

Чтобы открыть окно управления сетью, щелкните правой кнопкой мыши значок сети в правом верхнем углу и найдите сетевое соединение, которое вы хотите перезагрузить, затем нажмите «Выключить».

GUI

Значок сети исчезнет. Чтобы снова включить сеть, щелкните левой кнопкой мыши в правом верхнем углу стрелку вниз, найдите сетевой интерфейс и нажмите «Подключиться».

Источник

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