ifconfig

networkingLinux/Unix
The ifconfig command is one of the most frequently used commands in Linux/Unix-like operating systems. ifconfig Configure or display network interface parameters

Quick Reference

Command Name:

ifconfig

Category:

networking

Platform:

Linux/Unix

Basic Usage:

ifconfig [options] [arguments]

Common Use Cases

    Syntax

    ifconfig [interface] [options] [address]

    Options

    Option Description
    up Activate the interface
    down Deactivate the interface
    netmask addr Set the network mask
    broadcast addr Set the broadcast address
    pointopoint addr Set the point-to-point address for an interface
    hw ether addr Set the hardware/MAC address
    mtu N Set the Maximum Transmission Unit
    promisc Enable promiscuous mode (receive all packets)
    -promisc Disable promiscuous mode
    arp Enable ARP protocol on this interface
    -arp Disable ARP protocol on this interface
    multicast Enable multicast support for this interface
    -multicast Disable multicast support for this interface
    allmulti Enable all-multicast mode (receive all multicast packets)
    -allmulti Disable all-multicast mode
    txqueuelen N Set the transmit queue length
    add addr/prefixlen Add an IPv6 address to an interface
    del addr/prefixlen Remove an IPv6 address from an interface

    Examples

    How to Use These Examples

    The examples below show common ways to use the ifconfig command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.

    # Basic Examples Basic
    ifconfig
    Display information about all active network interfaces.
    ifconfig eth0
    Display information about the eth0 interface.
    sudo ifconfig eth0 up
    Activate the eth0 interface. sudo ifconfig eth0 down Deactivate the eth0 interface. # Advanced Examples Advanced sudo ifconfig eth0 192.168.1.10 netmask 255.255.255.0 Set IP address and netmask for eth0. sudo ifconfig eth0 mtu 1500 Set Maximum Transmission Unit (MTU) for eth0. sudo ifconfig eth0 promisc Enable promiscuous mode on eth0. sudo ifconfig eth0 -promisc Disable promiscuous mode on eth0. sudo ifconfig eth0:0 192.168.2.1 netmask 255.255.255.0 Create a virtual interface (alias) for eth0. sudo ifconfig eth0 hw ether 00:11:22:33:44:55 Change the MAC address of eth0.

    Try It Yourself

    Practice makes perfect! The best way to learn is by trying these examples on your own system with real files.

    Understanding Syntax

    Pay attention to the syntax coloring: commands, options, and file paths are highlighted differently.

    Notes

    The ifconfig command is a traditional Unix/Linux utility for configuring, controlling, and querying network interface parameters. It allows users to view and modify the configuration of network interfaces, including IP addresses, netmasks, MAC addresses, and various operational parameters. Key features of ifconfig: 1. Interface Information Display: Without arguments, ifconfig shows the status and configuration of all active network interfaces, including IP addresses, MAC addresses, and traffic statistics. 2. Interface Configuration: With appropriate privileges, ifconfig can configure network interfaces, setting IP addresses, netmasks, broadcast addresses, and other parameters. 3. Interface Control: ifconfig can activate (up) or deactivate (down) network interfaces, which is useful for troubleshooting or managing network connections. 4. Hardware Parameter Adjustment: The command can modify hardware-related parameters such as the Maximum Transmission Unit (MTU) and MAC address. 5. Special Mode Configuration: ifconfig can enable or disable special operational modes such as promiscuous mode (for packet capturing), ARP protocol support, and multicast packet handling. 6. Virtual Interface Support: The command supports creating and configuring virtual interfaces (aliases), which allow a single physical interface to have multiple IP addresses. 7. IPv6 Support: Modern versions of ifconfig can display and configure IPv6 addresses alongside traditional IPv4 addresses. It's important to note that in many modern Linux distributions, ifconfig is considered deprecated and is being replaced by the ip command from the iproute2 package. The ip command offers more comprehensive network configuration capabilities and better support for modern networking features. Despite this, ifconfig remains widely used due to its simplicity and familiarity. System administrators and network technicians still commonly use it for quick network troubleshooting, interface status checking, and basic configuration tasks. On many systems, ifconfig requires root or administrative privileges to make configuration changes, though regular users can typically use it to view interface information.

    Related Commands

    These commands are frequently used alongside ifconfig or serve similar purposes:

    Use Cases

    Learn By Doing

    The best way to learn Linux commands is by practicing. Try out these examples in your terminal to build muscle memory and understand how the ifconfig command works in different scenarios.

    $ ifconfig
    View All Commands