Understanding IP Addresses, CIDR, and MAC Addresses
This article explains how to view a machine's IP address on Windows and Linux, describes the structure and classification of IPv4 addresses, introduces CIDR subnetting, distinguishes public and private IP ranges, and clarifies the role and format of MAC addresses.
To view the local IP address on Windows, open a command prompt and run ipconfig for a brief view or ipconfig /all for detailed information. On Linux, if the net-tools package is installed, use ifconfig ; otherwise, the modern ip addr command provides the same data.
Below is a typical output of ip addr on a host:
<code># ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:16:3e:14:a2:5b brd ff:ff:ff:ff:ff:ff
inet 172.16.1.196/20 brd 172.16.15.255 scope global dynamic eth0
valid_lft 291113559sec preferred_lft 291113559sec</code>The output shows two network interfaces: the loopback lo and the Ethernet interface eth0 . The address 172.16.1.196 belongs to eth0 and is a 32‑bit IPv4 address, composed of four octets.
IPv4 addresses are divided into classes A, B, and C (the usable ones). The following table summarizes their ranges, private address blocks, subnet masks, number of networks, and maximum hosts per network:
Class
IP Range
Private Range
Subnet Mask
Network Count
Max Hosts per Network
A
1.0.0.1‑127.255.255.254
10.0.0.0‑10.255.255.255
255.0.0.0
126 (2⁷‑2)
16,777,214 (2²⁴‑2)
B
128.0.0.1‑191.255.255.254
172.16.0.0‑172.31.255.255
255.255.0.0
16,383 (2¹⁴‑1)
65,534 (2¹⁶‑2)
C
192.0.0.1‑223.255.255.254
192.168.0.0‑192.168.255.255
255.255.255.0
2,097,152 (2²¹‑1)
254 (2⁸‑2)
Because class C networks provide only 254 usable hosts, many organizations prefer Classless Inter‑Domain Routing (CIDR) to allocate address space more efficiently. CIDR expresses an address with a suffix indicating the number of leading 1 bits in the subnet mask, e.g., 172.16.1.196/20 . The /20 means the first 20 bits are the network portion, leaving 12 bits for host addresses, yielding 2¹²‑2 = 4094 usable hosts.
Calculating the network address involves a bitwise AND between the IP and the subnet mask. For the example above, the network address is 172.16.0.0 , the first usable host is 172.16.0.1 , and the last usable host is 172.16.15.254 . The broadcast address for the subnet is 172.16.15.255 .
In practice, most users remember CIDR notation rather than class A/B/C divisions, but it remains important to distinguish public and private IP ranges. Private IPs (10.x.x.x, 172.16‑31.x.x, 192.168.x.x) are used within local networks and are not routable on the public Internet, whereas public IPs are globally reachable.
Each network interface also has a MAC (Media Access Control) address, a 48‑bit hardware identifier displayed in the link/ether line, e.g., 00:16:3e:14:a2:5b . The MAC address is unique to the device but cannot be used for remote location; it functions like a physical ID, while the IP address provides logical, routable addressing.
Summary
IP addresses provide logical, routable identification; MAC addresses are unique hardware IDs without remote routing capability.
CIDR allows flexible subnetting by specifying the network prefix length.
IP addresses are categorized as public (Internet‑routable) or private (local network use).
php中文网 Courses
php中文网's platform for the latest courses and technical articles, helping PHP learners advance quickly.
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.