Tutorials Logic, IN info@tutorialslogic.com

IP Addressing IPv4, IPv6, Classes, CIDR

IP Addressing IPv4, IPv6, Classes, CIDR

IP is a practical Networking topic that becomes clear when you connect the definition to a small working example.

Use this page to understand what happens, why it happens, how to verify it, and what mistake usually breaks the concept.

After reading, practice IP with a normal case, a boundary case, and a broken case so the idea becomes usable instead of memorized.

IP Addressing IPv4 IPv6 Classes CIDR should be studied as a practical Networking lesson, not as a label. Start by naming the input, the rule that changes the input, and the result a learner should be able to predict after reading the page.

In the networking > ip-addressing page, the notes should connect the definition with a working scenario, a mistake that beginners actually make, and the exact check that proves the fix. That makes the topic useful for coding, debugging, and interview revision.

IPv4 Addressing

An IPv4 address is a 32-bit number written in dotted decimal notation - four octets (8-bit groups) separated by dots. Each octet ranges from 0 to 255.

Example: 192.168.1.100 = 11000000.10101000.00000001.01100100 in binary

IPv4 Address Classes

Class First Octet Range Default Subnet Mask Networks Hosts/Network Use
A 1 - 126 255.0.0.0 (/8) 126 16,777,214 Large organizations
B 128 - 191 255.255.0.0 (/16) 16,384 65,534 Medium organizations
C 192 - 223 255.255.255.0 (/24) 2,097,152 254 Small organizations
D 224 - 239 N/A N/A N/A Multicast
E 240 - 255 N/A N/A N/A Reserved/Experimental

Special IP Addresses

Address/Range Purpose
127.0.0.0 - 127.255.255.255 Loopback (localhost) - 127.0.0.1 is most common
10.0.0.0 - 10.255.255.255 Private Class A (RFC 1918)
172.16.0.0 - 172.31.255.255 Private Class B (RFC 1918)
192.168.0.0 - 192.168.255.255 Private Class C (RFC 1918)
169.254.0.0 - 169.254.255.255 APIPA (Automatic Private IP Addressing) - when DHCP fails
0.0.0.0 Default route / unspecified address
255.255.255.255 Limited broadcast (all hosts on local network)

Unicast, Multicast, and Broadcast

  • Unicast: One-to-one communication. A packet is sent from one source to one specific destination. Most common type.
  • Broadcast: One-to-all communication. A packet is sent to all devices on a network. Example: 192.168.1.255 (directed broadcast for 192.168.1.0/24).
  • Multicast: One-to-many communication. A packet is sent to a group of interested receivers. Uses Class D addresses (224.0.0.0 - 239.255.255.255).
  • Anycast: One-to-nearest communication. A packet is sent to the nearest node in a group. Used in IPv6 and CDNs.

IPv6 Addressing

IPv6 uses 128-bit addresses written as 8 groups of 4 hexadecimal digits separated by colons.

Example: 2001:0db8:85a3:0000:0000:8a2e:0370:7334

Abbreviation rules:

  • Leading zeros in each group can be omitted: 0db8 -> db8
  • One consecutive group of all-zero groups can be replaced with ::: 2001:db8::8a2e:370:7334

IPv4 vs IPv6

Feature IPv4 IPv6
Address Size 32 bits 128 bits
Address Format Dotted decimal (192.168.1.1) Hexadecimal colon notation
Total Addresses ~4.3 billion ~340 undecillion
Header Size 20-60 bytes (variable) 40 bytes (fixed)
NAT Required Yes (address exhaustion) No (enough addresses)
Security Optional (IPSec) Built-in (IPsec mandatory)
Broadcast Yes No (uses multicast/anycast)
Auto-configuration DHCP SLAAC (Stateless Address Autoconfiguration)

IPv6 Address Types

Type Prefix Purpose Example
Global Unicast 2000::/3 Routable Internet addresses 2001:db8::1
Link-Local fe80::/10 Communication on same link fe80::1
Unique Local fc00::/7 Private addressing (like RFC 1918) fc00::1
Multicast ff00::/8 One-to-many communication ff02::1
Loopback ::1 Local host (like 127.0.0.1) ::1
Unspecified :: Default route (like 0.0.0.0) ::

Subnet Masking and CIDR

Subnet masks divide IP addresses into network and host portions. CIDR (Classless Inter-Domain Routing) replaces class-based addressing with flexible subnetting.

CIDR Subnet Mask Network Bits Host Bits Total Hosts Usable Hosts
/8 255.0.0.0 8 24 16,777,216 16,777,214
/16 255.255.0.0 16 16 65,536 65,534
/24 255.255.255.0 24 8 256 254
/25 255.255.255.128 25 7 128 126
/26 255.255.255.192 26 6 64 62
/27 255.255.255.224 27 5 32 30
/28 255.255.255.240 28 4 16 14
/29 255.255.255.248 29 3 8 6
/30 255.255.255.252 30 2 4 2
/31 255.255.255.254 31 1 2 0
/32 255.255.255.255 32 0 1 1

IP Address Assignment Methods

DHCP automatically assigns IP addresses to devices on a network. The DHCP process involves four steps:

Method Advantages Disadvantages Use Cases
Static IP Consistent address, no DHCP dependency, easy to remember Manual configuration, potential conflicts, less flexible Servers, printers, routers, infrastructure devices
Dynamic IP Automatic configuration, no conflicts, efficient address usage Address changes, requires DHCP server, less predictable Client computers, mobile devices, temporary connections
  • DHCPDISCOVER: Client broadcasts request for IP address
  • DHCPOFFER: Server offers available IP address
  • DHCPREQUEST: Client requests the offered address
  • DHCPACK: Server acknowledges and assigns the address

Network Address Translation (NAT)

NAT allows multiple devices to share a single public IP address by translating private addresses to public ones. It was developed to address IPv4 address exhaustion.

Benefits Limitations
Conserves IPv4 addresses Breaks end-to-end connectivity
Provides basic security (hides internal network) Problems with peer-to-peer applications
Allows network renumbering Complicates VoIP and video conferencing
Reduces need for public addresses Performance overhead
  • Static NAT: One-to-one mapping between private and public addresses
  • Dynamic NAT: Many-to-many mapping from a pool of public addresses
  • PAT (Port Address Translation): Many-to-one mapping using different ports (most common)
  • NAT Overload: Another term for PAT, overloading a single public IP

IPv6 Address Configuration

SLAAC allows devices to automatically configure their own IPv6 addresses without a central server:

  • Device creates link-local address (fe80::/10)
  • Device discovers network prefix via Router Advertisement
  • Device combines prefix with interface identifier
  • Device performs Duplicate Address Detection (DAD)
  • EUI-64: Derived from MAC address (privacy concerns)
  • Privacy Extensions: Random temporary addresses
  • Stable Privacy: Random but stable addresses
  • Manual: Manually configured interface ID

IP Address Planning and Best Practices

  • Use RFC 1918 private addresses for internal networks
  • Reserve address ranges for different purposes (servers, printers, DHCP, etc.)
  • Document address assignments in a central registry
  • Plan for growth by allocating larger subnets initially
  • Use consistent addressing schemes across locations
  • Assign /48 prefixes to sites for easy routing
  • Use /64 subnets for LAN segments (standard practice)
  • Implement IPv6 alongside IPv4 (dual-stack)
  • Plan address hierarchy for efficient routing
  • Consider privacy addressing for client devices

IP Address Troubleshooting

Command Purpose Example Usage
ipconfig / ifconfig Show IP configuration ipconfig /all (Windows)
ping Test connectivity ping 8.8.8.8
tracert / traceroute Trace network path tracert google.com
nslookup DNS resolution test nslookup google.com
arp -a Show ARP table arp -a
netstat -rn Show routing table netstat -rn
  • IP Conflicts: Multiple devices with same IP address
  • Incorrect Subnet Mask: Devices can't reach other networks
  • Default Gateway Issues: No internet connectivity
  • DNS Resolution Problems: Can't resolve domain names
  • DHCP Failures: Devices can't get IP addresses

IP Security Considerations

  • Use private addressing for internal networks (RFC 1918)
  • Implement firewalls to control traffic between networks
  • Disable unused services that might expose IP addresses
  • Use IPsec for secure communication between sites
  • Monitor for IP spoofing and unauthorized address usage
  • Implement DHCP snooping to prevent rogue DHCP servers
  • IP Spoofing: Forging source IP addresses
  • Smurf Attacks: ICMP echo requests to broadcast addresses
  • SYN Floods: Overwhelming servers with connection requests
  • DNS Amplification: Using DNS servers for DDoS attacks
  • ARP Poisoning: Corrupting ARP tables for man-in-the-middle attacks

Future of IP Addressing

  • Mobile Networks: 4G/5G networks heavily use IPv6
  • Cloud Services: Major cloud providers support IPv6
  • Content Delivery: CDNs increasingly support IPv6
  • Government Mandates: Some countries require IPv6 support
  • IoT Devices: IPv6 essential for massive IoT deployments
  • IPv6-only Networks: Eliminating IPv4 entirely
  • NAT64/DNS64: IPv6 to IPv4 translation mechanisms
  • Segment Routing: Advanced routing with IPv6
  • programmable addressing: SDN-based address management
  • Zero Trust Networking: Identity-based access control

Deep Study Notes for IP

IP should be learned as a practical Networking skill, not only as a definition. Start by asking what problem the topic solves, what input or state it receives, what rule it applies, and what visible result proves it worked.

A strong explanation of IP includes the normal case, a boundary case, and a failure case. When you practice, write down the before-state, the operation, the after-state, and the reason the result changed.

This lesson was expanded because the audit reported: no code/example block; limited checklist/practice/mistake/FAQ notes . The added notes below focus on clearer explanation, more examples, and concrete practice so the topic is easier to understand from the page itself.

  • Define the exact problem solved by IP before looking at syntax.
  • Trace one small example by hand and describe every step in plain language.
  • Identify what changes when the input is empty, repeated, invalid, delayed, or larger than expected.
  • Connect the topic to a realistic project scenario instead of treating it as isolated theory.
  • Verify your answer with output, logs, query results, browser behavior, compiler feedback, or a state table.

Worked Explanation: Using IP Correctly

Imagine you are adding IP to a small learning project. The first step is to choose the smallest scenario that still shows the main idea. Avoid starting with a large production design; it hides the concept behind too many details.

Next, isolate the moving parts. Name the input, the rule, the output, and the possible error. This habit makes the topic easier to debug because you can see whether the problem is caused by bad data, wrong configuration, incorrect syntax, timing, permissions, or misunderstanding of the rule.

Finally, compare two versions: one correct version and one intentionally broken version. The broken version is valuable because it teaches you how the topic fails in real work, which is usually what interviews and debugging tasks test.

  • Normal case: show the expected behavior with simple, valid input.
  • Boundary case: test the smallest, largest, empty, repeated, or unusual value that still belongs to the topic.
  • Failure case: introduce one realistic mistake and explain the symptom it creates.
  • Repair step: change one thing at a time so you know exactly what fixed the problem.

IP packet-flow walkthrough

IP packet-flow walkthrough
Client device
  -> local network interface
  -> default gateway or switch
  -> routing/security decision
  -> destination service

For IP, explain each hop by naming the address, protocol, port, and decision made at that layer.

IP troubleshooting commands

IP troubleshooting commands
ipconfig /all
ping example.com
nslookup example.com
tracert example.com
netstat -ano

# Read the output in order: local config, name resolution, reachability, path, and open connections.
Key Takeaways
  • State the purpose of IP in one sentence before using it.
  • Create a tiny Networking example that demonstrates the topic without unrelated code.
  • Test one normal input, one edge input, and one incorrect input for IP.
  • Explain the result using before-state, operation, and after-state.
  • Add a verification step such as output, logs, query results, browser behavior, or compiler feedback.
Common Mistakes to Avoid
WRONG Memorizing IP as a definition only.
RIGHT Pair the definition with a small working example and a failure example.
The fastest way to remember the topic is to explain why the output changes.
WRONG Copying syntax without checking the state before and after.
RIGHT Write the input state, apply the rule, then inspect the output state.
State tracing turns confusing behavior into a visible sequence.
WRONG Ignoring the error path for IP.
RIGHT Create one intentionally broken version and document the symptom and fix.
A page is much easier to learn from when it explains both success and failure.
WRONG Memorizing IP Addressing IPv4 IPv6 Classes CIDR without the situation where it is useful.
RIGHT Connect IP Addressing IPv4 IPv6 Classes CIDR to a concrete Networking task.
Purpose makes syntax easier to recall.

Practice Tasks

  • Build the smallest working demo for IP and write what each line does.
  • Change one input or setting and predict the result before running it.
  • Break the example in a realistic way, then fix it and describe the repair.
  • Create a two-column note comparing when to use IP and when another approach is better.
  • Explain IP aloud as if teaching a beginner who knows basic Networking only.

Frequently Asked Questions

Understand the problem it solves, the input or state it works on, and the visible result that proves the concept is working.

Use one tiny correct example, one boundary example, and one broken example. Compare the output or state after each change.

They often memorize the term without tracing the behavior. Tracing makes the rule easier to remember and debug.

Remember the problem it solves in Networking, then attach the syntax or steps to that problem.

Ready to Level Up Your Skills?

Explore 500+ free tutorials across 20+ languages and frameworks.