This really isn't that hard, but I had someone ask for help on one of the forums I participate in, and thought I'd share the answer here.
The person needed to determine the following given an IP/Mask of 22.214.171.124/18
- Subnet Mask
- Network Address
- First usable host address
- Last usable host address
/18 means there is an 18 bit subnet mask on that IP address. This is neither a Class C (24 bit subnet mask) or Class B (16 bits). Although, "Classes" are kind of obsolete these days. It's just an 18 bit subnet mask. Straightforward.
In binary, it looks like this (decimal underneath):
11111111 11111111 11000000 00000000
255 255 192 0
To get the network address, you take the IP Address in binary, and do a boolean AND against the subnet mask. A boolean AND will only return a 1 where both numbers have a 1, and return a 0 everywhere else.
11111111 11111111 11000000 00000000 <-- subnet mask 255.255.192.0
10010010 10001101 11011011 00101111 <-- IP Address 126.96.36.199
======== ======== ======== ========
10010010 10001101 11000000 00000000 <-- Network Address 188.8.131.52
The first usable host IP address is always the first IP after the network address, in this case, 184.108.40.206.
To get the broadcast address, you simply change all of the non-masked bits from the network address (in this case, the last 14 bits) to 1.
10010010 10001101 11111111 11111111 <-- Broadcast 220.127.116.11
You need to know the broadcast address to come up with the last usable host IP address, which is always one IP below the broadcast address. The last usable IP in the network for this example is 18.104.22.168.