Jump to content
Sign in to follow this  

Calculate IP Subnet

Recommended Posts


I would like to do 3 different things, 1 would be to display the Network Bits of an entered subnet

i.e. = 24 bit

Next would be to calculate the Subnet Mask from the Network Bits (opposite of above)


24 bit =

Last would be to find the Network Address based on the IP Address & Subnet Mask, this is probably the hardest.

i.e. / = / = / =

I found this thread but couldn't get enough out of it to do exactly what I'd like to do



~~--Feel Free to Steal my Sigs --~~FLAT LOOK____________________________________ROUNDED LOOK

Share this post

Link to post
Share on other sites

It's a good beginner's problem; not too hard. StringSplit() the dotted decimal mask and do a loop to work with one part at a time.

Post what you tried if you get stuck and you'll find plenty of help.


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post

Link to post
Share on other sites

I apologies for posting to an old topic but this was the only post I found with a problem similar to the one I was trying to solve.  Anyhows,  this is the solution I found which seems to work well;

;Set our IP and Subnet


;Split them into arrays


;use a BitwiseAND to calculate the network

ConsoleWrite(BitAND($arrIP[1],$arrSN[1]) & "." & BitAND($arrIP[2],$arrSN[2]) & "." & BitAND($arrIP[3],$arrSN[3]) & "." & BitAND($arrIP[4],$arrSN[4])& @CRLF)

Hope this helps someone.

  • Like 1

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.