M4RKYU.SYSEdition 2027
Skip to content
LOCEN/Ontario · CA/▸logs · how to determine the network address from a known ip address 4895StandbyOK/--:--:--EST
M4M4RK_YUportfolio
  • BuildBuild
    BuildOverview
    • WorkSelected case studies and write-ups
    • GamesPlayable prototypes and game-dev logs
  • GalleryGallery
    GalleryOverview
    • PhotosPhoto collections and visual experiments
    • ShopPrints, posters, and one-off objects
  • WritingWriting
    WritingOverview
    • BlogLong-form devlogs and field notes
    • NotesShort observations, links, snippets
  • ResourcesResources
    ResourcesOverview
    • Tools38 in-browser developer utilities
    • LinksDaily-use dev and design bookmarks
  • AboutAbout
  • ContactContact
中文

syndicated · dev.to / @markyu

Network Address Calculation: The Subnet Math That Matters

A practical subnetting guide showing how to calculate a network address from an IP address and mask using binary math and simple examples.

Published
Oct 16 '24
·
Reading time
2 min read
·
Reactions
5
networkingbeginnersdevopssecurity
View on dev.to

On this page

  • The Rule
  • Example: 192.168.10.37/24
  • Example: 192.168.10.37/26
  • Quick Mental Shortcut
  • Python Check
  • Why Developers Should Care
  • Final Thought

Subnet math feels annoying until you need to debug a firewall rule, Kubernetes network policy, VPN route, or cloud security group.

Then suddenly this question matters:

Given an IP address and subnet mask, what network is it actually in?

Let’s calculate it directly.

The Rule

network address = IP address AND subnet mask

That is it.

The AND operation compares bits:

IP bitMask bitResult
000
010
100
111

Example: 192.168.10.37/24

/24 means the subnet mask is:

255.255.255.0

IP:

192.168.10.37

Mask:

255.255.255.0

Network:

192.168.10.0

With /24, the first three octets are the network part. The last octet is host space.

Example: 192.168.10.37/26

/26 is more interesting.

Mask:

255.255.255.192

The last octet in binary:

IP:   37  = 00100101
Mask: 192 = 11000000
AND:       00000000

So the network address is:

192.168.10.0/26

The /26 networks in the last octet move in blocks of 64:

NetworkHost range
192.168.10.0/26.1 - .62
192.168.10.64/26.65 - .126
192.168.10.128/26.129 - .190
192.168.10.192/26.193 - .254

37 falls into the first block.

Quick Mental Shortcut

For masks in the last octet:

block size = 256 - mask_octet

For /26:

256 - 192 = 64

So networks start at:

0, 64, 128, 192

Find the block that contains the IP.

Python Check

import ipaddress

ip = ipaddress.ip_interface("192.168.10.37/26")
print(ip.network)

Output:

192.168.10.0/26

This is what I use when I do not want to trust my tired brain during network debugging.

Why Developers Should Care

Subnet mistakes show up in:

  • cloud VPC rules
  • Docker/Kubernetes networking
  • VPN routing
  • database allowlists
  • office network debugging
  • zero-trust access rules

One wrong CIDR can expose too much or block the service you need.

Final Thought

Subnetting is not glamorous, but it is one of those fundamentals that saves time when production networking gets weird.

What subnet or CIDR mistake has bitten you before?

Related reading

Docker Containers: The Commands That Prove Isolation

A practical Docker container guide focused on the commands that show image layers, process isolation, networking, volumes, and debugging.

docker

Frontend Linear Data Structures Deep Dive: Arrays, Stacks, Queues, and Linked Lists

The Big Picture Before diving into stacks, queues, and linked lists, it helps to know...

computerscience

JS Sorting Algorithms Every Developer Should Know

You call .sort() every day without thinking about it. But the sorting algorithm your language's...

algorithms

originally published

This post first ran on dev.to. Comments and reactions live there.

Continue on dev.to
PreviousJava BeanUtils Copying: Convenient, but Not FreeA practical Java guide to BeanUtils, shallow copy pitfalls, reflection overhead, and when MapStruct or manual mapping is a better choice.
Back to all posts
NextBad Data Quality Costs More Than a Slow QueryA practical data quality guide for engineers: validation, ownership, schema drift, observability, and fixing bad data before dashboards lie.
Back to archive
M4RKYUM4RKYUM4RKYUM4RKYUM4RKYUM4RKYUM4RKYUM4RKYU
Crafted since 2024
ZhenXiao Mark YuZhenXiao Mark Yu
get in touch

Saw something here?Tell me about it.

It's a portfolio, not a service · but I read every note — drop a line if anything here resonated, or just to say hi.

Start a conversation
open channel

say hi anytime · 2026

--:--:--ESTOntario, Canada
  • Email
  • GitHub
  • dev.to
  • LinkedIn
  • Twitter / X
  • Instagram
  • Facebook
  • YouTube
  • CodePen
  • Spotify
  • Snapchat

Newsletter

Get the occasional dispatch

Notes and logs from m4rkyu.com — short, dated, no noise. Unsubscribe anytime.

Work

Production builds, games, and visual archives.

  • Projects
  • Games
  • Archive
  • Logs

Resources

Daily-use tools and a personal link library.

  • Search
  • Latest
  • Tools
  • Links
  • Notes
  • Topics
  • Shop
RSSJSON feed

Studio

Background, contact, and channels for collaboration.

  • About
  • Contact
  • Changelog
  • Colophon
  • Resumepending

Socials

Find me on the usual feeds.

  • GitHub
  • dev.to
  • LinkedIn
  • Twitter / X
  • Instagram
  • Facebook
  • YouTube
  • CodePen
  • Spotify
  • Snapchat
  • Email
© 2026 ZhenXiao Mark Yumarkyu0615@gmail.com
  • Email
  • GitHub
  • dev.to
  • LinkedIn
  • Twitter / X
  • Instagram
  • Facebook
  • YouTube
  • CodePen
  • Spotify
  • Snapchat
PrivacyTermsBuilt with Next.js 16 · React 19 · Tailwind 4