Tutorials

How to Use ifup ifdown ifquery Commands on Ubuntu Server

This article provides a guide for how to use ifup ifdown ifquery commands on Ubuntu server.

The ifup, ifdown, ifquery commands are some of the basic Linux networking commands.

The ifup command is used to activate (up) a network interface, ifdown deactivates (down) it while ifquery lets you check the state of a network interface.

To be more precise, these commands are used to configure network interfaces based on interface definitions in the file /etc/network/interfaces.

Before you see the usage of ifup, ifdown and ifqury, get a few things in order first.

Prerequisite

These commands may not be available in your system by default. On Ubuntu-based systems, you can install it using this command:

sudo

Sponsored
apt install ifupdown

For other distributions, please check your package manager.

You’ll need to know the interface names to work with them. How do you get that? Use the same ip command that you use for getting your IP address:

ip link show

Or the deprecated ifconfig command:

ifconfig -a

Now that you have ensured the required things, let’s see the command and examples.

Using ifup command

The command has a simple syntax:

ipup [options]

However, options has quite a long range of offerings. I’d be walking you through some of the major ones.

Up a specific interface

To activate or up an interface, just give its name to the ifup command.

For example, I’d be using wlo1 which is my wireless interface.

sudo ifup wlo1

Up all interfaces

To up every network interface, you’d need to use -a option but you can also use -v option (verbose) to get detailed info about what are those interfaces that are just activated.

sudo ifup -av

The reason why I had to interrupt DHCPDISCOVER was my system is not connected over DHCP and it would go on searching for a single from my Ethernet port.

Sponsored

Using ifdown Command

As its name suggests, this command does exactly the opposite of what I explained above.

But it follows the exact same command syntax as ifup:

ifdown [option]

Down a specific interface

You may encounter cases where you have to down a specific network interface as you can not afford to down the entire network and in those times, this command will be helpful.

For demonstration, I’d be using the wlo1 interface:

sudo ifdown wlo1

Down all interfaces

You may find yourself in a situation where you want to disconnect your system in every possible way and in those times. This command is going to be useful.

sudo ifdown -av

You may ping any IP address to check whether your system has been disconnected successfully or not.

ping Ubuntu-server.com

Using ifquery Command

While ifup and ifdown commands are used to configure the network interface, ifquery is used to fetch the config data of the network interface.

Being part of the same command family, ifquery utilizes the same command syntax as ifup and ifdown.

ifquery [option]

So let me start with a few examples of ifquery.

Fetch network interfaces that are configured at each boot

When you want to get the list of network interfaces that are being configured at each boot automatically (marked as auto in interfaces file), you’d have to pair the ifquery command with -l option.

ifqury -l

The allow-hotplug is similar to auto option you show above, but it is used for external peripherals such as USB drives and invokes kernel/udev detection against the hardware.

To fetch interfaces configured with the allow-hotplug keyword, you’d have to append the --allow=hotplug keyword with the -l option. Let me show you how:

ifquery -l --allow=hotplug

Closing Thoughts

The ifup and ifdown commands do not have any fancy options and their primary focus is to up/down network interfaces.

You’ll need these commands when you are experimenting or troubleshooting the network interfaces.

Ubuntu Server Admin

Recent Posts

Ubuntu Command-Line Mastery: The Essential Guide for Power Users

The Linux terminal is a powerful tool allowing users to control their system precisely and…

11 hours ago

Ubuntu Weekly Newsletter Issue 876

Welcome to the Ubuntu Weekly Newsletter, Issue 876 for the week of January 19 –…

3 days ago

How to utilize CPU offloads to increase storage efficiency

Canonical Ceph with IntelⓇ Quick Assist Technology (QAT) Photo by v2osk on Unsplash When storing…

4 days ago

Breaking the Rules: RPC Pattern with Apache Kafka and Karafka

Introduction Using Kafka for Remote Procedure Calls (RPC) might raise eyebrows among seasoned developers. At…

4 days ago

How to Install PalWorld on Ubuntu VPS (Easy 5 Minute Guide)

This article provides a guide for how to install PalWorld on Ubuntu VPS server. How…

5 days ago

How to Resolve Unmet Dependencies Error on Ubuntu

Using APT to manage software on Ubuntu (or similar Linux systems) is generally simple. It…

6 days ago