← Back to list

IP Subnet Calculator in GoLang

Hi All,

Sajan K · 2023-09-13 10:55 · 8 claps · 0.8 min read
#golang #go #ipv4 #subnet #ip-subnet-calculator
Open on Medium ↗

IP Subnet Calculator in GoLang

Hi All,

For past couple of months, I have been working on a project in GoLang. The project IP V4 subnet calculator. I have been using online tools to do these calculations till date. So I thought of writing my own subnet calculator in a language that is new to me. This will help me understand the structure and nature of the language as well.

When we execute the golang binary with the ip range including the subnet it gives is information such as number of hosts and the range in which the subnet resides. For eg:

➜  ~ ipr 10.20.0.0/23

IP - 10.20.0.0
Subnet - 10.20.0.0/23
Number of hosts - 512
IP range: 10.20.0.0 - 10.20.1.255

You can find the source code here — https://github.com/sajankgit/IPR-GO

Installation

From Binary

  1. Download the zip containing the binary from https://github.com/sajankgit/IPR-GO/releases/download/untagged-c60fb88a2994553600f0/ipr.zip
  2. unzip ipr.zip
  3. Copy the binary to your bin location — eg: cp -r ipr /usr/local/bin

From source

git clone https://github.com/sajankgit/IPR-GO.git
cd IPR-GO
go build
mv IPR-GO /usr/local/bin/ipr

Usage

ipr ip/cidr

Please try this from your side and let me know your valuable suggestions. Also, let me know if I can make any changes in code as well.

Thanks in Advance!

Have a great day.


메타데이터
post_id
32055770e2
slug
ip-subnet-calculator-in-golang-32055770e2
url
https://medium.com/@sajanpth/ip-subnet-calculator-in-golang-32055770e2
canonical_url
https://medium.com/@sajanpth/ip-subnet-calculator-in-golang-32055770e2
author_url
https://medium.com/@sajanpth
status
ok
fetched_at
2026-06-28 14:26:31