Bird
Raised Fist0
Interview Prepcomputer-networksmediumAmazonGoogleMicrosoftFlipkart

IP Addressing - IPv4, Subnet Mask, CIDR, Subnetting

Choose your preparation mode3 modes available
🎯
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. Which component in a CDN architecture is primarily responsible for serving cached content closest to the user to reduce latency?
easy
A. Edge server located near the user's geographic region
B. Origin server that stores the master copy of content
C. DNS server that resolves domain names to IP addresses
D. Load balancer distributing requests among origin servers

Solution

  1. Step 1: Identify the role of the origin server

    The origin server holds the original content but is usually far from the user, causing higher latency.
  2. Step 2: Understand the edge server's function

    Edge servers cache content closer to users geographically, reducing latency by serving requests locally.
  3. Step 3: Clarify DNS server's role

    DNS servers resolve domain names but do not serve content directly.
  4. Step 4: Load balancer's responsibility

    Load balancers distribute traffic among origin servers but do not cache content at the edge.
  5. Final Answer:

    Option A -> Option A
  6. Quick Check:

    Edge servers reduce latency by caching content near users, which is the core CDN principle.
Hint: Edge servers = cached content near users -> low latency
Common Mistakes:
  • Confusing origin server with edge server
  • Assuming DNS servers serve cached content
  • Thinking load balancers cache content
2. In which OSI layer would you most likely implement encryption to secure data before transmission?
easy
A. Presentation Layer
B. Transport Layer
C. Application Layer
D. Network Layer

Solution

  1. Step 1: Understand the role of the Presentation Layer

    The Presentation Layer is responsible for data translation, encryption, and compression before passing data to the Session Layer.
  2. Step 2: Why not other layers?

    Application Layer handles user interface and application services, Transport Layer manages end-to-end communication and reliability, Network Layer handles routing and addressing but not encryption.
  3. Final Answer:

    Option A -> Option A
  4. Quick Check:

    Encryption is a Presentation Layer function [OK]
Hint: Encryption and data formatting happen at the Presentation Layer [OK]
Common Mistakes:
  • Assuming encryption is done at the Application Layer
  • Confusing Transport Layer's reliability with security
  • Thinking Network Layer handles encryption
3. Which of the following statements about HTTP 4xx and 5xx status codes is INCORRECT?
medium
A. 4xx status codes indicate client-side errors, meaning the client must modify the request to succeed.
B. 5xx status codes indicate server-side errors, meaning the server failed to fulfill a valid request.
C. A 403 status code means the client is forbidden from accessing the resource, even if authenticated.
D. A 404 status code means the server is temporarily unavailable and the client should retry later.

Solution

  1. Step 1: Review meanings of 4xx and 5xx status codes

    4xx = client errors; 5xx = server errors.
  2. Step 2: Analyze each statement

    4xx status codes indicate client-side errors, meaning the client must modify the request to succeed. is correct: 4xx means client must fix request.
    5xx status codes indicate server-side errors, meaning the server failed to fulfill a valid request. is correct: 5xx means server failed.
    A 404 status code means the server is temporarily unavailable and the client should retry later. is incorrect: 404 means 'Not Found', not temporary unavailability; 503 indicates temporary server unavailability.
    A 403 status code means the client is forbidden from accessing the resource, even if authenticated. is correct: 403 means forbidden access regardless of authentication.
  3. Final Answer:

    Option D -> Option D
  4. Quick Check:

    404 is about missing resource, not server availability.
Hint: 404 = Not Found, 503 = Service Unavailable
Common Mistakes:
  • Confusing 404 with temporary server errors
  • Assuming 403 means unauthenticated rather than forbidden
  • Mixing client and server error categories
4. Which of the following statements about the scalability and overhead trade-offs between Distance Vector and Link State routing is TRUE?
medium
A. Distance Vector routing scales better in large networks because it floods link state advertisements less frequently
B. Distance Vector routing has lower convergence time but higher memory usage compared to Link State
C. Link State routing requires more memory and CPU but scales better due to faster convergence and less routing loops
D. Link State routing uses less bandwidth overall because it only sends updates when topology changes

Solution

  1. Step 1: Understand resource usage

    Link State routing stores the entire network topology, requiring more memory and CPU for Dijkstra's algorithm.
  2. Step 2: Analyze scalability and convergence

    Link State converges faster and avoids routing loops better, making it more scalable despite higher resource use.
  3. Step 3: Evaluate options

    Distance Vector routing scales better in large networks because it floods link state advertisements less frequently is false because Distance Vector does not flood link state advertisements at all. Distance Vector routing has lower convergence time but higher memory usage compared to Link State is false because Distance Vector generally has slower convergence and lower memory usage. Link State routing uses less bandwidth overall because it only sends updates when topology changes is misleading; Link State floods updates on topology changes, which can be bandwidth intensive.
  4. Final Answer:

    Option C -> Option C
  5. Quick Check:

    Link State trades higher resource use for better scalability and convergence.
Hint: More CPU/memory but faster convergence -> Link State scales better
Common Mistakes:
  • Assuming Distance Vector floods updates like Link State
  • Confusing convergence time and memory usage
  • Believing Link State sends fewer updates overall
5. In a network where ARP spoofing attacks are frequent, which advanced mitigation technique can be employed to detect and prevent such attacks beyond static ARP entries?
hard
A. Implementing dynamic ARP inspection (DAI) on switches to validate ARP packets against a trusted database.
B. Disabling ARP entirely and relying solely on IP addresses for communication.
C. Using DHCP snooping to assign static IP addresses to all devices.
D. Increasing the ARP cache timeout to reduce ARP traffic.

Solution

  1. Step 1: Understand advanced ARP spoofing mitigation

    Dynamic ARP Inspection (DAI) is a security feature on switches that intercepts ARP packets and verifies them against a trusted binding database.
  2. Step 2: Why not disabling ARP?

    ARP is essential for IP-to-MAC resolution; disabling it breaks local communication.
  3. Step 3: DHCP snooping is complementary but not sufficient

    DHCP snooping helps build trusted bindings but does not directly inspect ARP packets.
  4. Step 4: Increasing ARP cache timeout worsens spoofing risk

    Longer cache times mean stale or poisoned entries persist longer.
  5. Final Answer:

    Option A -> Option A
  6. Quick Check:

    DAI validates ARP packets to prevent spoofing effectively [OK]
Hint: DAI inspects ARP packets dynamically to prevent spoofing [OK]
Common Mistakes:
  • Thinking ARP can be disabled safely
  • Confusing DHCP snooping with ARP inspection
  • Believing longer ARP cache timeout improves security
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard