How to Restart Networking in Debian Linux

28/12/2020
Chưa phân loại
On Linux, one of the basic things you do is configure the network. Once you make changes, you have to restart the networking service in order for the changes to take effect.

In this article, I will show you how to configure the network easily and restart them properly on Debian Linux. Let’s get started.

Restarting Networking on Debian 8 Wheezy and Older:

On Debian Linux, the network configuration is stored in /etc/network/interfaces file. On older version of Debian, when you make changes to /etc/network/interfaces file, you can restart networking with the following command:

$ sudo /etc/init.d/networking restart

The network service should be restarted. But on Debian 9 Stretch, that no longer works due to a bug.

Installing Network Manager on Debian 9 Stretch:

You can directly configure a network interface using /etc/network/interfaces file manually if you like. But the good news is, you don’t have to do that. On recent Linux distributions such as Debian 9 Stretch, networking can be managed by the Network Manager. It makes configuring a network really easy. Network Manager has command line utilities for network configuration.

If you have minimal server version of Debian 9 Stretch installed, you may not have Network Manager installed. In that case, you have to install Network Manager.

First update the package repository cache with the following command

$ sudo apt update

The package repository cache should be updated.

Now install Network Manager with the following command:

$ sudo apt install network-manager

Press y and then press <Enter> to continue.

Network Manager should be installed.

Using Network Manager to Configure Networking:

Network Manager has nmtui terminal based interactive tool that you can use to configure networking on Debian 9 Stretch.

To start nmtui, run the following command:

$ sudo nmtui

You should see the following window. From here you can set hostname, edit/add network connection, and active/deactivate network connections that you created.

To create a connection, go to Edit a connection. Then press <Tab> to select <Add> and then press <Enter>.

Now select your connection method. I am going for Ethernet as I have a wired connection. Now press <Tab> and select <Create> and then press <Enter>.

Now type in a Profile name. It can be anything you want. I recommend you make it short and easy. Now type in a Device identified. I have only one physical Ethernet cable connected to my computer and is recognized as ens33, so I typed that. You can run ip link show command to find out your Device identifier.

If you want to use DHCP to get the IP address for this network interface, then that’s pretty much everything you need to do. But if you want to assign a static IPv4 or IPv6 address, then you have to press <Tab> to go to <Show> for IPv4 CONFIGURATION or IPv6 CONFIGURATION or both depending on your need. Then press <Enter>. Then you should see something like this. Type in your IP Address, Gateway, DNS servers information, Routing and other information.

Once you’re done, scroll down using the <Down Arrow Key> and go to <OK> and then press <Enter>.

Your connection should be created and activated.

NOTE: Network Manager do not manage interfaces defined in /etc/network/interfaces file. So if the interface you’re configuring with Network Manager is also configured using the /etc/network/interfaces file, then be sure to comment it out or remove it from the /etc/network/interfaces file for Network Manager to work with that interface.

Restarting a Single Connection Using Network Manager:

In the earlier section, I showed you how to create a connection using Network Manager. In this section I will show you how to restart the connection.

When you edit a connection, you must restart the connection for the changes to take effect.

You can use the nmtui utility to restart a connection using the Terminal based user interface.

Run nmtui and go to Activate a connection.

Now select your Connection from the list, in my case the Home Router, then press <Tab>.

Now while <Deactivate> is selected, press <Enter> to deactivate the connection first.

Now while <Activate> is selected, press <Enter> to activate the connection again. Your changes should be applied.

You can do the same thing from the terminal using the nmcli command.

Deactivate the Home Router connection with the following command:

$ sudo nmcli connection down "Home Router"

To Activate the Home Router connection again, run the following command:

$ sudo nmcli connection up "Home Router"

You can also Restart the connection with a single command:

$ sudo nmcli connection reload "Home Router"

Restarting Network Manager:

If you have a lot of connection, which may take a lot of time to restart one by one, then you can just restart the Network Manager service with the following command:

$ sudo systemctl restart network-manager

The Network Manager service should restart.

That’s how you Restart Networking Properly on Debian Linux. Thanks for reading this article.

Sandclock IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, Sandclock IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

Installing Node.js on Debian 10

Node.js is a server side JavaScript runtime. Node.js is open source and cross platform. Node.js runs on Linux, Windows...
29/12/2020

Top 10 Ethical Hacking Books

Hacking is an ongoing process of information gathering and exploitation of any target. The hackers are consistent, practical...
29/12/2020

Hướng dẫn đổi ngôn ngữ mặc định, đổi logo, favicon, độ phân giải video trên Jitsi

Đôi khi, bạn muốn “cá nhân hóa” một chút cho các ứng dụng tự dựng như jitsi, ví dụ...
30/12/2020
Bài Viết

Bài Viết Mới Cập Nhật

Hướng dẫn chuyển đổi windows server windows evaluation to standard và active windows server 2008 + 2012 + 2016 + 2019
26/10/2021

How to Update Ubuntu Linux
24/10/2021

Squid Proxy Manager cài đặt và quản lý Proxy Squid tự động trên ubuntu
20/10/2021

Hướng dẫn cài đặt Apache CloudStack 4.15.2.0
19/10/2021

Hướng dẫn ký file PDF bằng chữ ký số (chữ ký điện tử) và sửa lỗi mới nhất 2021 foxit reader
19/10/2021