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 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.

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

Predict, compare, and reduce costs with our S3 cost calculator

Previously I have written about how useful public cloud storage can be when starting a…

17 hours ago

One Thread to Poll Them All: How a Single Pipe Made WaterDrop 50% Faster

This is Part 2 of the "Karafka to Async Journey" series. Part 1 covered WaterDrop's…

21 hours ago

A year of documentation-driven development

For many software teams, documentation is written after features are built and design decisions have…

2 days ago

Announcing FIPS 140-3 for Ubuntu Core22

With the release of the FIPS 140-3 certified cryptographic modules for Ubuntu 22.04 LTS, Canonical…

3 days ago

The foundations of software: open source libraries and their maintainers

Open source libraries are repositories of code that developers can use and, depending on the…

6 days ago

From inspiration to impact: design students from Regent’s University London explore open design for their dissertation projects

Last year, we had the opportunity to speak at Regent’s UX Conference (Regent’s University London’s…

7 days ago