Windows programming

Moderators: None (Apply to moderate this forum)
Number of threads: 3670
Number of posts: 9122

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
what is subnet mask Posted by bodhi2016 on 12 Jul 2009 at 5:32 AM
I am trying to learn few tools to see what goes under the hood of my compuyrt.I am trying to learn nmap. I am reading a book.I could not understand what is subnet mask.how can a host specification of 192.168.1.5/24 can scan everything between 192.168.1.0 and 192.168.1.255.
Suppose five computers are connected to a computer A via LAN .Computer A has connection to the net.The five other computers can connect to the net via A .But will all these 6 computers (including A) will have the same ip or six diferent ip
Report
Re: what is subnet mask Posted by DataDink on 12 Jul 2009 at 8:15 AM
Subnetting and IP class only really make any sense at all when you break them down into binary.

Pop out the calculator on your computer and set it to scientific mode.
Set it to decimal and enter then number 255. Now set it to binary mode and you should see what 255 is converted to binary - 11111111.
254 = 11111110
253 = 11111101
252 = 11111100

And so on...

8 binary digits is what is called a byte - both a subnet mask and an IP address are made up of 4 bytes:

IP: 192.168.1.10
SUBNET: 255.255.255.0

Now let's look at the subnet mask in binary:
11111111.11111111.11111111.00000000

And let's look at the IP in binary:
11000000.10101000.00000001.00001010

Now - each 1 and 0 you see in a binary number is called a bit. So the rule to the subnet mask game is that every place you see a 1 in the subnet mask you are not allowed to change in the IP address, but every place you see a 0 in the subnet mask, you are allowed to create any combination of 1's and 0's in the IP address.

This means - for the above example - 192.168.1.0 and 192.168.1.255 are both valid IPs for this subnet - AND everything in between: (0-255).

If you were to take the subnet mask of:
11111111.11111111.00000000.00000000

Then your new IP range for your subnet would be:
192.168.0.0 to 192.168.255.255

Note: any IP address ending in 0 or 255 wouldn't be valid for assignment - but technically they still exist.


Ok - so that's how the subnet mask works! There is also the "Class" of ip address you have. If you look at any IP adress in binary you actually can tell what the Class of the IP address is by where the 1st 0 is.

So in our example:
11000000.10101000.00000001.00001010
--*-----.--------.--------.--------

We can see that the first 0 is the 3rd bit - so A, B, C - this is a Class C IP address...

If the IP address looked like this:
10000000.10101000.00000001.00001010
-*------.--------.--------.--------

The first 0 would be at the second bit - A, B - this is a Class B address

And an address starting with a 0, would be a class A address.

As you can imagine, a Class A address has more available different IPs than a class B or a Class C, and a class B has more available addresses than a class C.


And that is really all there is to it.

Did that help?

Report
This post has been deleted. Posted by smithlara on 3 Nov 2009 at 4:04 AM
This post has been deleted.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.