<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Amol Kamble</title>
    <description>The latest articles on DEV Community by Amol Kamble (@ammyskamble).</description>
    <link>https://dev.to/ammyskamble</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4131648%2F3efe2845-aed3-4014-b695-60b4f17a5d7a.jpg</url>
      <title>DEV Community: Amol Kamble</title>
      <link>https://dev.to/ammyskamble</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ammyskamble"/>
    <language>en</language>
    <item>
      <title>Hit an Exact KB Target in the Browser: Resizing Images With Canvas (No Server Upload)</title>
      <dc:creator>Amol Kamble</dc:creator>
      <pubDate>Thu, 26 Nov 2026 04:28:56 +0000</pubDate>
      <link>https://dev.to/ammyskamble/hit-an-exact-kb-target-in-the-browser-resizing-images-with-canvas-no-server-upload-2jod</link>
      <guid>https://dev.to/ammyskamble/hit-an-exact-kb-target-in-the-browser-resizing-images-with-canvas-no-server-upload-2jod</guid>
      <description>&lt;p&gt;Most image-resize code solves the easy half of the problem: get the file &lt;em&gt;under&lt;/em&gt; a maximum size. Real upload forms are stricter than that. Exam and job portals routinely specify a &lt;strong&gt;band&lt;/strong&gt; — a signature must be, say, 140×60 px and between 10 KB and 20 KB. A thumb impression might be 560×160 px and 20–50 KB. Too big is rejected. Too &lt;em&gt;small&lt;/em&gt; is also rejected.&lt;/p&gt;

&lt;p&gt;Landing inside a band, at exact pixel dimensions, entirely on the client, is a fun little engineering problem. Here's the pipeline I use.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Decode with orientation fixed
&lt;/h2&gt;

&lt;p&gt;Phone photos carry EXIF orientation. If you draw one to a canvas naively, it can come out rotated. &lt;code&gt;createImageBitmap&lt;/code&gt; with &lt;code&gt;imageOrientation: 'from-image'&lt;/code&gt; handles it in modern browsers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;bitmap&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;createImageBitmap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;file&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;imageOrientation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'from-image'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 2: Draw to the exact pixel size
&lt;/h2&gt;

&lt;p&gt;Portals check pixel dimensions exactly — 200×230 means 200×230, not "about that". So the canvas &lt;em&gt;is&lt;/em&gt; the spec:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;canvas&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'canvas'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;canvas&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;width&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;560&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c1"&gt;// spec width, px&lt;/span&gt;
&lt;span class="n"&gt;canvas&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;height&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;160&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// spec height, px&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;ctx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;canvas&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getContext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'2d'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fillStyle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'#fff'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;            &lt;span class="c1"&gt;// signatures/photos sit on white&lt;/span&gt;
&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fillRect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;canvas&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;canvas&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;height&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;drawImage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bitmap&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;canvas&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;canvas&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;height&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(For a real signature you'd crop to the ink bounding box first and centre it — the point here is the encode step.)&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Binary-search the JPEG quality until the size lands in-band
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;canvas.toBlob&lt;/code&gt; takes a quality parameter for JPEG. File size rises monotonically with quality, which makes it a textbook binary search:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;encodeInBand&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;canvas&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;minBytes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;maxBytes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;lo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.05&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hi&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;best&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;q&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lo&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;hi&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;blob&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;canvas&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toBlob&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'image/jpeg'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;blob&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;maxBytes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;hi&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;              &lt;span class="c1"&gt;// too heavy — lower the quality&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;blob&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;minBytes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;lo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;              &lt;span class="c1"&gt;// too light — raise it, remember this candidate&lt;/span&gt;
      &lt;span class="n"&gt;best&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;blob&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;blob&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;         &lt;span class="c1"&gt;// inside the band&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;best&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;             &lt;span class="c1"&gt;// closest attempt that stays under the ceiling&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Seven iterations get you within ~1% of the quality range — more than enough, and each &lt;code&gt;toBlob&lt;/code&gt; on a small canvas is a few milliseconds. No server round-trip, no upload, the file never leaves the device.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Respect the floor problem
&lt;/h2&gt;

&lt;p&gt;Here's the part nobody warns you about: &lt;strong&gt;a minimum-KB floor can be physically hard to reach.&lt;/strong&gt; A mostly-white signature on a small canvas is extremely compressible — at 140×60 px, even quality 1.0 may produce only a few KB, because there's simply very little information in the image. Raising quality past that point adds nothing; the encoder has nothing left to spend bytes on.&lt;/p&gt;

&lt;p&gt;At larger canvases the band is comfortable (560×160 px at high quality lands naturally in a 20–50 KB window). At tiny ones, if the portal's validator truly enforces its printed floor, no honest re-encode of the same pixels will satisfy it — which is why so many applicants see "file too small" errors on signatures they've done nothing wrong with. Knowing this saves you from shipping a "compressor" that promises a band it can't always hit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: Two spec-sheet traps
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;DPI is (mostly) a red herring.&lt;/strong&gt; Notifications print "200 dpi" next to pixel dimensions, but validators check pixels and bytes. The JFIF density field in the file header changes neither. If a portal asks for 200×230 px at 200 dpi, it is asking for 200×230 px.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Format is not a free choice.&lt;/strong&gt; PNG on a photograph explodes past any KB ceiling; JPEG on line art stays tiny. Every spec I've seen for these portals means JPEG, whether or not it says so in as many words.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Putting it together
&lt;/h2&gt;

&lt;p&gt;Decode with orientation → draw at exact spec pixels → binary-search quality into the KB band → be honest about floors. That pipeline powers the signature and photo presets in &lt;a href="https://signresize.in" rel="noopener noreferrer"&gt;SignResize&lt;/a&gt;, a free tool I built for exam applicants — it runs 100% in the browser, because the last thing a personal document should need is a trip to someone else's server.&lt;/p&gt;

&lt;p&gt;If you're building an upload flow with size bands, steal the binary search. It's about fifteen lines, and it's the difference between "compressed" and "accepted".&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>tutorial</category>
      <category>imageprocessing</category>
    </item>
    <item>
      <title>Subnetting Without Tears: How to Split 192.168.1.0/24 Into 4 Subnets (Worked Example)</title>
      <dc:creator>Amol Kamble</dc:creator>
      <pubDate>Mon, 23 Nov 2026 14:01:06 +0000</pubDate>
      <link>https://dev.to/ammyskamble/subnetting-without-tears-how-to-split-1921681024-into-4-subnets-worked-example-4mjm</link>
      <guid>https://dev.to/ammyskamble/subnetting-without-tears-how-to-split-1921681024-into-4-subnets-worked-example-4mjm</guid>
      <description>&lt;p&gt;Subnetting sounds intimidating until you work through one example by hand. Once you see where the numbers come from, you can split any network with confidence — and check your work in seconds.&lt;/p&gt;

&lt;p&gt;In this tutorial, we will take a single network, &lt;code&gt;192.168.1.0/24&lt;/code&gt;, and split it into four equal subnets. No memorized charts, no magic — just binary and a little arithmetic.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;Imagine you run a small office network. You have the network &lt;code&gt;192.168.1.0/24&lt;/code&gt;, which gives you 256 addresses in total, from &lt;code&gt;192.168.1.0&lt;/code&gt; to &lt;code&gt;192.168.1.255&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Now you need four separate subnets — say one for the office LAN, one for the guest Wi-Fi, one for the servers, and one for the printers and IoT devices. Keeping them separate means a misbehaving device on the guest network cannot flood the office LAN, and you can apply different firewall rules to each segment.&lt;/p&gt;

&lt;p&gt;You cannot simply chop the range into four arbitrary pieces. Each subnet needs its own network address, its own broadcast address, and a contiguous block of usable host addresses. The right way to do it is to borrow bits from the host part of the address.&lt;/p&gt;

&lt;h2&gt;
  
  
  Borrowing Bits: From /24 to /26
&lt;/h2&gt;

&lt;p&gt;An IPv4 address has 32 bits. In &lt;code&gt;192.168.1.0/24&lt;/code&gt;, the first 24 bits identify the network and the remaining 8 bits identify hosts — that is why there are 2^8 = 256 addresses.&lt;/p&gt;

&lt;p&gt;To create subnets, we borrow bits from the host portion and turn them into subnet bits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Number of subnets needed:&lt;/strong&gt; 4&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bits to borrow:&lt;/strong&gt; 2, because 2^2 = 4&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;New prefix length:&lt;/strong&gt; 24 + 2 = &lt;strong&gt;/26&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;New subnet mask:&lt;/strong&gt; 255.255.255.192 (the last octet, 192, is &lt;code&gt;11000000&lt;/code&gt; in binary)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Host bits remaining:&lt;/strong&gt; 32 − 26 = 6&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Addresses per subnet:&lt;/strong&gt; 2^6 = &lt;strong&gt;64&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Usable hosts per subnet:&lt;/strong&gt; 64 − 2 = &lt;strong&gt;62&lt;/strong&gt; (we subtract the network and broadcast addresses, more on that below)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each subnet therefore holds 64 addresses, of which 62 can be assigned to devices. Four subnets × 64 addresses = 256, which is exactly the space we started with. Nothing is wasted.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Four Subnets
&lt;/h2&gt;

&lt;p&gt;Because each subnet is 64 addresses wide, the network addresses step up by 64 in the last octet: 0, 64, 128, 192.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Subnet&lt;/th&gt;
&lt;th&gt;Network Address&lt;/th&gt;
&lt;th&gt;Usable Host Range&lt;/th&gt;
&lt;th&gt;Broadcast Address&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Subnet 1&lt;/td&gt;
&lt;td&gt;192.168.1.0/26&lt;/td&gt;
&lt;td&gt;192.168.1.1 – 192.168.1.62&lt;/td&gt;
&lt;td&gt;192.168.1.63&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Subnet 2&lt;/td&gt;
&lt;td&gt;192.168.1.64/26&lt;/td&gt;
&lt;td&gt;192.168.1.65 – 192.168.1.126&lt;/td&gt;
&lt;td&gt;192.168.1.127&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Subnet 3&lt;/td&gt;
&lt;td&gt;192.168.1.128/26&lt;/td&gt;
&lt;td&gt;192.168.1.129 – 192.168.1.190&lt;/td&gt;
&lt;td&gt;192.168.1.191&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Subnet 4&lt;/td&gt;
&lt;td&gt;192.168.1.192/26&lt;/td&gt;
&lt;td&gt;192.168.1.193 – 192.168.1.254&lt;/td&gt;
&lt;td&gt;192.168.1.255&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Notice the pattern: the usable range always starts one address after the network address and ends one address before the broadcast address. And the broadcast address of one subnet is always the address just before the next subnet begins.&lt;/p&gt;

&lt;p&gt;If you want to verify a subnet by hand, take any address — say &lt;code&gt;192.168.1.100&lt;/code&gt;. It falls between 64 and 127, so it belongs to Subnet 2, &lt;code&gt;192.168.1.64/26&lt;/code&gt;. Its network address is &lt;code&gt;.64&lt;/code&gt;, its broadcast is &lt;code&gt;.127&lt;/code&gt;, and its default gateway would typically be the first usable address, &lt;code&gt;.65&lt;/code&gt;. Try it with a few addresses of your own; the pattern clicks fast.&lt;/p&gt;

&lt;p&gt;If you would rather not do the binary by hand every time, you can check your answers with &lt;a href="https://devsubnet.com" rel="noopener noreferrer"&gt;this free subnet calculator&lt;/a&gt;. It runs 100% in the browser, so your IP data never leaves your machine — handy when you are working with real production ranges.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two Mistakes Everyone Makes
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Forgetting that the network and broadcast addresses are not usable
&lt;/h3&gt;

&lt;p&gt;Every subnet loses two addresses: the first (the network address, which identifies the subnet itself) and the last (the broadcast address, used to send a packet to every host on the subnet). That is why a /26 gives you 62 usable hosts, not 64.&lt;/p&gt;

&lt;p&gt;This is the classic exam and real-world trap. A requirement for "60 hosts" fits neatly in a /26, but a requirement for "64 hosts" does not — you would need a /25 instead, which gives 126 usable hosts. Always subtract two before deciding whether a subnet is big enough, and always plan a little headroom for growth.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. In VLSM, always allocate the largest subnet first
&lt;/h3&gt;

&lt;p&gt;The example above used equal-sized subnets, but real networks rarely need equal sizes. Variable Length Subnet Masking (VLSM) lets you carve a network into different-sized pieces — a /26 for the office, a /28 for the printers, and so on.&lt;/p&gt;

&lt;p&gt;The rule that saves you from a mess: &lt;strong&gt;allocate the largest subnet first, then the next largest, and so on.&lt;/strong&gt; If you hand out a small block first, it can sit right in the middle of the space the big block needs, and you will end up with a fragmented network that cannot fit the large subnet anywhere — even though the total free space is enough. Largest first keeps the address space tidy and leaves the leftovers in one clean block.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quick Practice
&lt;/h2&gt;

&lt;p&gt;Try these before reaching for a calculator:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Split &lt;code&gt;10.0.0.0/24&lt;/code&gt; into 8 subnets. What is the new mask, and how many usable hosts does each subnet have? (Answer: borrow 3 bits, /27, 30 usable hosts each.)&lt;/li&gt;
&lt;li&gt;You need a subnet for 100 hosts. What is the smallest mask that works? (Answer: /25, with 126 usable hosts — a /26 only gives 62.)&lt;/li&gt;
&lt;li&gt;What are the network and broadcast addresses of &lt;code&gt;172.16.5.200/26&lt;/code&gt;? (Answer: network &lt;code&gt;172.16.5.192&lt;/code&gt;, broadcast &lt;code&gt;172.16.5.255&lt;/code&gt;.)&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;Subnetting is just binary counting with a purpose. Borrow as many bits as you need — 2 bits for 4 subnets — add them to the prefix, and the block size (64, in our case) tells you where each subnet starts and ends. Remember to subtract the network and broadcast addresses, and when sizes differ, allocate the biggest subnet first.&lt;/p&gt;

&lt;p&gt;Work through one example on paper, verify it with a calculator, and the next time someone says "split this /24", you will know exactly what to do.&lt;/p&gt;

&lt;p&gt;Happy subnetting!&lt;/p&gt;

</description>
      <category>networking</category>
      <category>tutorial</category>
      <category>beginners</category>
      <category>devops</category>
    </item>
    <item>
      <title>Stop Sending Your IP Schemas to Remote Servers: Why I Built a 100% Client-Side Subnet Calculator</title>
      <dc:creator>Amol Kamble</dc:creator>
      <pubDate>Fri, 18 Sep 2026 14:02:02 +0000</pubDate>
      <link>https://dev.to/ammyskamble/stop-sending-your-ip-schemas-to-remote-servers-why-i-built-a-100-client-side-subnet-calculator-2mej</link>
      <guid>https://dev.to/ammyskamble/stop-sending-your-ip-schemas-to-remote-servers-why-i-built-a-100-client-side-subnet-calculator-2mej</guid>
      <description>&lt;p&gt;As developers and cloud architects, we are constantly planning VPCs, slicing up subnets for Kubernetes, and trying to avoid IP overlap across multi-region deployments. And like most people, I used to just Google "subnet calculator" and use whatever popped up first.&lt;/p&gt;

&lt;p&gt;But I realized a massive security flaw in this workflow: &lt;strong&gt;most online subnet calculators process your inputs on their remote servers.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Whenever we type our internal IP schemas, CIDR blocks, or exact network topologies into these tools, we are essentially broadcasting our corporate network architecture to a third-party server. For a profession that obsesses over IAM roles, zero-trust networks, and private endpoints, this felt like a glaring blind spot.&lt;/p&gt;

&lt;p&gt;Network planning should be secure, fast, and entirely private. So, I built &lt;a href="https://devsubnet.com/" rel="noopener noreferrer"&gt;DevSubnet&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is DevSubnet?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://devsubnet.com/" rel="noopener noreferrer"&gt;DevSubnet&lt;/a&gt; is a free, 100% client-side IP subnet and CIDR calculator. There is zero server-side processing, no database logging your inputs, and no telemetry tracking your IP architectures. Everything executes locally in your browser via JavaScript.&lt;/p&gt;

&lt;p&gt;While building it, I also wanted to solve the real-world headaches I face when provisioning infrastructure, going beyond the basic RFC 1918 math.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Features Built for Modern DevOps:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Cloud Provider Offsets:&lt;/strong&gt; Standard calculators assume you lose 2 IPs per subnet (Network and Broadcast). But if you deploy in the cloud, you know that AWS reserves 5 IPs, Azure reserves 5 IPs, and GCP reserves 4. DevSubnet automatically adjusts your usable host counts based on your selected cloud provider.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Infrastructure as Code (IaC) Export:&lt;/strong&gt; Once you have your CIDR blocks sliced correctly, you can instantly export configuration syntax for Terraform (&lt;code&gt;cidrsubnet()&lt;/code&gt;), AWS CloudFormation, Azure Bicep, Ansible, and Linux &lt;code&gt;iproute2&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Interactive Visual Splitter:&lt;/strong&gt; Slicing a &lt;code&gt;/16&lt;/code&gt; into multiple &lt;code&gt;/24&lt;/code&gt;s for different availability zones? The recursive visual splitter lets you build out your architecture tree visually.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Kubernetes CNI Sizing:&lt;/strong&gt; Quickly size Pod and Service CIDR blocks for Cilium, Calico, and AWS VPC CNI to prevent pod scheduling failures down the line.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Try It Out
&lt;/h2&gt;

&lt;p&gt;You can use the tool completely free here: &lt;a href="https://devsubnet.com/" rel="noopener noreferrer"&gt;DevSubnet.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Whether you are studying for a networking certification, writing Terraform modules, or architecting a multi-AZ cloud environment, I would love to hear your thoughts. &lt;/p&gt;

&lt;p&gt;What is your current workflow for planning IP blocks? Are there any specific IaC exports or cloud provider quirks you would like to see added? Drop your feedback in the comments!&lt;/p&gt;

</description>
      <category>showdev</category>
      <category>devops</category>
      <category>security</category>
      <category>aws</category>
    </item>
  </channel>
</rss>
