Home / Alt manpages / ifconfig(8)

  • ifconfig(8)
  • Admin command
  • linux

Inspect and Safely Adjust Linux Interfaces with ifconfig

You will use ifconfig to inspect interface state, identify an interface that is down, and understand the shape of a narrowly scoped configuration change. The command is part of the legacy net-tools package. This machine has net-tools 2.10-0.1ubuntu4.4 installed.

Allow about fifteen minutes. You need a shell; inspection is normally unprivileged. Configuration changes usually need root privileges and can interrupt networking, so use a console or an out-of-band recovery path before changing the interface carrying your current connection.

1. List interfaces you can see

Start with the read-only form. With no arguments, ifconfig shows active interfaces. Add -a to include interfaces that are currently down:

$ ifconfig -a
br-example: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.0.2.10  netmask 255.255.255.0  broadcast 192.0.2.255
        ether 02:00:00:00:00:10  txqueuelen 0  (Ethernet)

The names, addresses and counters are host-specific. The useful fields are the interface name, flags, MTU, protocol addresses, hardware address and packet counters. The exact flags are also driver-dependent. Do not copy an address or MAC address from this sample into a real configuration.

Checkpoint: record the exact interface name you intend to inspect. A name such as enp0s31f6, eth0 or br-example is not interchangeable with another device.

2. Inspect one interface

Pass one interface name to see only that device:

$ ifconfig INTERFACE_NAME
INTERFACE_NAME: flags=...  mtu 1500
        inet ADDRESS  netmask NETMASK  broadcast BROADCAST

Replace INTERFACE_NAME with a name from ifconfig -a. If it is wrong, the command reports an error instead of showing another interface. Use -v when an error is not clear:

$ ifconfig -v INTERFACE_NAME

Use -s when you need a short list similar to netstat -i. These inspection commands do not change addresses, flags or link state.

3. Read the address and mask together

For IPv4, the inet line contains the address and netmask. The mask determines which addresses are considered local to that interface. The manpage says that if you set an address without a mask, ifconfig derives a usual class A, B or C mask from the address. That is an old default, not a substitute for checking the network design. Supply the intended mask explicitly when configuring an interface.

IPv6 addresses appear on inet6 lines with a prefix length. The address family is IPv4 by default; use inet6 when the operation needs IPv6 syntax. For example, the manpage's form for adding an IPv6 address is:

$ sudo ifconfig INTERFACE_NAME inet6 add 2001:db8:1234::10/64

This changes live kernel state and may affect routing or reachability. Do not run it with an address copied from documentation. Replace the address and prefix with values assigned to this host, and check the result immediately:

$ ifconfig INTERFACE_NAME
INTERFACE_NAME: flags=...  mtu 1500
        inet6 2001:db8:1234::10  prefixlen 64  scopeid 0x0<global>

To remove the address added in the example, use the matching address and prefix:

$ sudo ifconfig INTERFACE_NAME inet6 del 2001:db8:1234::10/64

That undo command is only correct for an address you deliberately added. Removing an existing service address can disconnect applications.

4. Make a small IPv4 change only with a recovery path

The general IPv4 configuration shape is:

$ sudo ifconfig INTERFACE_NAME 192.0.2.10 netmask 255.255.255.0

Assigning an address implicitly activates the interface unless you use the special alias behaviour described by the manpage. The command does not make the setting persistent across reboot. Distribution network management, such as a service or configuration file, may later reapply its own state.

Before pressing Enter, check three things: the interface name, the address ownership, and the netmask. This is a service-disrupting action. Keep a second session open if possible. After it returns, inspect the interface:

$ ifconfig INTERFACE_NAME
INTERFACE_NAME: flags=...  mtu 1500
        inet 192.0.2.10  netmask 255.255.255.0

There is no universal undo value. Restore the address and mask that were present in your recorded output, or let the host's network manager reapply its configuration. Do not guess an old address from memory.

up activates an interface and down shuts its driver down. Both can break traffic immediately. A reversible-looking command is still disruptive:

$ sudo ifconfig INTERFACE_NAME down
$ sudo ifconfig INTERFACE_NAME up

Only use this when you have confirmed the interface and have a recovery route. The mtu option changes the maximum transfer unit:

$ sudo ifconfig INTERFACE_NAME mtu 1400
$ ifconfig INTERFACE_NAME

Restore the previous MTU from your recorded output, commonly 1500 but not always. An MTU mismatch can cause fragmentation or failed connections, so test the affected traffic rather than relying only on a successful command exit.

6. Avoid the traps that cause the most damage

  • Do not use ifconfig with no interface when you meant to inspect a particular device. No arguments reports active interfaces only.
  • Do not assume -a means every possible device. It reports interfaces currently available to the command, including those that are down.
  • Do not enable promisc or allmulti as a diagnostic guess. They change which packets the interface receives and may increase capture or processing exposure.
  • Do not change a hardware address with hw unless the driver supports it and you understand the effect on switching, leases and access controls.
  • Do not treat a successful address change as persistent configuration. Check the network manager or distribution configuration that owns the interface.

For newer Linux systems, the manpage points to ip link from the iproute2 package for complete link-layer information, particularly because this old ioctl interface cannot display all 20 bytes of an Infiniband hardware address correctly. That is a limitation of this command, not evidence that the address is short.

Done means

  • You used ifconfig -a to find the exact interface name.
  • You inspected the selected interface and recorded its address, mask, MTU and flags.
  • You treated IPv4 and IPv6 syntax as separate operations.
  • Every live change had an explicit elevated command, a verification step and a recovery value.
  • You know which persistent network configuration will reapply the desired state after reboot.