Computer Science, asked by Yashugehlot7949, 1 year ago

How to calculate subnet mask from ip address step by step?

Answers

Answered by anupambd94
0

In this example, we'll calculate a subnet mask for a computer with IP address 192.35.128.93 that belongs to a network with six subnets.

Step

Determine the network class (A, B or C) based on IP address:

If IP addresses begin with 1 to 126, it is Class A.If IP addresses begin with 128 to 191, it is Class B.If IP addresses begin with 192 to 223, it is Class C.

In our example, the network is class C since the IP address 192.35.128.93 start with 192.

Step

Determine the number of bits needed to define subnets:

Number of subnets = (2^Number of bits) - 2. Hence,Number of bits = Log2(Number of subnets + 2).

In our example, there are six subnets:

Number of bits = Log2(6 + 2) = Log2(8) = 3. Three bits in the IP address are used as a subnet portion.Step

Compose the subnet mask in binary form by extending the default subnet mask with subnet bits. Default subnet mask for classes A to C are:

11111111.00000000.00000000.00000000 (Class A, network part is 8 bits)11111111.11111111.00000000.00000000 (Class B, network part is 16 bits)11111111.11111111.11111111.00000000 (Class C, network part is 24 bits)

In our example, an extension of the default class C subnet mask with 3 bits (Step 2) results in the subnet mask 11111111.11111111.11111111.11100000.

Step

Convert the binary subnet mask to the decimal-dot form. The binary form contains four octets (8 bits in each). Use following rules:

For "1111111" octet, write "255".For "00000000" octet, write "0".If octet contains both "1" and "0" use the formula:

Integer number = (128 x n) + (64 x n) + (32 x n) + (16 x n) + (8 x n) + (4 x n) + (2 x n) + (1 x n) Where "n" is either 1 or 0 in the corresponding position in the octet sequence.

In our example, for 11111111.11111111.11111111.11100000 11111111 ---> 255 11111111 ---> 255 11111111 ---> 255 11100000---> (128 x 1) + (64 x 1) + (32 x 1) + (16 x 0) + (8 x 0) + (4 x 0) + (2 x 0) + (1 x 0) = 224

Subnet mask is 255.255.255.224.

Answered by Anonymous
0

Explanation:

Here is one way to calculate it. First of all you should determine what is the subnet mask to be used. By having /25 we would know that the subnet mask has the first 25 bits set to one, so it would be 255.255.255.128, now we know that the interested octet on the subnet mask is the fourth one, so we need to figure out the magic number to use it later in our calculation. By extracting the interested octet value (128) from 256 we will have the magic number, so 256 - 128 = 128, now let's start with calculating the network numbers by incrementing the magic number to the interested octet starting from zero:

 

61.25.37.0

61.25.37.128

61.25.37.256 <-- This one is not valid since it has 256 decimal value in the fouth octect, we know that the maximum valid decimal value we would have is 255.

 

Now that we have the network numbers, we would find out the broadcast by taking off one from the value of the interested octet (fourth) of the next network:

 

61.25.37.0 - 61.25.37.127

61.25.37.128 - 61.25.37.255

 

For each network, the first address is the network number (id) and the last is the broadcast address.

Similar questions