Restart network manager windows

How to Restart a Network in Ubuntu [Beginner’s Tip]

Last updated October 29, 2020 By Sergiu 12 Comments

You’re using an Ubuntu-based system and you just can’t seem to connect to your network? You’d be surprised how many problems can a simple restart fix.

In this article, I’ll go over multiple ways you can restart network in Ubuntu and other Linux distributions, so you can use whatever suits your needs. The methods are basically divided into two parts:

Restart network in Ubuntu using command line

If you are using 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 at your disposal to restart network in Ubuntu. Some (or perhaps most) commands mentioned here should be applicable for restarting network in Debian and other Linux distributions as well.

1. 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).

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

2. systemd

The service command is just a wrapper for this method (and also for init.d scripts and Upstart commands). The systemctl command is much more versatile than service. This is what I usually prefer.

The network icon (again) should disappear for a moment. To check out other systemctl options, you can refer to its man page.

3. 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.

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

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.

4. ifup & ifdown

This commands handle a network interface directly, changing it’s 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.

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

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.

This is another method often used by system administrators. It is a text menu for managing networks right in your terminal.

This should open up the following menu:

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

Select Activate a connection:

Press Enter. This should now open the connections menu.

Читайте также:  Экранная клавиатура windows server 2012

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

Press Enter. This should deactivate your connection.

Select the connection you want to activate:

Press Enter. This should reactivate the selected connection.

Press Tab twice to select Back:

Press Enter. This should bring you back to the nmtui main menu.

Select Quit:

This should exit the application and bring you back to your terminal.

That’s it! You have successfully restarted your network

Restart 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.

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”.

Congratulations! You have now restarted your network.

Bonus Tip: Refresh 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”.

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.

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.

We hope that we 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.

Like what you read? Please share it with others.

Настройка Network Manager в консоли

NetworkManager — популярный инструмент управления сетевыми подключениями в Linux, имеет удобный графический интерфейс как для Gnome, так и для KDE, но бывают ситуации когда окружение рабочего стола не запускается, и нужно поднимать сеть из консоли, или нужно настроить сеть на сервере где не установлено рабочее окружение.

В этой инструкции будет рассмотрена настройка Network Manager в консоли с помощью утилиты nmcli. С настройкой в графическом интерфейсе вы разберетесь без каких-либо инструкций, поэтому была выбрана именно эта тема. Также поговорим о том, как посмотреть информацию о сетевых интерфейсах в системе.

Собираем информацию о системе

Чтобы получить информацию обо всех установленных в системе сетевых интерфейсах используйте команду:

Для просмотра статистики переданных и полученных пакетов для интерфейса, например, enp24s0, наберите:

ip -s link show enp24s0

А чтобы посмотреть таблицу маршрутизации:

ip route show match 0/0

Синтаксис и опции nmcli

Утилита nmcli — многофункциональный и гибкий инструмент командной строки для настройки сети с помощью Network Mananger из консоли. Сначала рассмотрим ее синтаксис:

Читайте также:  Как удалить service linux

$ nncli опции объект команда

Чаще всего в nmcli мы будем использовать такие объекты:

  • device — управление сетевыми интерфейсами;
  • connection — управление соединениями;
  • networking — управление сетью в целом;
  • general — показывает состояние всех сетевых протоколов и NetworkManager в целом;
  • radio — управление сетевыми протоколами, wifi, ethernent и т д.

Команды для каждого объекта разные, а опции нам не будут интересны. Дальше рассмотрим примеры nmcli network manager.

Настройка сети с помощью nmcli

1. Запустить NetworkManager

Первым делом нужно запустить NetworkManager из консоли:

sudo systemctl start NetworkManager

Теперь смотрим состояние интерфейсов с помощью nmcli:

nmcli general status

Еще мы можем посмотреть имя хоста:

nmcli general hostname

Получаем состояние интерфейсов

nmcli device status

2. Список подключений

Теперь самое интересное, управление сетью nmcli. Смотрим список доступных подключений:

nmcli connection show

Здесь вы можете видеть одно проводное подключение для интерфейса enp24s0. С помощью следующей команды можно посмотреть информацию о нём:

nmcli connection show «Проводное соединение 2»

3. Управление подключениями

Чтобы подключится к сети с помощью нужного подключения используйте команду up:

nmcli connection up «Проводное соединение 2»

Команды можно сокращать, например:

nmcli conn up «Проводное соединение 2»

А для деактивации подключения используйте команду down:

nmcli conn down «Проводное соединение 2»

4. Создание DHCP соединения

Чтобы создать новое подключение используйте команду add. Например создадим новое подключение с именем dhcp:

nmcli connection add con-name «dhcp» type ethernet ifname enp24s0

Команде надо передать параметр type — тип устройства, в нашем случае ethernet (Проводное соединение), а также ifname — название сетевого интерфейса, в этом примере enp24s0. По умолчанию используется тип подключения DHCP, поэтому больше ничего настраивать не надо и вы можете уже активировать это подключение как описано выше.

5. Создание соединения с статическим адресом

Для статического подключения настроек больше, вам надо передать команде add ip адрес, который будет использоваться в качестве основного в параметре ip4, а также шлюз с помощью параметра gw4:

nmcli connection add con-name «static» ifname enp2s0 autoconnect no type ethernet ip4 192.168.0.210 gw4 192.168.0.1

6. Настройка подключения

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

nmcli conn modify «static» ipv4.dns 8.8.8.8

И ещё один DNS сервер с помощью оператора +:

nmcli conn modify «static» +ipv4.dns 8.8.4.4

Для добавления дополнительной информации в поле используйте символ +. Например, вот так можно добавить еще один ip адрес:

nmcli conn modify «static» +ipv4.addresses 192.168.0.240/24

Обратите внимание, что IP адрес должен быть из той же подсети, что и ваш шлюз иначе может ничего не работать. Теперь можете активировать подключение:

nmcli connection up static

7. Настройка Wifi

В графическом интерфейсе это делается одной галочкой, здесь одной командой. Смотрим состояние wifi:

nmcli radio wifi

nmcli radio wifi on

nmcli radio wifi off

Такой командой можно посмотреть список доступных сетей wifi:

nmcli device wifi list

Команда для подключения к новой сети wifi выглядит не намного сложнее. Например, давайте подключимся к сети TP-Link с паролем 12345678:

nmcli device wifi connect «TP-Link» password 12345678 name «TP-Link Wifi»

Если всё прошло хорошо, то вы получите уже привычное сообщение про создание подключения с именем TP-Link Wifi и это имя в дальнейшем можно использовать для редактирования этого подключения и управления им, как описано выше.

Выводы

Как видите, все очень просто и быстро. Настройка network manager в консоли выполняется в пару команд, достаточно только их запомнить или где-нибудь написать, чтобы вы могли выполнить управление сетью nmcli когда это понадобится.

Читайте также:  Microsoft bob для windows 10

Restart-Net Adapter

Restarts a network adapter by disabling and then re-enabling the network adapter.

Syntax

Description

The Restart-NetAdapter cmdlet restarts a network adapter by disabling and then re-enabling the network adapter. This may be needed for certain properties to take effect in a physical network adapter or to put the network adapter into a known state.

Examples

Example 1: Restart the specified network adapter

This command restarts the network adapter named Ethernet 2.

Parameters

Runs the cmdlet as a background job. Use this parameter to run commands that take a long time to complete. The cmdlet immediately returns an object that represents the job and then displays the command prompt. You can continue to work in the session while the job completes. To manage the job, use the *-Job cmdlets. To get the job results, use the Receive-Job cmdlet. For more information about Windows PowerShellВ® background jobs, see about_Jobs.

Type: SwitchParameter
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

Runs the cmdlet in a remote session or on a remote computer. Enter a computer name or a session object, such as the output of a New-CimSession or Get-CimSession cmdlet. The default is the current session on the local computer.

Type: CimSession [ ]
Aliases: Session
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

Prompts you for confirmation before running the cmdlet.

Type: SwitchParameter
Aliases: cf
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

Indicates that the cmdlet includes both visible and hidden network adapters in the operation. By default only visible network adapters are included. If a wildcard character is used in identifying a network adapter and this parameter has been specified, then the wildcard string is matched against both hidden and visible network adapters.

Type: SwitchParameter
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

Specifies the input to this cmdlet. You can use this parameter, or you can pipe the input to this cmdlet.

Type: CimInstance [ ]
Position: Named
Default value: None
Accept pipeline input: True
Accept wildcard characters: False

Specifies an array of network adapter interface descriptions. For a physical network adapter this is typically the name of the vendor of the network adapter followed by a part number and description, such as Contoso 12345 Gigabit Network Device .

Type: String [ ]
Aliases: ifDesc
Position: Named
Default value: None
Accept pipeline input: True
Accept wildcard characters: False

Specifies an array of network adapter names.

Type: String [ ]
Aliases: ifAlias, InterfaceAlias
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

Returns an object representing the item with which you are working. By default, this cmdlet does not generate any output.

Type: SwitchParameter
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

Specifies the maximum number of concurrent operations that can be established to run the cmdlet. If this parameter is omitted or a value of 0 is entered, then Windows PowerShellВ® calculates an optimum throttle limit for the cmdlet based on the number of CIM cmdlets that are running on the computer. The throttle limit applies only to the current cmdlet, not to the session or to the computer.

Type: Int32
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

Shows what would happen if the cmdlet runs. The cmdlet is not run.

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