Bird
Raised Fist0
Interview Prepcomputer-networksmediumAmazonGoogleMicrosoftFlipkart

IP Addressing - IPv4, Subnet Mask, CIDR, Subnetting

Choose your preparation mode3 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
🎯
IP Addressing - IPv4, Subnet Mask, CIDR, Subnetting
mediumNETWORKSAmazonGoogleMicrosoft

Imagine managing a large office network where you need to efficiently allocate IP addresses to different departments without wasting addresses or causing conflicts.

💡 Beginners often confuse IP addresses as just random numbers or think subnet masks are optional, missing how these components work together to define network boundaries and hosts.
📋
Interview Question

Explain IPv4 addressing, subnet masks, CIDR notation, and the concept of subnetting. How do these components work together to organize and manage IP networks?

IPv4 address structure and classesSubnet mask role in separating network and host portionsCIDR notation and its advantages over classful addressingSubnetting to divide networks into smaller segments
💡
Scenario & Trace
ScenarioA company has a single Class C network 192.168.1.0/24 and wants to divide it into four smaller subnets for different departments.
The subnet mask 255.255.255.0 (or /24) is modified to 255.255.255.192 (/26) to create four subnets. Each subnet has 64 IP addresses (62 usable hosts). The network ID and host ID portions are recalculated accordingly, allowing department-specific IP ranges and efficient address management.
ScenarioAn ISP assigns IP addresses to customers using CIDR blocks instead of traditional classful addressing.
Instead of fixed class boundaries, the ISP uses CIDR notation like 203.0.113.0/22 to allocate a block of 1024 addresses. This flexible allocation reduces wasted IPs and simplifies routing by aggregating routes.
  • What if the subnet mask is incorrectly configured, causing overlapping subnets?
  • What happens when all host bits are set to zero or one in a subnet?
  • How does subnetting affect broadcast and network addresses?
  • What if a subnet is too small to accommodate required hosts?
⚠️
Common Mistakes
Confusing subnet mask with IP address

Interviewer doubts your understanding of network segmentation

Clarify that subnet mask is a separate 32-bit mask used to identify network vs host bits

Assuming classful addressing is still standard

Shows outdated knowledge, interviewer questions your current networking awareness

Explain CIDR as the modern standard replacing classful addressing for flexibility

Ignoring reserved network and broadcast addresses when subnetting

Leads to incorrect subnet size calculations and unusable IP assignments

Always exclude network and broadcast addresses from usable host count

Thinking subnet mask bits are always contiguous ones

Interviewer suspects lack of understanding of valid subnet masks and CIDR

Explain subnet masks must have contiguous ones from left to right; non-contiguous masks are invalid

🧠
Basic Definition - What It Is
💡 This level covers the essential vocabulary and purpose of IP addressing components.

Intuition

IP addresses identify devices; subnet masks define network boundaries.

Explanation

IPv4 addresses are 32-bit numbers divided into four octets, used to uniquely identify devices on a network. A subnet mask is a 32-bit number that masks the IP address to separate the network portion from the host portion. CIDR (Classless Inter-Domain Routing) notation expresses the subnet mask as a suffix (e.g., /24) indicating how many bits are used for the network. Subnetting is the process of dividing a larger network into smaller subnetworks to improve management and security.

Memory Hook

💡 Think of an IP address as a street address and the subnet mask as the city boundary that tells you which part is the city and which part is the house number.

Interview Questions

What is the purpose of a subnet mask?
  • Separates network and host portions of an IP address
  • Defines the size of the network
  • Helps routers determine if a destination is local or remote
Depth Level
Interview Time30 seconds
Depthbasic

Covers fundamental definitions and roles of IPv4, subnet masks, CIDR, and subnetting.

Interview Target: Minimum floor - never go below this

Knowing only this helps pass initial screening but lacks depth for technical interviews.

🧠
Mechanism Depth - How It Works
💡 This level explains the internal workings and practical application of subnetting and CIDR.

Intuition

Subnet masks and CIDR define network boundaries by masking bits, enabling flexible IP allocation and routing.

Explanation

IPv4 addresses are split into network and host parts using the subnet mask, which is a binary mask applied to the IP address. CIDR notation simplifies subnet mask representation by indicating the number of bits used for the network prefix. Subnetting involves borrowing bits from the host portion to create multiple smaller networks within a larger network, allowing better IP address utilization and traffic management. This process affects how routers forward packets and how devices recognize if a destination IP is on the same subnet or requires routing. Understanding reserved addresses like network ID (all host bits zero) and broadcast address (all host bits one) is critical to avoid assigning unusable IPs.

Memory Hook

💡 Imagine cutting a large pizza (network) into slices (subnets) by deciding how many slices you want (bits borrowed), with each slice having a fixed number of pieces (hosts).

Interview Questions

How does CIDR improve IP address allocation compared to classful addressing?
  • CIDR allows variable-length subnet masks
  • Reduces IP address wastage by allocating only needed addresses
  • Enables route aggregation to reduce routing table size
What happens if you assign the network or broadcast address to a host?
  • Network address identifies the subnet itself, not a host
  • Broadcast address is used to send packets to all hosts on subnet
  • Assigning these causes communication issues or conflicts
Depth Level
Interview Time2-3 minutes
Depthintermediate

Demonstrates understanding of subnetting mechanics, CIDR benefits, and IP address management.

Interview Target: Target level for FAANG on-sites

Mastering this level distinguishes you from most candidates and prepares you for detailed network discussions.

📊
Explanation Depth Levels
💡 Choose your depth based on interview stage and role requirements.
LevelInterview TimeSuitable ForRisk
Basic Definition30sScreening call or initial roundsToo shallow for on-site or system design interviews
Mechanism Depth2-3 minutesOn-site interviews at FAANG and top tech companiesRequires solid understanding; missing details may cause doubts
💼
Interview Strategy
💡 Use this guide to structure your explanation clearly and confidently before interviews.

How to Present

Start with a clear definition of IPv4 addressing and subnet masksUse a relatable analogy or example to illustrate subnettingExplain CIDR notation and how it differs from classful addressingDiscuss subnetting mechanics and reserved addressesMention common edge cases and their implications

Time Allocation

Definition: 30s → Example: 1min → Mechanism: 2min → Edge cases: 30s. Total ~4min

What the Interviewer Tests

Checks your grasp of IP address structure, subnetting logic, CIDR advantages, and practical network segmentation.

Common Follow-ups

  • How do you calculate the number of hosts per subnet given a subnet mask?
  • Explain the difference between public and private IP addresses.
💡 These follow-ups test your ability to apply concepts and understand real-world network design.
🔍
Pattern Recognition

When to Use

Asked when discussing IP networking fundamentals, subnet design, or routing basics.

Signature Phrases

'Explain IPv4 addressing and subnetting''What is CIDR and why is it used?''How do subnet masks work?'

NOT This Pattern When

Similar Problems

Practice

(1/5)
1. In which scenario is the DHCP Discover message primarily used during network configuration?
easy
A. When a client wants to renew an existing IP lease
B. When a client releases its IP address back to the server
C. When a DHCP server confirms the IP address assignment
D. When a client initially connects to a network and needs an IP address

Solution

  1. Step 1: Understand the role of DHCP Discover message

    The Discover message is the initial broadcast sent by a client to locate available DHCP servers and request an IP address.
  2. Step 2: Analyze other options

    When a client wants to renew an existing IP lease describes lease renewal, which uses the Request message, not Discover. When a client releases its IP address back to the server refers to releasing an IP, unrelated to Discover. When a DHCP server confirms the IP address assignment is about the server confirming the IP assignment, which is the Acknowledgment message.
  3. Final Answer:

    Option D -> Option D
  4. Quick Check:

    Discover is always the first message sent by a client seeking an IP address.
Hint: Discover = first client broadcast to find DHCP servers
Common Mistakes:
  • Confusing Discover with Request or Acknowledgment messages
  • Assuming Discover is used for lease renewal
  • Thinking Discover is sent by the server
2. You want to prevent unauthorized access to your internal network by filtering incoming and outgoing traffic based on IP addresses and ports. Which network component is best suited for this task?
easy
A. Proxy server acting as an intermediary for client requests
B. Firewall filtering traffic based on rules
C. Reverse proxy optimizing server load
D. Content Delivery Network (CDN) caching static content

Solution

  1. Step 1: Identify the role of each component

    Firewalls are designed to filter network traffic based on IP addresses, ports, and protocols, enforcing security policies.
  2. Step 2: Understand Proxy and Reverse Proxy roles

    Proxies forward client requests but do not primarily filter traffic at the network level; reverse proxies handle server-side requests and optimize load.
  3. Step 3: CDN role

    CDNs cache content to improve performance but do not filter traffic for security.
  4. Final Answer:

    Option B -> Option B
  5. Quick Check:

    Firewall is the component that filters traffic based on rules [OK]
Hint: Firewall filters traffic; proxies forward requests.
Common Mistakes:
  • Confusing proxy with firewall as a security filter
  • Assuming reverse proxy filters traffic like a firewall
3. When a TCP packet is lost during transmission, what sequence of events occurs internally before the data is successfully received?
easy
A. The sender immediately retransmits the lost packet without waiting for any signal
B. The receiver sends an acknowledgment for the last correctly received packet, triggering retransmission after timeout
C. The receiver sends a negative acknowledgment (NAK) to request retransmission of the lost packet
D. The sender continues sending new packets without retransmitting lost ones

Solution

  1. Step 1: Understand TCP reliability mechanism

    TCP uses acknowledgments (ACKs) to confirm receipt of packets.
  2. Step 2: Lost packet detection

    If a packet is lost, the sender does not receive an ACK for it within a timeout period.
  3. Step 3: Retransmission trigger

    After timeout, the sender retransmits the lost packet.
  4. Step 4: Evaluate options

    The receiver sends an acknowledgment for the last correctly received packet, triggering retransmission after timeout correctly describes the process. The sender immediately retransmits the lost packet without waiting for any signal is incorrect because retransmission waits for timeout or duplicate ACKs. The receiver sends a negative acknowledgment (NAK) to request retransmission of the lost packet is incorrect; TCP does not use NAKs. The sender continues sending new packets without retransmitting lost ones ignores retransmission, violating TCP reliability.
  5. Final Answer:

    Option B -> Option B
  6. Quick Check:

    TCP relies on ACK timeouts to detect loss and trigger retransmission.
Hint: TCP retransmits after timeout triggered by missing ACKs, not immediately or via NAKs.
Common Mistakes:
  • Believing TCP uses negative acknowledgments (NAKs)
  • Thinking retransmission happens immediately without waiting
  • Assuming sender ignores lost packets
4. Which of the following best explains why TCP's sliding window flow control alone cannot prevent network congestion?
medium
A. Because sliding window increases window size exponentially regardless of network state
B. Because sliding window only limits sender based on receiver buffer, not network capacity
C. Because sliding window retransmits lost packets too slowly
D. Because sliding window requires explicit congestion notification from routers

Solution

  1. Step 1: Understand sliding window's limitation

    Sliding window controls flow based on receiver's buffer availability, not network congestion.
  2. Step 2: Differentiate from congestion control

    Congestion control algorithms like AIMD adjust sending rate based on network feedback to avoid congestion.
  3. Step 3: Reject exponential increase and retransmission speed options

    Sliding window does not inherently increase window exponentially; retransmission speed is unrelated to flow control.
  4. Step 4: Clarify explicit congestion notification role

    Explicit congestion notification is optional and unrelated to sliding window's basic operation.
  5. Final Answer:

    Option B -> Option B
  6. Quick Check:

    Sliding window limits sender by receiver buffer, not network capacity.
Hint: Flow control = receiver buffer limit; congestion control = network capacity limit.
Common Mistakes:
  • Assuming sliding window adapts to network congestion
  • Confusing flow control with retransmission mechanisms
  • Believing sliding window depends on router signals
5. If a domain's authoritative DNS server is down, which of the following best describes how DNS resolution behaves assuming the recursive resolver has a cached entry with a TTL of 300 seconds that expired 10 seconds ago?
hard
A. The recursive resolver will attempt to query the authoritative server despite the expired TTL and return an error if unreachable.
B. The recursive resolver will return the expired cached record to the client to avoid resolution failure.
C. The recursive resolver will immediately return a SERVFAIL error to the client since the authoritative server is unreachable.
D. The recursive resolver will query the root server again to find an alternative authoritative server.

Solution

  1. Step 1: Understand TTL expiration

    Once TTL expires, cached records are considered stale and should not be served without validation.
  2. Step 2: Behavior on authoritative server failure

    The recursive resolver tries to refresh the record by querying the authoritative server.
  3. Step 3: Outcome if authoritative server is down

    If unreachable, the resolver returns an error (e.g., SERVFAIL) to the client.
  4. Step 4: Why other options are incorrect

    The recursive resolver will immediately return a SERVFAIL error to the client since the authoritative server is unreachable ignores retry attempt; The recursive resolver will return the expired cached record to the client to avoid resolution failure violates TTL rules by serving expired data; The recursive resolver will query the root server again to find an alternative authoritative server is incorrect because root servers do not provide alternative authoritative servers.
  5. Final Answer:

    Option A -> Option A
  6. Quick Check:

    Expired TTL triggers retry; failure returns error -> correct
Hint: Expired TTL means resolver must retry; failure leads to error, not stale data.
Common Mistakes:
  • Assuming expired cache is always served
  • Thinking root servers provide alternative authoritative servers
  • Believing resolver returns error immediately without retry