Mastering IP Addresses: From ifconfig to CIDR and Beyond
Learn how to view and interpret IP addresses on Windows and Linux using commands like ipconfig, ifconfig, and ip addr, understand the differences between ifconfig and ip addr, explore IPv4 classes, CIDR notation, public vs private IPs, and MAC addresses, and network interface flags.
When interviewers ask "Do you know how to check an IP address?", many candidates feel the question is too simple for a technical role. In reality, the answer is straightforward: on Windows use ipconfig, on Linux use ifconfig, and a more modern Linux command is ip addr.
Beyond ifconfig, Linux also provides ip addr to display IP information. If you cannot answer this, you probably have not used Linux much.
Difference between ifconfig and ip addr
This is a historical story about net-tools and iproute2. On a minimal Linux system you may find neither command installed; you can install them with the packages net-tools and iproute2, though most distributions include them by default.
Running ip addr typically produces output like the following:
root@test:# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether fa:16:3e:c7:79:75 brd ff:ff:ff:ff:ff:ff
inet 10.100.122.2/24 brd 10.100.122.255 scope global eth0
inet6 fe80::f816:3eff:fec7:7975/64 scope linkThis output lists all network interfaces. Most interfaces have an IP address, which functions like a door number in the network world. If two devices share the same IP, an address conflict occurs, leading to connectivity problems.
In the example, 10.100.122.2 is an IP address composed of four octets, each 8 bits, totaling 32 bits. The limited address space led to the creation of IPv6, shown in the output as fe80::f816:3eff:fec7:7975/64, which uses 128 bits.
IPv4 originally defined three classes (A, B, C). Each class splits the 32‑bit address into a network part and a host part. Class A provides many networks with few hosts, class B balances both, and class C offers many hosts per network but only 254 hosts per network, which is often insufficient.
CIDR (Classless Inter‑Domain Routing)
To overcome the rigid class system, CIDR was introduced. An address like 10.100.122.2/24 means the first 24 bits are the network prefix and the remaining 8 bits are the host identifier.
With CIDR comes the concept of a broadcast address ( 10.100.122.255) and a subnet mask ( 255.255.255.0). Performing a bitwise AND between the IP and the mask yields the network address 10.100.122.0.
Public vs. Private IP Addresses
In everyday use, most people only remember CIDR, but it is still important to distinguish public and private IP ranges. Private IPs (e.g., 192.168.0.x) are used inside homes, offices, or campuses and can be reused across different organizations, whereas public IPs are globally unique and must be obtained from an Internet registry.
For example, the first address in a /24 network is typically the gateway (e.g., 192.168.0.1), and the broadcast address is .255. Devices within the same subnet communicate using MAC addresses.
MAC Addresses
The line link/ether fa:16:3e:c7:79:75 shows the MAC address, a 48‑bit hardware identifier expressed in hexadecimal. MAC addresses are unique to each network interface and function like a physical ID card; they are used for communication within the same broadcast domain but cannot replace IP addresses for routing across networks.
Network Interface Flags
Flags such as <BROADCAST,MULTICAST,UP,LOWER_UP> describe the state of an interface: UP means the interface is active, BROADCAST indicates it can send broadcast packets, MULTICAST allows multicast traffic, and LOWER_UP shows the physical link is present.
The MTU 1500 is the maximum transmission unit for Ethernet frames; if a packet exceeds this size, it must be fragmented.
The queueing discipline qdisc pfifo_fast organizes outgoing packets into three priority bands based on the Type‑of‑Service field in the IP header.
Summary
IP addresses provide location information; MAC addresses are hardware identifiers without routing capability.
CIDR determines whether an address belongs to the local network.
IP addresses are classified as public or private.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Open Source Linux
Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
