How to Restart Network Interface in Linux

How do I restart the network interface under Linux operating systems after making changes to IP configuration without rebooting the server?

You can restart the networking service in Linux using various command. Use the following commands as per your Linux distribution to restart the networking service. You must run the command as root user either using sudo or su commands. The ifup command bring a network interface up. The ifdown command take a network interface down. You must be careful with ifdown command if you are using it over SSH based session.

Restart Network Interface Using Command Lines in Linux

WARNING! These examples may result in loss of networking connectivity when run over ssh based sessions. Therefore for remote servers, use a console provided by your cloud service provider or IPMI. The nixCraft or author is not responsible for data loss.

First, you can get a list of network interfaces on Linux using the ip command (or ifconfig command):

ip link show
ifconfig -a

Then, the procedure to to turn off eth0 interface is as follows (replace the eth0 with your actual name). Run:

ifdown eth0

To turn on eth0 interface run:

ifup eth0

See ip address info using the ip command:

ip a show eth0


Restart Network Interface Using Command Lines in Linux
If you get error such as ifup or ifdown command not found, then use the ip command to turn off and on interface named eth0 or enp0s31f6:

sudo ip link set enp0s31f6 down
sudo ip link set enp0s31f6 up

Debian / Ubuntu Linux

To restart network interface, enter:

sudo /etc/init.d/networking restart

To stop and start use the following option (do not run them over remote ssh session as you will get disconnected):

sudo /etc/init.d/networking stop
sudo /etc/init.d/networking start

Debian/Ubuntu Linux with systemd, run:

sudo systemctl restart networking

The latest version of Ubuntu or Debian service name changed to NetworkManager. Hence, use the systemctl command as follows:

sudo systemctl restart NetworkManager

Redhat (RHEL) / CentOS / Fedora / Suse / OpenSuse Linux

To restart network interface, enter:

/etc/init.d/network restart

To stop and start use the following option (do not run them over remote ssh session as you will get disconnected):

/etc/init.d/network stop
/etc/init.d/network start

Fedora/RHEL/CentOS/Suse Linux with systemd, run:

sudo systemctl restart network

Again, The latest version of RHEL/CentOS/Rocy/Alma Linux service name changed to NetworkManager. Hence, use the systemctl command as follows:

sudo systemctl restart NetworkManager

Slackware Linux restart commands

Type the following command:

/etc/rc.d/rc.inet1 restart

You can take down or restart particular interface such as eth1 as follows:

/etc/rc.d/rc.inet1 eth1_restart
/etc/rc.d/rc.inet1 eth1_start ### start eth1 ###
/etc/rc.d/rc.inet1 eth1_stop ##stop eth1 ###

How to see status of network/networking service

Run command as per your Linux distro version:
# CentOS/RHEL/Fedora/Rocky/Alma Linux #

systemctl status network #old
systemctl status NetworkManager #new

# Debian/Ubuntu/Linux mint and co #

systemctl status networking #old
systemctl status NetworkManager #new 

# Suse/OpenSUSE Linux #

systemctl status network

# Alpine Linux #

service networking status

Sample outputs from OpenSUSE:

* wicked.service - wicked managed network interfaces
   Loaded: loaded (/usr/lib/systemd/system/wicked.service; enabled; vendor preset: disabled)
   Active: active (exited) since Sat 2018-01-13 06:40:25 UTC; 1 weeks 3 days ago
  Process: 93 ExecStart=/usr/sbin/wicked --systemd ifup all (code=exited, status=0/SUCCESS)
 Main PID: 93 (code=exited, status=0/SUCCESS)
    Tasks: 0 (limit: 512)
   CGroup: /system.slice/wicked.service
 
Jan 13 06:40:10 opensuse systemd[1]: Starting wicked managed network interfaces...
Jan 13 06:40:25 opensuse wicked[93]: lo              up
Jan 13 06:40:25 opensuse wicked[93]: eth0            up
Jan 13 06:40:25 opensuse systemd[1]: Started wicked managed network interfaces.

To see info about your ip address run:

ifconfig -a

OR

ip a
ip a show
ip a show eth1

How to restart the networking service on Gentoo

Run the following for eth0:

/etc/init.d/net.eth0 restart

Restating networking service on Alpine Linux

Use the service command:

service networking restart

# OR #

/etc/init.d/networking restart

Arch Linux restart networking

Use the systemd-networkd.service on your Arch Linux. For example, on Linode cloud server, I use the following commands:
# Restart it #

sudo systemctl restart systemd-networkd.service

# Get the status #

systemctl status systemd-networkd.service

Sample outputs:

 systemd-networkd.service - Network Configuration
     Loaded: loaded (/usr/lib/systemd/system/systemd-networkd.service; enabled;>
     Active: active (running) since Tue 2022-02-15 19:58:13 UTC; 3 days ago
TriggeredBy: ● systemd-networkd.socket
       Docs: man:systemd-networkd.service(8)
   Main PID: 245 (systemd-network)
     Status: "Processing requests..."
      Tasks: 1 (limit: 4690)
     Memory: 3.0M
        CPU: 1min 41.703s
     CGroup: /system.slice/systemd-networkd.service
             └─245 /usr/lib/systemd/systemd-networkd

Feb 15 19:58:12 localhost systemd-networkd[245]: lo: Link UP
Feb 15 19:58:12 localhost systemd-networkd[245]: lo: Gained carrier
Feb 15 19:58:12 localhost systemd-networkd[245]: Enumeration completed
Feb 15 19:58:13 localhost systemd[1]: Started Network Configuration.
Feb 15 19:58:13 localhost systemd-networkd[245]: eth0: Link UP
Feb 15 19:58:13 localhost systemd-networkd[245]: eth0: Gained carrier
Feb 15 19:58:14 localhost systemd-networkd[245]: eth0: Gained IPv6LL
Notice: journal has been rotated since unit was started, output may be incomple
  • systemctl status, systemctl restart, service networking restart, Restart Network Interface
  • 10 کاربر این را مفید یافتند
آیا این پاسخ به شما کمک کرد؟

مقالات مربوطه

How to Set Up a Mac for Your Kids

Providing children with access to a computer and the internet is increasingly important, but so...

How to Get Help With a Command from the Linux Terminal

Whether you’re an inexperienced terminal user or a grizzled veteran, you won’t always know the...

How to change the ssh port on Linux

To Change the SSH Port for Linux Server Connect to your server via SSH Switch to the root...

How To Install screenFetch in Linux

If you've browsed Linux groups on social media, you've probably seen a lot of screenshots that...

Static IP vs. Dynamic IP Address

A static IP address is one that remains fixed and never changes. The PC always sees the same...

Powered by WHMCompleteSolution