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

Building RAG with enterprise open source AI infrastructure

One of the most critical gaps in traditional Large Language Models (LLMs) is that they…

4 hours ago

Life at Canonical: Victoria Antipova’s perspective as a new joiner in Product Marketing

Canonical is continuously hiring new talent. Being a remote- first company, Canonical’s new joiners receive…

1 day ago

What is patching automation?

What is patching automation? With increasing numbers of vulnerabilities, there is a growing risk of…

2 days ago

A beginner’s tutorial for your first Machine Learning project using Charmed Kubeflow

Wouldn’t it be wonderful to wake up one day with a desire to explore AI…

3 days ago

Ubuntu brings comprehensive support to Azure Cobalt 100 VMs

Ubuntu and Ubuntu Pro supports Microsoft’s Azure Cobalt 100 Virtual Machines (VMs), powered by their…

3 days ago

Ubuntu Weekly Newsletter Issue 870

Welcome to the Ubuntu Weekly Newsletter, Issue 870 for the week of December 8 –…

4 days ago