Ifconfig is an older version of the ip command, but many still prefer ifconfig due to its simpler syntax and ease of use. But how exactly do you use ifconfig for network interface configuration? Here is a walkthrough.

Installing Net-Tools

The ifconfig command doesn’t come installed into Linux distributions by default. Most system administrators will install the package it belongs to when setting things up, but in some cases, it might be missing on your computer. You can install it easily. If you try using the ifconfig command on a system that doesn’t have it installed, you’ll get an error message – along with instructions on how to install it. Just enter the command: sudo apt install net-tools This will install ifconfig and a few other network configuration utilities. Note that sudo is required for installing ifconfig and enabling or disabling networks.

Viewing Network Information Using ifconfig

The simplest way to use the ifconfig command is to run it directly without any parameters. This brings up information on all active interfaces, including ethernet and wireless connections. This provides all pertinent information about the network interfaces, including MTU value (Maximum Transmission Unit), IP addresses, and packet history. If you only want the technical specs in a more digestible format with interface names, enter ifconfig -s. However, both of these versions don’t include currently inactive networks. To view all network interfaces, use the ifconfig -a command instead. When you already know the name of the networks and only want the status of a particular interface, you can append its name to the ifconfig command. Like this: ifconfig eth0

Enabling and Disabling Networks With ifconfig

Monitoring the status of running networks isn’t the only thing you can do with ifconfig. You can also use the command to configure almost every aspect of these interfaces, down to the MTU and the masking used. The simplest use case is to start up or stop networks. You can do this by using the following command: sudo ifconfig name up The “name” parameter is the actual name of the network. This can be used to enable any of the inactive interfaces detected using the ifconfig -a command. To disable a network, just use down instead of up: sudo ifconfig dummy0 down This will disable the interface.

Configuring Networks With ifconfig

Modifying any value associated with a network interface is easy. Just remember to prepend the command with sudo, as all these changes require administrator privileges to take effect. The most common use of this feature is to assign a custom IP address to a network. For example, this is how to give a new IP address to the dummy0 interface: sudo ifconfig dummy0 29.95.245.112 You can enter any valid IP address after the network name to assign it. You will only get a message if you entered something incorrectly. Otherwise, the change will immediately take effect. You can also specify a netmask like this: sudo ifconfig dummy0 netmask 255.255.255.0 The syntax for setting a broadcast address is similar: sudo ifconfig dummy0 broadcast 77.40.108.115 If you’re looking to modify all these IP addresses for a network, it’s more efficient to lump all the commands together. Like most Linux commands, you can include multiple arguments in the same line. A network interface can also have one or more aliases. These are specified by the syntax of name:x, where name is the network’s name and x a digit. For example, here is how to add an alias IP address to the dummy0 network. sudo ifconfig dummy0:0 69.72.169.2 You can confirm that it worked by using ifconfig to get its status. ifconfig dummy0:0

What Else Can You Do With ifconfig?

The ifconfig command has an extensive list of arguments that you can use to modify many other variables of a network interface. You can enable multicast, set the MTU, and activate promiscuous mode, among other things. The official man pages have a complete list of all the arguments that can be used with ifconfig, along with a technical definition of what each does. You can, of course, invoke the manual from the terminal itself using the man ifconfig command.

When Should You Use ifconfig?

For most users, there’s little reason to be using the ifconfig command. The automatic settings provided by default are good enough for normal internet usage. But if you’re a system administrator who wants more granular control over their network interfaces, then ifconfig is just the tool for you. You can use the command upon booting up the system to properly configure network interfaces and then pretty much forget about it. It’s handy in diagnosing network issues as well since you can query the status of any network interface and configure it. You can use ifconfig to restart networks or even switch technical parameters until it works more smoothly.

Linux Ifconfig Command  How to Use It - 97Linux Ifconfig Command  How to Use It - 84Linux Ifconfig Command  How to Use It - 50Linux Ifconfig Command  How to Use It - 6Linux Ifconfig Command  How to Use It - 72Linux Ifconfig Command  How to Use It - 50Linux Ifconfig Command  How to Use It - 3Linux Ifconfig Command  How to Use It - 98Linux Ifconfig Command  How to Use It - 74Linux Ifconfig Command  How to Use It - 82Linux Ifconfig Command  How to Use It - 70Linux Ifconfig Command  How to Use It - 96Linux Ifconfig Command  How to Use It - 16Linux Ifconfig Command  How to Use It - 42