CrackOps
Interview PrepTracksLinuxAWS LabSoonInterview RoomSoon
Sign inStart free
CrackOps

Interview prep for the people who keep production up.

[email protected]
ProductInterview PrepTracksDashboardInterview Room
RolesDevOpsSREPlatformCloud
CompanyAboutContactPrivacyTerms
© CrackOps
Linux / Networking / ifconfig

ifconfig

Legacy interface configuration (read it, prefer ip)

Beginnernetworkinterfaceslegacy

ifconfig shows network interfaces with their IP, netmask, MAC and packet counters, and can bring interfaces up or down. It's part of the deprecated net-tools package: still common on older servers, in macOS and in old docs, but on modern Linux use ip.

Syntaxifconfig [-a] [INTERFACE] | ifconfig INTERFACE [ADDRESS] [netmask MASK] [mtu N] [up|down]

Watch it run

An old runbook says 'check ifconfig'. Install it if needed and read the fields.

devops@devops-lab: ~ — zsh — 96×28
➜ ~
Step 1 of 2
ifconfig

Not installed by default. The same information is available from ip addr and ip -s link.

Anatomy of a command

$
commandsudo

Viewing is free; any change needs root.

How it works

ifconfig talks to the kernel with ioctl calls on a socket (SIOCGIFFLAGS, SIOCGIFADDR, SIOCSIFMTU and so on) and reads /proc/net/dev for counters. That old interface only knows one IPv4 address per interface name, which is why net-tools introduced alias labels like ens5:1 for extra addresses. Addresses added with ip addr add (without a label) are invisible to ifconfig, and it knows nothing about policy routing, network namespaces or many modern link types. net-tools has been unmaintained for years and is not installed by default on Ubuntu, Debian, RHEL or Amazon Linux; ip from iproute2 replaces it. Like ip, changes made with ifconfig apply only to the running kernel and are lost at reboot.

Options you'll actually use

ifconfigShow interfaces that are up
-aShow all interfaces, including down ones
IFACEShow one interface
IFACE ADDR netmask MSet the primary IPv4 address and mask
IFACE up / downEnable or disable the interface
IFACE mtu NChange the MTU
IFACE:N ADDRAdd an alias address (legacy multi-IP)
-sShort table of counters, like netstat -i

Common mistakes

Using ifconfig output to check which IPs a host has

It only shows one IPv4 address per interface name; addresses added with ip (or by cloud agents) don't appear.

ip -br a # or ip -4 addr show
Assuming ifconfig exists in scripts and containers

net-tools isn't installed on modern distributions or slim images, so the script fails with 'command not found'.

Use ip (iproute2), which is always present on systemd systems.
Configuring a server permanently with ifconfig commands in rc.local

Changes are runtime-only, and mixing them with netplan or NetworkManager leads to conflicts after DHCP renewals or reboots.

Describe the config in netplan or NetworkManager and apply it.

Interview questions

Practice

Try these on a Linux machine of your own. Each task has a hint and a solution.

  1. 1

    Show all interfaces with ifconfig, including those that are down.

  2. 2

    Show the loopback interface with ifconfig, then with ip, and find the MTU in both.

  3. 3

    Write the ip command equivalent to: sudo ifconfig eth0 10.0.1.40 netmask 255.255.255.0 up

Related commands

ipShow and change interfaces, addresses and routesnetstatLegacy network statistics (and their ss/ip twins)ssSee listening ports and open connectionspingCheck if a host answers and how fast
PreviousipNextuseradd
Linux / Networking / ifconfig

ifconfig

Legacy interface configuration (read it, prefer ip)

Beginnernetworkinterfaceslegacy

ifconfig shows network interfaces with their IP, netmask, MAC and packet counters, and can bring interfaces up or down. It's part of the deprecated net-tools package: still common on older servers, in macOS and in old docs, but on modern Linux use ip.

Syntaxifconfig [-a] [INTERFACE] | ifconfig INTERFACE [ADDRESS] [netmask MASK] [mtu N] [up|down]

Watch it run

An old runbook says 'check ifconfig'. Install it if needed and read the fields.

devops@devops-lab: ~ — zsh — 96×28
➜ ~
Step 1 of 2
ifconfig

Not installed by default. The same information is available from ip addr and ip -s link.

Anatomy of a command

$
commandsudo

Viewing is free; any change needs root.

How it works

ifconfig talks to the kernel with ioctl calls on a socket (SIOCGIFFLAGS, SIOCGIFADDR, SIOCSIFMTU and so on) and reads /proc/net/dev for counters. That old interface only knows one IPv4 address per interface name, which is why net-tools introduced alias labels like ens5:1 for extra addresses. Addresses added with ip addr add (without a label) are invisible to ifconfig, and it knows nothing about policy routing, network namespaces or many modern link types. net-tools has been unmaintained for years and is not installed by default on Ubuntu, Debian, RHEL or Amazon Linux; ip from iproute2 replaces it. Like ip, changes made with ifconfig apply only to the running kernel and are lost at reboot.

Options you'll actually use

ifconfigShow interfaces that are up
-aShow all interfaces, including down ones
IFACEShow one interface
IFACE ADDR netmask MSet the primary IPv4 address and mask
IFACE up / downEnable or disable the interface
IFACE mtu NChange the MTU
IFACE:N ADDRAdd an alias address (legacy multi-IP)
-sShort table of counters, like netstat -i

Common mistakes

Using ifconfig output to check which IPs a host has

It only shows one IPv4 address per interface name; addresses added with ip (or by cloud agents) don't appear.

ip -br a # or ip -4 addr show
Assuming ifconfig exists in scripts and containers

net-tools isn't installed on modern distributions or slim images, so the script fails with 'command not found'.

Use ip (iproute2), which is always present on systemd systems.
Configuring a server permanently with ifconfig commands in rc.local

Changes are runtime-only, and mixing them with netplan or NetworkManager leads to conflicts after DHCP renewals or reboots.

Describe the config in netplan or NetworkManager and apply it.

Interview questions

Practice

Try these on a Linux machine of your own. Each task has a hint and a solution.

  1. 1

    Show all interfaces with ifconfig, including those that are down.

  2. 2

    Show the loopback interface with ifconfig, then with ip, and find the MTU in both.

  3. 3

    Write the ip command equivalent to: sudo ifconfig eth0 10.0.1.40 netmask 255.255.255.0 up

Related commands

ipShow and change interfaces, addresses and routesnetstatLegacy network statistics (and their ss/ip twins)ssSee listening ports and open connectionspingCheck if a host answers and how fast
PreviousipNextuseradd