VMware ESXi and vSphere Cluster Management
Linux ifconfig Command: View and Configure Network Interfaces
Learn how to use the legacy Linux ifconfig command to inspect interfaces, read addresses and flags, assign a temporary IPv4 address, and enable or disable devices.
What is ifconfig?
ifconfig is a command-line utility for examining and changing Linux network interfaces. It is traditionally provided by the net-tools package.
A network interface is a communication endpoint provided by a physical adapter, virtual device, wireless adapter, VLAN, or the special loopback device. Historically, administrators used ifconfig for two main tasks:
- Displaying the status and addressing information of interfaces.
- Changing interface parameters such as an IPv4 address, netmask, and administrative state.
Modern Linux distributions generally recommend the ip command from the iproute2 suite. However, ifconfig remains useful on older systems and when working with older documentation or scripts.
List active network interfaces
Run ifconfig without an interface name to display interfaces that are currently active:
ifconfigThe output normally contains one section for each active interface. An administratively down interface may be omitted by some ifconfig implementations. To include inactive interfaces, use the -a option:
ifconfig -aThe exact formatting varies between systems, but common output includes the interface name, addresses, hardware address, state flags, MTU, and traffic counters.
Common interface names
- eth0 is a traditional name for the first Ethernet interface.
- enp0s3 and ens33 are examples of predictable names used by many modern Linux systems. The name is based on hardware or firmware location rather than simply being numbered.
- lo is the loopback interface. It supports communication from a host to itself and is not an external network adapter.
A physical or virtual adapter connects the host to another network or service. The loopback device instead keeps traffic inside the same operating system. Applications commonly use it for local services, often with an address in the 127.0.0.0/8 range.
View one interface
To limit the output to one named interface, place its name after the command:
ifconfig eth0Replace eth0 with the actual device name on your system, such as enp0s3, ens33, a wireless name, or a virtual interface. Discover names with:
ifconfig -aYou can inspect the loopback interface separately:
ifconfig loRead ifconfig output
An IPv4 address is a 32-bit network-layer address commonly written in dotted-decimal form, such as 192.0.2.10. A netmask separates the network portion of that address from the host portion. The address 192.0.2.10 with netmask 255.255.255.0 is equivalent to the prefix notation 192.0.2.10/24: the first 24 bits identify the network and the remaining 8 bits identify a host within it.
An IPv6 address may appear when IPv6 is configured. A broadcast address identifies all hosts on a local IPv4 subnet where broadcast is supported. A MAC address is a link-layer identifier associated with the interface. Unlike an IP address, it identifies the interface at the data-link layer and is used for local network delivery.
| Field or concept | Meaning | Why it matters |
|---|---|---|
| Interface name | The device name, such as eth0, enp0s3, or lo. | Use it when inspecting or changing that device. |
| IPv4 address | The interface's IPv4 network-layer address. | Identifies the host on an IPv4 network. |
| IPv6 address | An IPv6 network-layer address, when configured. | Supports IPv6 communication and may coexist with IPv4. |
| Netmask | Separates the network and host portions of an IPv4 address. | Determines which destinations are local to the subnet. |
| Broadcast address | An IPv4 address for traffic to all hosts on a local subnet. | Used by protocols that support local broadcast. |
| MAC address | A link-layer identifier for the interface. | Used for local network-frame delivery. |
| MTU | Maximum Transmission Unit, the largest packet size sent without fragmentation at that layer. | Incorrect values can affect connectivity and performance. |
| UP/RUNNING flags | Interface status indicators. UP means administratively enabled; RUNNING commonly indicates an available carrier or operational link. | Helps distinguish software state from link state. |
| RX/TX counters | Received and transmitted packet and byte totals. | Useful for spotting traffic, errors, or dropped packets. |
Temporarily assign an IPv4 address
Use this syntax to assign an IPv4 address and netmask:
sudo ifconfig <interface> <ipv4-address> netmask <netmask>For example, this uses 192.0.2.10, an address reserved for documentation:
sudo ifconfig eth0 192.0.2.10 netmask 255.255.255.0Verify the result by inspecting the interface:
ifconfig eth0Direct changes made with ifconfig are normally temporary. They can disappear after a reboot, a network service restart, a DHCP renewal, or an action by NetworkManager or another network manager. Changing an active interface over SSH can also terminate your current session.
Enable or disable an interface
Bring an interface administratively up with:
sudo ifconfig eth0 upDisable it with:
sudo ifconfig eth0 downdown disables network traffic on the device. up re-enables its administrative state. An interface can be administratively enabled without having a working carrier: for example, an Ethernet cable may be disconnected, or a wireless adapter may not be associated with an access point. The UP and RUNNING flags help distinguish these conditions, although detailed link information is often clearer with ip link show.
Privileges and persistent configuration
Reading interface information usually works as a regular user, but changing addresses or interface state requires elevated privileges:
sudo ifconfig <interface> up
sudo ifconfig <interface> 192.0.2.10 netmask 255.255.255.0There is an important difference between a temporary command-line adjustment and persistent network configuration:
| Method | Survives reboot | Typical use case | Management considerations |
|---|---|---|---|
ifconfig | No | Legacy systems, testing, or short-lived changes. | May be replaced by DHCP or a network manager. |
ip command | No, normally | Modern manual inspection and temporary configuration. | Use the current distribution's supported management system for persistence. |
| NetworkManager | Yes, when saved in a connection profile | Desktop and server network profiles. | Configure through the distribution-supported NetworkManager tools. |
| Netplan or systemd-networkd | Yes, when configuration is saved | Distributions and deployments that use these systems. | Follow the system's configuration and apply procedures. |
| Distribution-specific network configuration | Yes, when saved correctly | Older systems using traditional network scripts or service files. | Use the format and service commands documented for that distribution. |
For permanent settings, use the supported method for your distribution, such as NetworkManager, systemd-networkd, Netplan, or traditional distribution-specific network scripts. Avoid having multiple network managers compete to control the same interface.
Modern equivalents with ip
The ip command from iproute2 is the recommended tool for current Linux administration. These commands cover the most common ifconfig tasks:
| Task | Legacy ifconfig command | Recommended ip command |
|---|---|---|
| Show addresses | ifconfig | ip addr show |
| Show all links | ifconfig -a | ip link show |
| Show a particular interface | ifconfig eth0 | ip addr show dev eth0 |
| Add an IPv4 address with prefix length | sudo ifconfig eth0 192.0.2.10 netmask 255.255.255.0 | sudo ip addr add 192.0.2.10/24 dev eth0 |
| Bring an interface up | sudo ifconfig eth0 up | sudo ip link set dev eth0 up |
| Bring an interface down | sudo ifconfig eth0 down | sudo ip link set dev eth0 down |
The ip commands also make the distinction between address information and link information explicit: use ip addr for addresses and ip link for device and link state.
Troubleshooting
ifconfig: command not found
The net-tools package may not be installed, or the distribution may expect administrators to use iproute2. Use the modern commands where possible:
ip addr show
ip link showInstall the distribution's net-tools package only when legacy compatibility is required, using the package manager and procedures supported by that distribution.
The expected eth0 interface does not exist
Modern predictable naming may produce a name such as enp0s3 or ens33. The machine may also have only a wireless, virtual, or differently named adapter. Run:
ifconfig -a
ip link showReplace eth0 in examples with the real interface name.
The configured address disappears
A direct ifconfig change is temporary, or DHCP, NetworkManager, or another service may have replaced it. Check whether DHCP is intended to manage the interface and configure the address through the distribution-supported persistent network system.
Network access stops after using down
The selected interface was administratively disabled. Restore it with:
sudo ifconfig <interface> upIf you disabled the remote management interface, use a local console, out-of-band management, or an alternate connection.
The interface is UP but traffic fails
An enabled interface may still lack physical carrier or wireless association. Addressing, netmask, route, gateway, VLAN, DNS, or firewall problems can also prevent communication. Inspect the relevant layers:
ip link show
ip addr show
ip route showCheck local gateway reachability before investigating DNS. The RUNNING flag is useful, but it does not prove that every part of the network configuration is correct.
Permission denied or operation not permitted
Changing interface state or addresses requires elevated privileges. Retry with sudo and confirm that your account is authorized to perform administrative operations.
Key points
ifconfigis a legacy net-tools utility for viewing and changing network-interface settings.ifconfiglists active interfaces;ifconfig -aincludes interfaces that may be administratively down.- Interface names may be traditional, such as
eth0, or predictable, such asenp0s3andens33. lois the host-local loopback interface, not an external network adapter.- IPv4 addresses, netmasks, broadcast addresses, MAC addresses, flags, MTU values, and counters describe different aspects of an interface.
- Direct ifconfig changes are normally temporary and can interrupt remote administration.
- Use
ip addrandip linkfor modern Linux administration, and use a supported network manager for persistent settings.
For more practice with the legacy utility, return to the Linux ifconfig command guide and compare each task with its modern ip equivalent.