Forums: » Register « |  Free Tools |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |

New Free Tools on Dev Shed!

#1
January 29th, 2012, 10:02 AM
 matthayzon
Contributing User

Join Date: Jan 2012
Posts: 37
Time spent in forums: 6 h 30 m 4 sec
Reputation Power: 2
Netid and hostid of any given IP address?

Hello,
I am trying to understand how to figure out the Netid and Hostid of any given IP address (manually that is without using CMD).

I know that it has a lot to do with the class that the IP address belongs to. For example, if leftmost bit of the first octet starts with a 0, it belongs to class A.

That is where I get stuck, once I determine what class an IP address belongs to, I am unable to identify which portion of the address is dedicated to the network and the host.

Thank in advance for any help.

#2
January 29th, 2012, 11:23 AM
 E-Oreo
Lost in code

Join Date: Dec 2004
Posts: 8,233
Time spent in forums: 2 Months 2 Days 20 h 11 m 10 sec
Reputation Power: 7170
To do it by hand you need to know the table:
http://en.wikipedia.org/wiki/Classful_network

It's not necessary to memorize the entire table, because it's not hard to figure it out on the fly and there are plenty of patterns. When you need to remember is how to identify the class of the address and the size of each class.

So if you have an address that starts with 110 you need to recognize that it's a class C address and a class C address has 24 bits in the network part of the address (including the 110). Since all addresses have 32 bits, the last 8 bits of the address must be the host part.

Wikipedia also has multiple examples like this one:
Code:
```Class C
192.  0.  0.  0 = 11000000.00000000.00000000.00000000
223.255.255.255 = 11011111.11111111.11111111.11111111
110nnnnn.nnnnnnnn.nnnnnnnn.HHHHHHHH```
__________________
PHP FAQ
How to program a basic, secure login system using PHP

Quote:
 Originally Posted by Spad Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around

#3
January 29th, 2012, 11:33 AM
 matthayzon
Contributing User

Join Date: Jan 2012
Posts: 37
Time spent in forums: 6 h 30 m 4 sec
Reputation Power: 2
So, for example if the IP address was 140.10.33.17.

That would mean the IP address belongs to the B class since the leftmost octet starts with 10, and Class B addresses have 16 host and network bits, right?

So....class C always has 24 network bits, class B addresses always have 16 network bits, and class A always has 8 network bits? and the remaining bits are dedicated to the host?

I appreciate your help I think I get it now!

 Viewing: Dev Shed Forums > System Administration > Networking Help > Netid and hostid of any given IP address?