Network Integration  «Prev  Next»
Lesson 4 Enabling and disabling network interfaces
Objective Enable and disable a network interface.

Enable and disable a network interface in Linux

Question: What are the steps to enable and disable a network interface in Red Hat Linux?
Managing network interfaces is a critical task for a Red Hat Linux Administrator. The state of a network interface, whether it is enabled or disabled, has direct ramifications for system communications, security, and data transfer. Thus, precise control over these interfaces is indispensable. The procedure for enabling and disabling network interfaces on Red Hat Linux is typically conducted via the NetworkManager service, using the `nmcli` utility or by manipulating interface configuration files directly. Here are the authoritative steps:

Using NetworkManager Command-Line Utility (nmcli)

To Enable a Network Interface:

  1. Identify the Network Interface: Before you can enable a network interface, you must identify it. To list all network interfaces, execute:
    nmcli device status
    
  2. Enable the Network Interface: To activate a network interface, execute the following `nmcli` command:
    nmcli device connect <interface_name>
    

    Replace `<interface_name>` with the name of the interface you wish to enable, such as `eth0` or `ens33`.
  3. Confirm the Status: To ensure the network interface is indeed enabled, check its status with:
    nmcli device status
    

The state should show as "connected".

To Disable a Network Interface:

  1. Identify the Network Interface: The identification step remains consistent; you list all interfaces by issuing:
    nmcli device status
    
  2. Disable the Network Interface: To deactivate the network interface, use the following `nmcli` command:
    nmcli device disconnect <interface_name>
    

    Again, replace `<interface_name>` with the name of the interface you intend to disable.
  3. Confirm the Status: To ensure that the interface has been disabled, check its status:
    nmcli device status
    

The state should show as "disconnected".

Using Interface Configuration Files

Alternatively, you can manually manage the state of a network interface by manipulating its corresponding configuration file.

To Enable a Network Interface:

  1. Edit the Configuration File: Navigate to `/etc/sysconfig/network-scripts/` and edit the corresponding `ifcfg-<interface_name>` file.
    sudo vi /etc/sysconfig/network-scripts/ifcfg-<interface_name>
    
  2. Modify ONBOOT Directive: Set the `ONBOOT` directive to `yes`:
    ONBOOT=yes
    
  3. Restart the Network Service: Apply the changes by restarting the network service:
    sudo systemctl restart network
    

To Disable a Network Interface:

  1. Edit the Configuration File: The file path remains the same:
    sudo vi /etc/sysconfig/network-scripts/ifcfg-<interface_name>
    
  2. Modify ONBOOT Directive: Set the `ONBOOT` directive to `no`:
    ONBOOT=no
    
  3. Restart the Network Service: Apply the change:
    sudo systemctl restart network
    

Important Considerations:

  1. Privilege Level: These tasks require superuser or equivalent permissions.
  2. Caution: Deactivating an interface may disrupt network services. Proceed with caution, especially on production systems.
  3. Validation: Always validate changes by inspecting interface status and possibly conducting traffic tests.

By following these well-defined steps, you can execute the crucial administrative tasks of enabling and disabling network interfaces on Red Hat Linux systems with precision and confidence. This meticulous control over network interfaces enhances both the security and the operational efficiency of the system.

Network interfaces must be flexible enough to allow you to connect and disconnect from a subnet. Once a network interface[1] is configured, only one simple step is required to begin using the interface.

Enabling an Interface

Interfaces must be activated, or enabled, before communications among computers can begin. The simplest way to activate an interface is to use netcfg in one of the following ways:
  1. Click your interface and then click Activate
  2. Set the interface to automatically start-up at boot time

An even simpler method is the command line utility, ifup. To activate the interface eth0, type ifup eth0 at a command prompt. If you have configured the connection properly and the network is functioning correctly, then the interface will activate. From there, you can begin using network applications like your Web browser or FTP and Telnet clients.

Disabling an interface

When you wish to disable an interface, you can use the same netcfg method used to enable an interface. For example, if you have a modem using interface ppp0 and you need to disable the interface to use a telephone on the same line, open netcfg to the Interfaces screen, select the ppp0 interface, and click Deactivate.
Alternatively, you can just type ifdown ppp0 at the command prompt. The ifdown command is the opposite of ifup, as you might have guessed. Use it whenever you wish to disable an interface. The next lesson shows you how to use the Host Table to look up network IP addresses and host names.

Enabling Disabling - Quiz

Before moving on to the next lesson, click the Quiz link below to review configuration and activation.
Enabling Disabling - Quiz
[1]Interface: A communications system used to connect a Linux machine to a network.