ifup Command in Linux

November 21, 2023

Introduction

The Linux ifup command allows you to view network interfaces in the terminal. It is often used with ifdown and ifquery commands.

The following text elaborates on the ifup command in Linux, its options, and use cases.

ifup Command in Linux

Prerequisites

  • Access to the terminal.
  • Linux system (this tutorial uses Ubuntu 22.04).
  • sudo or root privileges.

Note: To ensure correct ifup functionality, the /run/network/ifstate file must be writable. If this proves challenging, solutions include employing the sudo command, obtaining root privileges, or using the --force option. Alternatively, create a symbolic link for /run/network/ifstate leading to a location with write permissions.

ifup Command Syntax

The ifup command follows this syntax:

ifup [options] [interface] 

Executing ifup without specifying any options or interface does not generate any output. While the [interface] components are obligatory, options are not. Options tailor the command to specific requirements.

Note: If your system doesn't have ifup, run the command below.

sudo apt install ifupdown

ifup Command Options

The ifup command produces varied output based on different arguments. The table below lists the available options.

OptionDescription
-v, --verbose Displays what happens before executing the command.
--force 
Forces configuration.
--ignore-errors Ignores errors.
-o OPTION=VALUE Sets a specific network configuration option to a specified value, treating it as defined in the /etc/network/interfaces file.
--no-scripts 
Does not run any hook scripts.
--no-loopback Does not treat the loopback device differently from other network interfaces.
-n, --no-act Prints out the actions that would occur without executing the command.
-a, --all 
Processes all interfaces marked as automatically activated at the startup.
-h, --help Shows the help message.
-V, --version 
Prints copyright and version information.
-i, --interfaces FILE Allows users to specify a custom file for defining network interface configurations.
--state-dir DIR
Instructs the command to use a specific directory to store state information.
-X, --exclude PATTERN Excludes interfaces from the operation based on a specified PATTERN.

--no-mappings
Stops extra network configuration rules or settings specified through mappings. This allows the network interface to be brought up with minimal or default configuration.

Note: The --force argument resolves a common problem with ifup. Network interface records occasionally don't accurately reflect the actual states, leading to inconsistencies. When this occurs, using --force allows ifup to carry out configuration commands regardless of the interfaces' current state.

ifup Command Examples

Because ifup supports various arguments, it has multiple practical use cases. However, before executing ifup, users must be aware of the specific interface names. To determine these names, execute the ip command or the deprecated ifconfig command.

Confirm the interface's names with:

ip link show
ip link show terminal output

The second option to verify interfaces is by using:

ifconfig -a
ifconfig -a terminal output

Note: The ifconfig command is not available on all Linux systems. To install it, execute the command below.

sudo apt install net-tools

To make sure interfaces are active, use ping. For instance, ping google.com:

ping google.com
Pinging google.com

For this tutorial, first execute ifdown to turn off all the interfaces:

sudo ifdown -av
sudo ifdown -av

The command produces verbose output. To verify all interfaces are down, use ifconfig, ip, or ping. For instance:

ifconfig -a
ifconfig -a terminal output when all interfaces are down

The output shows interfaces are down.

The following text presents practical ifup usage examples.

Bring up a Specific Interface

To activate a specific network interface, run the following syntax:

sudo ifup [interface]

For instance, turn on the enp0s3 interface with:

sudo ifup enp0s3

The command produces no output. Verify the interface is working with ifconfig, ip, or ping.

Print Verbose Output

To display additional info in the command output, run the command with -vFor instance, bring up the lo interface with:

sudo ifup -v lo
sudo ifup lo -v terminal output

Note: In general, the interface name alone should be sufficient when bringing up the interface. Therefore, sudo ifup -v [interface] is the typical syntax. However, in some configurations, the syntax is sudo ifup -v [interface] [configuration]. For example, sudo ifup -v lo=lo.

Activate all Interfaces

To bring up all interfaces and get the verbose mode, run:

sudo ifup -av
sudo ifup -av

Ignore Errors

The argument --ignore-errors instructs the system to bring up network interfaces and to proceed with the activation even if errors are encountered during the process.

For instance, to bring up all interfaces, print verbose output, and ignore errors, run:

sudo ifup --ignore-errors -av
sudo ifup --ignore-errors -av terminal output

Exclude an Interface

The --exclude option allows users to specify an interface to be excluded from the list. The syntax for this command is:

sudo ifup --exclude [interface]

For instance, exclude the lo interface with:

sudo ifup --exclude lo

The command has no output.

Simulate Interface Activation

Using the --no-act option is beneficial when users wish to preview the changes that occur while activating a network interface without actually applying those changes. The syntax is:

ifup --no-act [interface]

For example, simulate ifup on the lo interface without executing the command with:

sudo ifup --no-act -v lo
sudo ifup --no-act terminal output

Note:While many Linux distributions have basic networking capabilities installed by default, sometimes automatic network adjustments for hardware changes may require additional packages. To determine if these extra packages are installed and necessary for your specific requirements, refer to the system documentation or consult the package manager.

Conclusion

After reading this tutorial, you are now familiar with the Linux ifup command, syntax, options, and common use case examples.

For more essential commands for networking, check out our Linux network commands cheat sheet.

Was this article helpful?
YesNo
Sara Zivanov
Sara Zivanov is a technical writer at phoenixNAP who is passionate about making high-tech concepts accessible to everyone. Her experience as a content writer and her background in Engineering and Project Management allows her to streamline complex processes and make them user-friendly through her content.
Next you should read
What is SNMP (Simple Network Management Protocol)?
October 20, 2022

This article explains what SNMP is, its basic components, and how it woks. See which network monitoring tools are available and get started with network management today...
Read more
How to Test Network Speed in Linux via CLI
November 25, 2020

This article shows you numerous ways to test network speed in Linux via CLI. Learn how to install and use 9 online tools to test internet speed from the command prompt window...
Read more
Nmap Commands - 17 Basic Commands for Linux Network
May 14, 2019

Nmap stands for Network Mapper. It is an open source tool for network exploration and security auditing...
Read more
Best Tools to Monitor Network Bandwidth on a Linux Server
September 19, 2024

There are many different tools for monitoring network traffic on a Linux server. Each option has its strengths and weaknesses. Most of...
Read more