100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace

What is a Subnet Mask?

Learn what a subnet mask is, how it splits network and host bits, and how to calculate usable hosts — with interview Q&A.

easyQ124 of 234 in Computer Networks Est. time: 5 minsLast updated:
Open Code Lab
124 / 234

Expected Interview Answer

A subnet mask is a 32-bit value paired with an IPv4 address that tells a device which bits of the address identify the network and which bits identify the specific host, so it can determine whether a destination is on the local network or must be reached through a router.

Written in the same dotted-decimal form as an IP address (e.g., 255.255.255.0) or as a CIDR prefix length (e.g., /24), the subnet mask has contiguous 1 bits covering the network portion and contiguous 0 bits covering the host portion; a bitwise AND of the IP address and the mask yields the network address. For example, with IP 192.168.1.10 and mask 255.255.255.0 (/24), the network is 192.168.1.0 and the host portion is the final octet, giving 254 usable host addresses (256 total minus the network and broadcast addresses). When a device needs to send a packet, it applies its own subnet mask to both its own IP and the destination IP: if they land in the same network, the packet is delivered directly on the local segment (resolved via ARP); if not, the device forwards the packet to its default gateway for routing. Longer masks (like /26 or /30) create smaller subnets with fewer hosts, which is the basis of subnetting and VLSM (Variable Length Subnet Masking) for efficient address allocation.

  • Lets a device split an IP address into network and host portions
  • Determines whether a destination is local or needs a gateway
  • Enables subnetting to size networks appropriately (fewer wasted addresses)
  • Maps directly to CIDR prefix notation for concise configuration

AI Mentor Explanation

A subnet mask is like the rule that says the first two digits of a seat code identify the stand and the last two digits identify the exact seat within it — an usher applies that same rule to any ticket to instantly know whether a fan belongs in this stand or needs directing elsewhere. Applying the rule consistently is what lets an usher sort thousands of fans quickly instead of checking every seat individually. A device applying its subnet mask to an IP address works exactly the same way, splitting it into network and host portions. Getting the digit-split rule wrong would send fans to the wrong stand, just as a wrong mask misroutes packets.

Step-by-Step Explanation

  1. Step 1

    Pair mask with IP

    A subnet mask (e.g., 255.255.255.0 or /24) is assigned alongside a device's IP address.

  2. Step 2

    Bitwise AND

    The device ANDs its IP with the mask to determine its own network address.

  3. Step 3

    Compare destinations

    For any destination IP, the same mask determines if it falls in the same network (local) or a different one (remote).

  4. Step 4

    Route or deliver locally

    Local destinations are resolved via ARP and delivered directly; remote destinations are sent to the default gateway.

What Interviewer Expects

  • Correct definition: separates network bits from host bits in an IP address
  • Can convert between dotted-decimal mask and CIDR prefix notation
  • Can calculate network address, broadcast address, and usable hosts for a given mask
  • Explains how the mask decides local delivery vs default gateway routing

Common Mistakes

  • Forgetting to subtract network and broadcast addresses when counting usable hosts
  • Confusing subnet mask with a wildcard mask (used in ACLs, which is inverted)
  • Assuming all networks default to a /24 (255.255.255.0)
  • Not knowing the mask determines local-vs-gateway forwarding decisions

Best Answer (HR Friendly)

A subnet mask is like the rule that tells you which part of a street address is the neighborhood and which part is the house number — it lets a computer figure out whether another device is on the same local network or needs to be reached through a router. Without it, a device would not know whether to deliver data directly or send it out to the wider network.

Code Example

Inspecting subnet mask and computing the network address
# Show this machine’s IP address and subnet mask (Linux)
ip -4 addr show eth0
# inet 192.168.1.10/24 brd 192.168.1.255 scope global eth0

# Convert /24 to dotted-decimal and inspect network/broadcast/hosts
ipcalc 192.168.1.10/24
# Netmask:   255.255.255.0 = 24
# Network:   192.168.1.0/24
# HostMin:   192.168.1.1
# HostMax:   192.168.1.254
# Broadcast: 192.168.1.255

Follow-up Questions

  • How do you calculate the number of usable hosts from a subnet mask?
  • What is the difference between a subnet mask and a wildcard mask?
  • How does a device decide to use its default gateway based on the mask?
  • What is VLSM and why does it need variable-length masks?

MCQ Practice

1. What does a subnet mask primarily determine?

A subnet mask separates the network portion of an IP address from the host portion.

2. What is the dotted-decimal form of a /24 subnet mask?

A /24 prefix corresponds to 255.255.255.0, leaving the last octet for host addresses.

3. How many usable host addresses does a /24 subnet have?

A /24 has 256 total addresses; subtracting the network and broadcast addresses leaves 254 usable hosts.

Flash Cards

What is a subnet mask?A 32-bit value that separates the network portion of an IP address from the host portion.

/24 in dotted decimal?255.255.255.0.

How is the network address computed?By bitwise ANDing the IP address with the subnet mask.

What decides local delivery vs gateway routing?Comparing the destination IP against the local network using the subnet mask.

1 / 4
124 / 234

Continue Learning

Frequently Asked Questions

21 categories · pick one to explore

Where can I practice technical interview questions for free in India?
SkillVeris offers a free interview questions section with readiness scoring, so you can practice technical interview questions at no cost from anywhere in India or worldwide. Questions span AI/ML, programming, web development, DevOps, cloud and security. Combine them with Code Lab for hands-on coding practice and the AI Mentor for instant explanations whenever an answer confuses you.
How do I prepare for a coding interview if I am a complete beginner?
Start by learning one language well, then practice small problems daily before attempting interview questions. On SkillVeris you can take a free structured programming course with 24–40 lessons, write code in the in-browser Code Lab across 6 languages, and then move to the interview questions bank with readiness scoring to measure how prepared you actually are.
What is interview readiness scoring and how does it work?
Interview readiness scoring measures how prepared you are for a technical interview based on your performance across practice questions. On SkillVeris, as you answer interview questions, your readiness score updates so you can see weak topics before the real interview. It turns vague confidence into a concrete signal, telling you which areas need more revision and which are already strong.
How long does it take to get interview ready for a developer job?
Most beginners need a few months of consistent practice to feel interview ready, though timelines vary with background and daily study time. A practical route is finishing a structured SkillVeris course, which includes 24–40 lessons, module assessments and a final exam at an 80 percent pass mark, then drilling the free interview questions until your readiness score is consistently strong.
What are the most common technical interview topics for freshers?
Freshers are commonly tested on programming fundamentals, data structures, problem solving, databases, and basics of the role's stack such as web development or cloud. SkillVeris covers these through 37 free courses, a glossary of around 2,000 terms for quick definitions, cheat sheets for revision, and interview questions with readiness scoring so you can practise exactly what interviewers usually ask.
Can I practice coding interview prep without installing anything?
Yes, SkillVeris Code Lab runs entirely in your browser, so you can practice coding interview prep without installing compilers or editors. It supports 6 languages across 15 categories of exercises. Pair Code Lab sessions with the interview questions bank and readiness scoring, and you have a complete free preparation setup that works on any machine with an internet connection.
How do I explain technical concepts clearly in an interview?
Practice explaining each concept through a simple analogy first, then add the technical detail, because interviewers value clarity over jargon. SkillVeris teaches with its Learn Through Hobbies method, explaining concepts through cricket, music, gaming, cooking and eight more domains. Learning a topic through an analogy gives you a ready-made, memorable way to explain it when an interviewer asks.
Are there free mock interview resources for software engineers?
SkillVeris provides free interview questions with readiness scoring, which works like a self-paced mock interview you can repeat any time. You answer real-style technical questions, get scored, and see where you stand. The AI Mentor is available 24/7 to explain any answer at Quick, Detailed or Deep-dive depth, acting like an always-available interviewer who never gets tired.
How should I prepare for an AI or machine learning interview?
Cover ML fundamentals, Python, and modern topics like LLMs and RAG, then practise explaining projects clearly. SkillVeris has free AI/ML courses including Python for AI and ML, Large Language Models and Retrieval-Augmented Generation, each with 24–40 lessons and assessments. After finishing, use the interview questions bank and readiness scoring to confirm you can answer under pressure.
What should I revise the night before a technical interview?
Revise concise summaries rather than learning anything new: core definitions, common patterns, and your own project stories. SkillVeris cheat sheets and study notes are built exactly for this kind of quick revision, and the glossary of around 2,000 terms lets you verify any definition fast. A short readiness-score check on the interview questions bank confirms nothing critical is shaky.
How do I prepare for a DevOps interview with no work experience?
Build demonstrable knowledge through structured learning and hands-on practice, since you cannot point to job experience. SkillVeris offers free DevOps, Docker and Kubernetes related courses within its 37-course catalog and a DevOps Engineer learning path. Complete the courses, earn certificates by passing the final exams, then use the interview questions section to rehearse common DevOps scenarios.
Do certificates help in clearing technical interviews?
Certificates alone do not clear interviews, but they signal structured learning and give interviewers a starting point for questions. SkillVeris awards certificates when you pass a course final exam at 80 percent, after 24–40 lessons and module assessments, so the certificate reflects genuine effort. Pair it with practised interview answers and Code Lab projects to make a stronger impression.
How can I improve my problem solving speed for coding interviews?
Speed comes from repetition on progressively harder problems, not from rushing. Practise daily in SkillVeris Code Lab, which offers in-browser coding in 6 languages across 15 categories, and time yourself on interview questions. Review every mistake with the AI Mentor, which explains solutions 24/7 at Quick, Detailed or Deep-dive depth, so each session genuinely improves your pattern recognition.
What questions are asked in a Python technical interview?
Python interviews typically cover data types, functions, comprehensions, OOP, error handling and libraries relevant to the role, such as ML packages for AI positions. SkillVeris interview questions include Python topics, and its free Python for AI and ML course builds the underlying knowledge across 24–40 lessons. Readiness scoring then shows whether your Python answers are interview grade.
How do I handle interview questions I don't know the answer to?
Say what you do know, reason aloud toward an approach, and be honest about the gap, because interviewers value thinking over bluffing. Reduce how often this happens by broadening fundamentals: SkillVeris study notes, cheat sheets and the roughly 2,000-term glossary fill knowledge gaps quickly, and readiness scoring highlights weak areas before an interviewer ever finds them.
Is there a free way to check my interview readiness before applying for jobs?
Yes, SkillVeris interview questions come with readiness scoring, all completely free, so you can measure preparation before applying. Once your score looks solid, browse the SkillVeris Jobs page, which aggregates live roles across India, UK, USA, Germany and Remote with salary and experience filters, and apply knowing your technical preparation has been objectively tested.
How do I prepare for web developer interview questions?
Focus on JavaScript fundamentals, your framework of choice, HTTP basics, and building things you can discuss. SkillVeris offers free web development courses among its 37-course catalog, plus a Full Stack Java Developer learning path. After the courses, drill the interview questions bank, practise coding tasks in Code Lab, and use readiness scoring to verify you cover typical frontend and backend topics.
Can the AI Mentor help me practice interview answers?
Yes, the SkillVeris AI Mentor answers questions 24/7 and can explain any concept at Quick, Detailed or Deep-dive depth, which makes it useful for rehearsing interview explanations. Ask it to clarify a topic, then try explaining it back in your own words. Combined with the interview questions bank and readiness scoring, it becomes a free, always-available practice partner.
What is the best free platform for technical interview prep in 2026?
SkillVeris is a strong free option because it combines structured learning with dedicated interview preparation in one place. You get 37 free courses, interview questions with readiness scoring, an in-browser Code Lab for hands-on practice, cheat sheets and study notes for revision, and a 24/7 AI Mentor. Everything is free, which matters for learners in India and worldwide.
How do I stay calm and confident during a technical interview?
Confidence comes from evidence of preparation, so build that evidence deliberately. Complete a SkillVeris course, pass its final exam at the 80 percent bar, and watch your readiness score climb on the interview questions bank. Knowing you have explained concepts through analogies, coded in Code Lab, and scored well on practice questions gives you genuine, grounded calm on the day.

What Learners Say

Real journeys from the SkillVeris community — swipe for more.

SkillVeris taught me Python through Cricket. Now I’m building real projects and feeling confident!
Arjun S. · B.Tech Student
The best platform for hobby-based learning. Concepts finally stick.
Priya R. · Data Analyst
I went from zero coding to a portfolio of projects — all by learning through my love for gaming. Landed my first internship!
Kabir M. · CS Undergraduate
Trending Topics50 popular tags — tap to explore
Trending CoursesAll 37 free courses — tap to browse