NetworkingIntermediate25 min read

What Is ifconfig in Networking?

Reviewed byJohnson Ajibi· Senior Network & Security Engineer · MSc IT Security

This page mentions older exam versions. See the Current Exam Context and Legacy Exam Context sections below for the updated mapping.

On This Page

Quick Definition

ifconfig is a command used in Linux and macOS to view or change settings for your computer's network connections. You can use it to see your IP address, turn a network card on or off, or check if a cable is connected. It helps you understand how your computer talks to the network.

Commonly Confused With

ifconfigvsipconfig

ipconfig is the Windows equivalent of ifconfig. It displays IP configuration information. The key difference is the operating system: ifconfig is for Linux/macOS, ipconfig is for Windows. Also, ipconfig can release and renew DHCP leases with /release and /renew, whereas ifconfig cannot directly renew a DHCP lease.

On a Windows PC, you type ipconfig to see your IP. On a Linux server, you type ifconfig.

ifconfigvsip addr show

ip addr show is the modern Linux command that replaces ifconfig. It provides similar information but in a different format and with more features, such as supporting multiple addresses per interface natively. ip addr show is part of the iproute2 package and is preferred in many modern distributions.

Instead of typing ifconfig, on a modern Linux system you would type ip addr show to see all interfaces and their IP addresses.

ifconfigvsnetstat

netstat is a command used to display network connections, routing tables, interface statistics, and more. While both tools show interface information, ifconfig is focused on configuration and status of interfaces, whereas netstat shows connection-oriented information like listening ports and established TCP connections.

Use ifconfig to check if your interface has an IP address. Use netstat -tuln to see which ports are open and listening for connections.

ifconfigvsroute

route is a command used to view and manipulate the IP routing table. ifconfig has no ability to view or change the routing table. The route command is used for adding or removing default gateways, whereas ifconfig is for interface-level settings like IP address and netmask.

Use ifconfig to assign an IP to an interface. Use route -n to see the default gateway.

Must Know for Exams

ifconfig is a commonly tested command in several IT certification exams, particularly those focused on networking and Linux system administration. On the CompTIA Network+ exam (N10-008 and N10-009), network troubleshooting is a major domain, and command-line tools are a key part of that. The exam objectives explicitly include using ifconfig or ipconfig to verify IP address configuration, subnet mask, default gateway, and DNS settings. Candidates may be presented with a scenario where a user cannot connect to the network, and they must identify that the interface is down by interpreting the ifconfig output. Multiple-choice questions often show a snippet of ifconfig output and ask what the problem is, such as a missing IP address or a disabled interface. Understanding how to read the flags, IP address, and error counts is critical.

On the CompTIA Linux+ exam (XK0-005), ifconfig and the ip command are covered under the objective of managing network configurations. Candidates are expected to know how to configure network interfaces, set IP addresses, bring interfaces up and down, and view interface statistics. Simulation questions might require the test-taker to type the correct ifconfig command to accomplish a task, such as setting an IP address on eth0. The exam also tests the difference between temporary changes made with ifconfig and persistent configurations stored in configuration files. Knowing that ifconfig changes are fleeting after a reboot is essential.

The Cisco Certified Network Associate (CCNA) exam does not test Linux ifconfig directly, but it does test comparable concepts. Cisco devices use the command show ip interface brief, which serves a similar purpose. However, for network professionals, understanding the host-side view from ifconfig is important for end-to-end troubleshooting. Some CCNA questions might ask why a workstation cannot ping a router, where the root cause is that the workstation's interface is down, as indicated by ifconfig. In that context, ifconfig is supporting knowledge.

On the Red Hat Certified Engineer (RHCE) exam, ifconfig is considered a legacy tool, but it may still appear in performance-based tasks. The exam encourages using the ip command, but candidates must be prepared to work with systems that have only ifconfig available. Similarly, the Linux Professional Institute (LPI) exams include ifconfig in their objectives for network configuration.

Common exam question types include: reading ifconfig output to identify the IP address, troubleshooting why an interface shows no IP address, determining that an interface is down, interpreting error counters to diagnose a faulty cable, and identifying the MAC address. Performance-based questions may ask the candidate to assign an IP address to an interface using ifconfig. Trap answers often suggest using ifconfig to set a default gateway, which is not possible with ifconfig alone; that requires the route command. Understanding these nuances is important for exam success.

Simple Meaning

Think of ifconfig as the control panel for the doors your computer uses to communicate with the outside world. Every computer has at least one network interface, like an Ethernet port for a wired connection or a Wi-Fi adapter for wireless. ifconfig lets you see information about each of those doors. You can find out what name the door has, like eth0 for the first wired port, and what its address is on the local network, called the IP address. You can also see if the door is open or closed, which means whether the interface is active and ready to send and receive data. Using ifconfig, you can open a door that is closed by running a command, or close one that is open if you want to disconnect from the network temporarily. You can also assign a new address to the door, which is like changing your house number in a neighborhood. This is useful when you need to set a static IP address instead of getting one automatically from a router. The command also shows technical details like the hardware address, which is a unique serial number burned into the network card by the manufacturer, and how many packets of data have been sent or received through that door. If you are having trouble connecting to the internet, ifconfig is one of the first tools to check because it tells you whether your computer even believes it has a working network interface. Without this tool, you would have to guess why your connection is failing. In short, ifconfig puts you in the driver's seat for managing your computer's network connections at a basic but essential level. It is a straightforward, powerful command that every IT learner should know how to use.

When you run ifconfig without any options, it lists all available network interfaces along with their current settings. This output includes the interface name, the IP address, the subnet mask, the broadcast address, and flags that show if the interface is up or down. For a beginner, the most important thing to see is whether an interface has an IP address. If it does not, your computer cannot communicate on the network. The command also shows the Maximum Transmission Unit or MTU, which is the largest size of a data packet that the interface can handle. If you see errors or dropped packets in the output, that can indicate a physical problem like a bad cable or a driver issue. Learning to read the output of ifconfig is a foundational skill for anyone studying for IT certifications like CompTIA Network+ or Linux+. It gives you direct visibility into the first layer of network connectivity right on your own machine.

Full Technical Definition

ifconfig, short for interface configuration, is a system administration utility in Unix and Unix-like operating systems that allows for the configuration, control, and querying of TCP/IP network interface parameters from a command line interface. It is part of the net-tools package on Linux systems, though many modern distributions are transitioning to the ip command from the iproute2 suite. The tool operates by making ioctl system calls to the kernel to read or modify the state of network devices. Each network interface is represented by a name such as eth0, wlan0, or lo. The loopback interface lo is a virtual interface that the computer uses to communicate with itself, crucial for inter-process communication and testing.

The command syntax typically is ifconfig [interface] [options]. Common options include up and down to activate or deactivate an interface, and netmask to set the subnet mask. The command can assign an IP address directly using ifconfig eth0 192.168.1.10 netmask 255.255.255.0 up. This sets a static address, brings the interface up, and applies the subnet mask in one line. The broadcast address is automatically calculated based on the IP and netmask unless specified with the broadcast option. The command also supports aliasing, where multiple IP addresses are assigned to a single physical interface, using a colon notation such as eth0:1. This is often used for hosting multiple websites on one server.

The output of ifconfig provides detailed information. The flags section shows the status, such as UP, BROADCAST, RUNNING, MULTICAST. UP indicates the interface is active, RUNNING means the physical link is detected, and MULTICAST means it supports multicast communication. The inet address is the IPv4 address, and inet6 is the IPv6 address if configured. The mask is displayed as hex, such as 0xffffff00, which corresponds to 255.255.255.0. The ether line shows the MAC address, a unique 48-bit hardware identifier assigned by the manufacturer. The RX and TX lines show packet statistics: received and transmitted packets, errors, dropped packets, overruns, and frame or carrier errors. High error counts can indicate faulty cables, duplex mismatches, or hardware failure. Overruns occur when the kernel is too busy to process incoming data.

In the context of IT certification exams, ifconfig is a standard tool for network troubleshooting and configuration. For example, the CompTIA Network+ exam expects candidates to know how to verify IP addressing and connectivity using command-line tools. The Linux+ exam includes ifconfig as part of managing network configurations. However, it is important to note that ifconfig is deprecated in many current Linux distributions in favor of the ip command, which provides more functionality and cleaner output. The ip addr show command is the modern replacement for ifconfig. Despite this, many older systems and scripts still rely on ifconfig, and understanding it remains relevant for legacy support. The command does not persist across reboots; changes made with ifconfig are lost after restart unless saved in configuration files like /etc/network/interfaces on Debian-based systems or /etc/sysconfig/network-scripts/ on Red Hat-based systems. For persistent changes, network configuration should be handled through those files or using NetworkManager. The tool is not available by default on Windows, where the equivalent is ipconfig, but ifconfig can be installed via subsystems like Cygwin or Windows Subsystem for Linux. On macOS, ifconfig works similarly but with some differences in interface naming, such as en0 for Ethernet and en1 for Wi-Fi. Understanding ifconfig is foundational for any IT professional, as it provides direct access to the network layer configuration and is often the first command run when diagnosing connectivity issues. Its simplicity and ubiquity make it a staple in the administrator's toolkit.

Real-Life Example

Imagine you live in a large apartment building with many different doors. Each door leads to a different area: one door goes to the parking garage, another to the rooftop garden, and another to the main lobby. Each door has a unique number, like Door 7A and Door 7B.

You have a master key that can open or close any door, and there is a label on each door showing the number of people that have passed through it today. This apartment building is your computer, and each door is a network interface. The door number is the interface name, like eth0 or wlan0.

The label showing how many people have passed through is the packet count. The master key is the ifconfig command. ifconfig allows you to see the status of each door, whether it is open (up) or locked (down).

It tells you the address label on the door, which is the IP address, and the unique serial number engraved on the door frame, which is the MAC address. If you want to allow people to enter through the parking garage door, you use your master key to unlock it, which is like running ifconfig eth0 up. If the door is broken and no one can get through, you can check the label to see if there are errors, like scratches or dents counted on the door.

In the computing world, those scratches are errors or dropped packets. Now suppose the building manager changes the main entrance address, and you need to update the label on Door 7A. You use your master key to write the new label, which is like assigning a new IP address with ifconfig.

This analogy works because both situations involve managing access points with unique identifiers, monitoring traffic, and making changes as needed. The key takeaway is that ifconfig gives you the same kind of direct, physical-level control over your network interfaces as a master key gives you over doors in a building. You can see what is happening, lock or unlock interfaces, and change addresses without needing to contact anyone else.

This is why ifconfig is invaluable for quick troubleshooting and configuration on the command line.

Why This Term Matters

ifconfig matters because it is often the first tool an IT professional reaches for when diagnosing network problems. When a user reports that they cannot access the internet, checking ifconfig answers the immediate question of whether the computer even has a valid IP address. Without an IP address, there is no way to communicate on the network. The command also reveals whether the interface is active, whether the cable is detected, and if there are excessive errors indicating hardware issues. This makes ifconfig a time-saving diagnostic instrument. Instead of guessing or restarting the computer, a technician runs one command and gains a wealth of information.

In practical IT environments, ifconfig is used for tasks such as temporarily assigning an IP address during a server migration, testing network connectivity by bringing an interface up and down, or checking the MAC address for security filtering on a network switch. Network administrators also use ifconfig to set up virtual interfaces for hosting multiple services on a single physical network card. While many modern systems prefer the ip command, ifconfig remains ingrained in countless legacy scripts, documentation, and training materials. Understanding ifconfig provides a bridge between older and newer networking concepts.

For learners, mastering ifconfig builds confidence in working with the command line and understanding network fundamentals. It demystifies how an IP address gets onto an interface and how the operating system interacts with hardware. This knowledge is directly applicable to real-world troubleshooting scenarios. For example, when setting up a Linux server in a data center, ifconfig is used to verify that the network team has assigned the correct IP address to the correct interface. Without this ability, a server could be misconfigured and unreachable. Knowing ifconfig helps professionals understand the information presented by its modern counterparts, such as ip addr show, since the concepts of interface state, IP address, netmask, and MAC address are identical. Ifconfig is a foundational skill that supports network troubleshooting, configuration, and understanding across multiple operating systems and certification exams.

How It Appears in Exam Questions

Exam questions involving ifconfig typically fall into three categories: output interpretation, command syntax, and troubleshooting scenarios. In output interpretation questions, the exam presents a partial or full ifconfig output and asks for specific information. For example, a question might show: eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.1.10 netmask 255.255.255.0 broadcast 192.168.1.255 ether 00:1a:2b:3c:4d:5e and then ask what is the MAC address of this interface. The correct answer would be 00:1a:2b:3c:4d:5e. Another question might ask what the subnet mask is, or whether the interface is up. These questions test the candidate's ability to parse the output quickly.

Command syntax questions require the candidate to choose the correct ifconfig command to accomplish a task. For instance, a question might read: A Linux technician needs to set the IP address of eth0 to 10.0.0.5 with a netmask of 255.255.255.0 and bring the interface up. Which command accomplishes this? The correct answer is ifconfig eth0 10.0.0.5 netmask 255.255.255.0 up. Wrong answers might omit the netmask, use a different interface name, or use incorrect syntax like ifconfig eth0 ip 10.0.0.5. Some questions test the difference between ifconfig and route, asking which command is used to view the routing table, which is route -n, not ifconfig.

Troubleshooting scenario questions present a situation where a user cannot access the network. The scenario might say: A user reports that they cannot browse the internet. The technician runs ifconfig and sees that eth0 is listed but has no IP address. What is the most likely cause? Answers might include: the DHCP client is not running, the cable is unplugged causing the interface not to get an address, or the interface is administratively down. The candidate needs to deduce that if the interface is up but has no IP address, the issue is likely with DHCP or static address assignment. Conversely, if the interface shows no IP and also is not UP, the cable might be disconnected. Another scenario: The ifconfig output shows a high number of errors on the RX or TX counters. The question asks what this indicates, and the correct answer is usually a faulty cable or duplex mismatch.

Questions also test knowledge of the limitations of ifconfig. For example, a question might state: Which of the following cannot be accomplished with the ifconfig command? Correct answers include adding a default gateway, changing DNS servers, or viewing the routing table. Trap answers often suggest that ifconfig can set the default gateway, which is incorrect. Understanding these boundaries is essential for scoring well on these questions.

Practise ifconfig Questions

Test your understanding with exam-style practice questions.

Practise

Example Scenario

You are a junior IT support technician at a small company. An employee in the sales department calls you and says her computer cannot reach the internet. She is running Linux on her desktop.

You ask her to open a terminal and type ifconfig. She reads back the output to you. You hear that the interface named enp2s0 is listed, but it does not show an inet address. There is no IP address assigned.

The interface flags show it is up and running, so the cable is connected and the network card is active. You suspect the DHCP client is not working or the computer is set to use a static IP that was never configured. You ask her to type sudo dhclient enp2s0 to request an IP address from the router.

After a few seconds, she runs ifconfig again and now sees an IP address in the 192.168.1.x range. The internet starts working again. This scenario illustrates the primary use of ifconfig: verifying the current network configuration.

Without ifconfig, you would have no quick way to see that the interface had no IP address. You might have wasted time checking cables or restarting the computer. In this case, the simple observation of a missing IP address from the ifconfig output pointed directly to the solution.

If the interface had shown an IP address but high error counts, you might have suspected a bad cable or switch port. If the interface had been marked DOWN, you would have used ifconfig enp2s0 up to activate it. This real-world example shows why ifconfig is a fundamental troubleshooting tool.

It gives you the first piece of the puzzle whenever a network connection fails. IT certifications test this exact ability: reading ifconfig output and drawing the correct conclusion about what is wrong. The more you practice interpreting the output, the faster you will be at diagnosing issues in both exam scenarios and real jobs.

Common Mistakes

Using ifconfig to set a default gateway

ifconfig does not have the capability to set the default gateway. The default gateway is part of the routing table, which is managed by the route or ip route command.

To set a default gateway, use route add default gw <gateway-ip> or ip route add default via <gateway-ip>.

Thinking ifconfig changes persist after reboot

ifconfig makes live, temporary changes to the kernel's network settings. These changes are lost when the system is restarted unless they are saved in network configuration files.

For persistent changes, edit the appropriate network configuration file, such as /etc/network/interfaces or use /etc/sysconfig/network-scripts/, depending on your distribution.

Confusing ifconfig with ipconfig

ifconfig is a Unix/Linux command. ipconfig is a different command used in Windows. They are not interchangeable. Some beginners try to use ipconfig on Linux or ifconfig on Windows and get errors.

Know your operating system. On Linux/macOS use ifconfig or ip addr. On Windows use ipconfig.

Ignoring the interface name and using the wrong one

New learners often type commands targeting the wrong interface, such as trying to configure eth0 on a system where the interface is named ens33 or wlp2s0. This results in 'Device not found' errors.

Always run ifconfig first to list all available interfaces and their names. Copy the exact name to use in subsequent commands.

Misreading the netmask in hex format

ifconfig displays the netmask in hexadecimal format, like 0xffffff00. Beginners may not recognize this as 255.255.255.0 and misunderstand the configuration.

Learn to convert hex netmasks to dotted decimal. Alternatively, use ip addr show which displays the netmask in CIDR notation, such as /24.

Exam Trap — Don't Get Fooled

{"trap":"An exam question shows ifconfig output with the interface status as DOWN but a valid IP address is listed. Many learners think the interface is still usable because an IP is assigned.","why_learners_choose_it":"Learners focus on the presence of an IP address and assume that means the interface is working.

They do not check the flags at the beginning of the output.","how_to_avoid_it":"Always check the flags. If the word 'UP' is not present among the flags, the interface is disabled and will not transmit or receive any traffic, regardless of the IP address shown.

The IP address is configured but not active. The correct fix would be to use ifconfig <interface> up."

Step-by-Step Breakdown

1

Open a terminal

Access the command line interface on your Linux or macOS system. You can usually find the terminal in the applications menu or by using a keyboard shortcut like Ctrl+Alt+T on many Linux distributions.

2

Run ifconfig with no arguments

Type ifconfig and press Enter. This will display the current configuration of all active network interfaces. If an interface is down, it might not appear unless you include the -a flag: ifconfig -a shows all interfaces, including those that are down.

3

Identify the interface of interest

Look for the interface name such as eth0, ens33, wlan0, or enp0s3. Note its status, IP address, netmask, and MAC address. The IP address will appear after 'inet' and the MAC address after 'ether'. The flags line will tell you if the interface is UP or DOWN.

4

Configure a specific interface

To assign an IP address, use the syntax: sudo ifconfig <interface> <ip-address> netmask <subnet-mask> up. For example: sudo ifconfig eth0 192.168.1.100 netmask 255.255.255.0 up. The 'up' part is optional if the interface is already up, but good practice. The sudo command is often required for configuration changes.

5

Verify the change

Run ifconfig again targeting only that interface: ifconfig eth0. Check that the inet address now shows the new IP and the flags include UP. You can also ping another device on the network to confirm connectivity.

6

Bring an interface down and up

To disable an interface, type sudo ifconfig eth0 down. This stops all traffic on that port. To re-enable it, type sudo ifconfig eth0 up. This is useful for testing network dependencies or resetting a connection without rebooting.

Practical Mini-Lesson

In real-world IT operations, ifconfig remains a go-to command for immediate network interface visibility, despite the push toward the ip command. The reason is simple: ifconfig is universally available on nearly all Unix-like systems, including older production servers that may not have iproute2 installed. In a data center with hundreds of legacy servers, knowing ifconfig inside and out saves time. A common task involves verifying that a newly installed network card is recognized by the system. After physically installing the card, an administrator runs ifconfig -a to see if the new interface appears. If it does not, the driver might be missing or the card is faulty. If it appears but is down, a simple ifconfig <interface> up brings it online.

Another practical use is changing the MTU size. Some network configurations require a smaller MTU to avoid fragmentation. This can be done with ifconfig eth0 mtu 1400. The change takes effect immediately without a restart. However, it will not survive a reboot. Professionals must document this change and add it to startup scripts or configuration files if persistence is needed. Network bonding, where multiple interfaces are combined for redundancy or speed, also uses ifconfig to check the status of each slave interface in the bond.

Troubleshooting high latency or packet loss often starts with ifconfig. By looking at the RX and TX error counters, a technician can identify a failing network card or a bad cable. For example, if the RX errors count is increasing rapidly while pinging a remote host, the cable or the switch port on the other end is suspect. If the TX errors count is high, the computer's network card or driver may be the problem. Some technicians use the command watch -n 2 ifconfig eth0 to monitor error counters in real time while performing tests.

What can go wrong with ifconfig? One risk is making a typo in the IP address and accidentally assigning the wrong address, which can cause a duplicate IP conflict on the network. Another risk is bringing down an interface that hosts critical services, causing an outage. For this reason, experienced administrators always double-check the interface name before running ifconfig down. Also, ifconfig does not validate that the assigned IP address is valid for the subnet. You can assign a 192.168.1.x address on a 10.x.x.x network, and the command will succeed, but your traffic will not route correctly. Network administrators must have a clear understanding of the network design before using ifconfig.

Finally, professionals should know how to combine ifconfig with other commands. For instance, to find the MAC address quickly for security policies, one might use ifconfig eth0 | grep ether. To count interfaces, ifconfig | grep -c inet can show how many interfaces have IP addresses. Mastering these small efficiencies builds confidence and speed on the job.

Memory Tip

Think 'I F Config', I Face Config. It configures the face (interface) your computer shows to the network.

Covered in These Exams

Current Exam Context

Current exam versions that test this topic — use these objectives when studying.

Legacy Exam Context

Older materials may mention these exam versions, but learners should use the current objectives for their target exam.

N10-008N10-009(current version)
XK0-005XK0-006(current version)

Related Glossary Terms

Frequently Asked Questions

Why does ifconfig show 'command not found' on my Linux system?

This usually means the net-tools package is not installed. You can install it using your package manager, such as sudo apt install net-tools on Debian/Ubuntu or sudo yum install net-tools on Red Hat/CentOS. Alternatively, use the ip command.

Can ifconfig show DNS server information?

No, ifconfig does not display DNS server information. For DNS settings, you would check /etc/resolv.conf or use commands like nmcli or systemd-resolve.

Does ifconfig work on Windows?

No, ifconfig is not a native Windows command. Windows uses ipconfig. However, ifconfig can be used on Windows through third-party tools like Cygwin or within the Windows Subsystem for Linux.

How do I see all interfaces including those that are down?

Use ifconfig -a. This shows all interfaces, regardless of their state. Without the -a flag, only active interfaces are displayed.

What is the difference between ifconfig up and ifconfig down?

ifconfig up activates a network interface, making it ready to send and receive data. ifconfig down deactivates the interface, stopping all network traffic through it.

Why is ifconfig being deprecated?

ifconfig is considered deprecated because the iproute2 suite (the ip command) provides more consistent output, supports all network types, and has better scripting capabilities. Many Linux distributions now recommend using ip instead.

Summary

ifconfig is a fundamental command-line utility for configuring and viewing network interfaces on Unix-like operating systems. It allows IT professionals to check IP addresses, subnet masks, MAC addresses, and interface status, as well as to activate or deactivate interfaces and make temporary configuration changes. For IT certification exams such as CompTIA Network+ and Linux+, understanding ifconfig is essential for troubleshooting network connectivity issues. Candidates must be able to read ifconfig output to identify problems like a missing IP address, a disabled interface, or hardware errors indicated by packet statistics.

The tool, while simple, has important nuances. It does not set default gateways, its changes are not persistent across reboots, and it is being replaced by the ip command in modern systems. However, its prevalence on legacy systems and in exam objectives means it remains a must-know skill. Learners should practice running ifconfig, interpreting its output, and distinguishing it from similar commands like ipconfig and route. Common mistakes include misreading the netmask in hex format, using the wrong interface name, and confusing ifconfig with Windows tools.

Exam traps often involve scenarios where an interface is down but has an IP address configured, leading learners to incorrectly believe it is functional. Mastering ifconfig builds a strong foundation for understanding how the operating system interacts with network hardware. By learning this command, IT certification candidates gain a practical tool for both exams and real-world network administration. The key takeaway is that ifconfig provides immediate, low-level insight into a computer's network connectivity, making it an indispensable part of any IT professional's diagnostic toolkit.