fbpx
Limited time 25% of on our life-time plans using code: LMT25
  • 00Days
  • 00Hours
  • 00Minutes
  • 00Seconds
Search
Close this search box.

Mastering ifconfig Command: An Introductory Guide With 20 Examples

ipconfig

Table of Contents

Get up to 50% off now

Become a partner with CyberPanel and gain access to an incredible offer of up to 50% off on CyberPanel add-ons. Plus, as a partner, you’ll also benefit from comprehensive marketing support and a whole lot more. Join us on this journey today!

Ifconfig commands are one of the basic commands in Linux networking. Basically, it is used to configure and manage various network interfaces. However, with newer commands such as ip in modern distributions these days, ifconfig is still popular among network administrators and enthusiasts of Linux. It enables users to manage IP addresses, troubleshoot network connectivity, and configure network interface settings important for maintaining a Linux system’s network stability and operation.

Here we’ll discuss the common uses, syntax, and examples of using the ifconfig command effectively. We’ll also show how the most advanced web hosting control panel, CyberPanel, can make the management of your network much easier while also improving the control over your server.

What is the ifconfig Command?

It stands for “interface configuration”. This command is a powerful command-line utility established to control and administer network interfaces on Unix-like systems. Traditionally, the ifconfig command is used to let you view the IP addresses assigned and to modify such addresses on network interfaces. This command enables network administrators to connect a specific interface, Ethernet or Wi-Fi, and troubleshoot some interfaces as well.

For example, if the servers fail to connect, the running of ifconfig provides a snapshot immediately regarding which IP addresses, subnet masks, and broadcast addresses are being used by every network interface. This makes the networks in the servers and other appliances connected run better since the configuration settings are accomplished through the use of the command ifconfig.

Linux ifconfig Command Options

Linux ifconfig Command Options

Syntax and Basic Usage of ifconfig Command

The syntax of the ifconfig command is very simple. Just type the following command and you will get all the status of the network interfaces:

ifconfig

The command will display all the available network interfaces and their respective IP addresses, subnet masks, and MAC addresses. Here’s the basic syntax:

Tech Delivered to Your Inbox!

Get exclusive access to all things tech-savvy, and be the first to receive 

the latest updates directly in your inbox.

output

interface: This is the network interface, like eth0 or wlan0.

options: Other options define more configurations like the possibility of specifying an IP address or enabling/disabling interfaces.

address: assigns an IP address to an interface.

Basic Example of ifconfig Command and Its Output

eth0 interface
output

This command displays the configuration of the eth0 interface, showing details such as the IP address, subnet mask, and hardware address (MAC address).

ifconfig Advanced Options and Configurations

Static IP Address

To assign a static IP address to an interface, you would use:

setting static IP address

This sets the IP address to be 192.168.1.100 and assigns the subnet mask 255.255.255.0 to the eth0 interface.

Enable/Disable Network Interfaces

To enable or disable network interfaces, you would use the ifconfig command as shown below:

Enable Interface: ifconfig eth0 up

Disable Interface: ifconfig eth0 down

One feature explains this because disabling and re-enabling an interface solves the connectivity issues.

Enhance Your CyerPanel Experience Today!
Discover a world of enhanced features and show your support for our ongoing development with CyberPanel add-ons. Elevate your experience today!

Setting A Broadcast Address

The ifconfig command helps you set a broadcast address for an interface

setting a braodcast address

This command assigns the broadcast address 192.168.1.255 to eth0, which is useful for network-wide communication.

Examples of ifconfig Command in Action

Viewing All Network Interfaces

viewing all networks interfaces
output

Changing the MAC Address of an Interface

To set a custom MAC address:

setting custom MAC address

This is helpful for privacy or security reasons, as some network services rely on MAC addresses for identification.

Comprehensive Guide to the ifconfig Command in Linux

1. ifconfig Command For Linux

The ifconfig command in Linux is the most powerful tool for configuration, management, and troubleshooting of network interfaces based on Linux systems. Here’s how it works:

Basic Command Example:

ifconfig command

This command displays all active network interfaces, showing details like IP addresses, MAC addresses, and packet statistics.

output

2. ifconfig command in Ubuntu

You probably won’t find the command ifconfig pre-installed under Ubuntu. In this case, you can install the net-tools package to enable the installation of the command ifconfig:

ifconfig command in Ubuntu

After you install it, you are able to run ifconfig to view network configurations, which is especially useful with Ubuntu server editions where you will be doing a lot of network management.

output

3. Run command ifconfig on Windows

The Windows version of the command is ipconfig, which achieves the same goal. Displays network information about Windows systems. It can be quickly used to show IP addresses, subnet masks, and default gateways for an interface.

Windows Example

ipconfig

4. ifconfig Command Not Found

If you are getting the ïfconfig command not found” error, it means that net-tools is not installed on your Linux system. You can resolve this by installing net-tools:

installing net-tools

5. ifconfig Command on Linux for IP Address

To display the IP address of a specific interface, you can filter ifconfig results. For example:

ifconfig command on linux for IP address
output

Use cases of the ifconfig Command: 20 Examples

Show All Active Interfaces

It displays all active interfaces in the system along with the IP address, MAC address, netmask, and broadcast address.

to show all active interfaces
output

Information for Specific Interface eth0

It only shows information for a specific interface that is mentioned (e.g. eth0), and which is useful to check if a particular interface is alive or not.

for information for specific interface eth0
output

Static IP Setting

It is used for setting a static IP along with the netmask to an interface, mostly at servers or for special kinds of network setup.

static IP setting
output

Turn ON the Interface

Enable the network interface online, and enable the device to start communication on a network.

enabling interface
output

Disable Interface

This is used to disable an interface but does not remove its configurations; this command can be useful for diagnostic purposes or when testing.

disabling interface
output

Set MTU

It assigns the maximum transmission unit of packet size; this is usually implemented if there are specific requirements that require a minimum packet size or fine-tuning for better network performance.

setting MTU
output

Change MAC Address

This changes the MAC address for testing or to bypass certain restrictions based on MAC address restrictions set up in the network.

changing MAC address
output

Add Alias (eth0:1)

Attach an alias IP for adding multiple IP addresses across a single physical interface such as virtual hosting or subnetting.

adding Alias
output

Disassociate an Alias

This method detaches an alias IP address from the interface with use cases being during some changes in network configurations.

disassociating an Alias
output

Setup Broadcast Address

this kind of setup sets the broadcast addresses on the interface it’s a type of set that enables sending packets out to all network devices across it.

setting up broadcast address
output

Show Network Counters

It displays detailed, but basic transmission and receives packet counters and error information to address a problem within the networks in terms of transmission and drops of packets.

showing network counters
output

Set Interface Metric

It associates a numeric metric with an interface, the routing decision when there are several interfaces available.

setting interface metric
output

Set Subnet Mask

It makes further subnet precision possible by setting the subnet mask within IP addresses.

setting subnet mask
output

Show MTU Setting Only

 extracts the MTU value of an interface, for a quick view of packet size limits on a network connection.

showing MTU setting
output

Show IPv4 Addresses

It shows all IPv4 addresses that are connected to active interfaces: handy for network inventory.

showing IPv4 address
output

Enable Promiscuous Mode

It enables the interface to capture all packets irrespective of whether they are not destined for it. Often used in packet analysis and troubleshooting.

enabling promiscuous mode
output

Disable Promiscuous Mode

Toggles off promiscuous mode to put the interface back into normal operation, restricting it to only the intended traffic.

disabling promiscuous mode
output

Check MAC Address Only

It quickly shows the MAC address of the specified interface, which can be helpful for network configuration or troubleshooting.

checking MAC address
output

Enable Multicast Mode

Enable an interface to perform processing on multicast packets – it is typically applied to the goal of video conferencing or streaming.

enabling multicast mode
output

Clear IP Configuration

It reinitializes IP address configuration on a specific interface. This is typically set before associating another new IP.

clearing IP configuration
output

Integration of ifconfig Command with CyberPanel for Advanced Network Management

CyberPanel

CyberPanel is a very powerful web hosting control panel. It provides a simple interface for the management of the network. Administrators can configure the network settings with the help of CyberPanel without knowing the deep details about the command lines, especially the ifconfig command. For example, when you host multiple websites on a server, you need to assign different IPs to each site. This may be facilitated by CyberPanel by its integration with the ifconfig command to simplify IP management and server configurations.

FAQs on the ifconfig Command

1. What is the difference between ifconfig and ip command?

Both are associated with the management of network interfaces; however, ifconfig is part of the older package, net-tools while ip is part of the newer iproute2. Most of the new distributions prefer to use ip instead of ifconfig.

2. Do I use ifconfig for setting DNS addresses?

No, ifconfig can’t manage DNS configuration. You keep DNS in /etc/resolv.conf.

3. How can I get my public IP using ifconfig?

ifconfig only returns private IPs. If you want your public IP use curl ifconfig.me or curl ipinfo.io

4. Can I ever use ifconfig for debug purposes?

Yes, you can debug using ifconfig. For example, if you see that some packets are dropped or if you see any error in the ifconfig, then you know something is wrong somewhere.

5. How do I rename an interface using ifconfig?

You can’t make ifconfig natively change the names of interfaces. You can though using ip link set.

6. What does ‘MTU’ in ifconfig output represent?

MTU is the abbreviation for Maximum Transmission Unit, an interface parameter that defines the maximum size of packets transferred over the interface. The change in MTU might help if the network performance is poor under certain conditions.

Conclusion: Fine-Tune Your Linux Networking with the ifconfig Command

The ifconfig command remains a very important tool for network administrators and has made the management of network interfaces on Linux systems much easier. From setting static IPs to enabling or disabling interfaces, ifconfig is pretty flexible and in control over networking configurations. If one uses CyberPanel, the tasks can be easily done with user-friendly management tools that integrate with ifconfig to make server administration even simpler. From all that has been described above with the examples on the same, you will now know how to install and troubleshoot your network under Linux.

Use all this today and master control over your network with ifconfig commands under Linux!

Hasib Iftikhar

I'm Hasib Iftikhar, a dedicated technical writer at CyberPanel, joining the team in July 2024. With three years of extensive experience in content writing, I specialize in copywriting, article writing, guest posting, affiliate content writing, and SEO. My expertise ensures that each piece of content I create is engaging, informative, and optimized for search engines, helping businesses enhance their online presence and reach their target audience effectively.
Unlock Benefits

Become a Community Member

SIMPLIFY SETUP, MAXIMIZE EFFICIENCY!
Setting up CyberPanel is a breeze. We’ll handle the installation so you can concentrate on your website. Start now for a secure, stable, and blazing-fast performance!