Skip to main content
Commands

Using ifup, ifdown, and ifquery commands in Linux

The ifup, ifpdown and ifquery are parts of the same package and help you troubleshoot the network interfaces in Linux.

Sagar Sharma

Warp Terminal

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:

ifup [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 wireless interface using ifup command

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
Use ifup commmad to up all network interfaces

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 specific network interface in linux using ifdown command

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
Down every interface using ifdown command in Linux

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

ping Linuxhandbook.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
list network interfaces that are configured automatically at each boot

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
fetch interfaces that are configured with allow-hotplug keyword using ifquery command

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.

Let me know if I missed something.

Sagar Sharma