0

The below was asked as a question in an exam I gave previous week:

"You are given two hosts with IP addresses 152.46.69.12 and 152.46.69.105 with both having masks set to 255.255.255.0. How do the masks have to change to force a ping from host 152.46.69.12 to traverse a router to reach host 152.46.69.105."

Now you can have the masks set to 255.255.255.192 to ensure it works that way but I have couple of other questions:
1) can we set a mask to 0.0.0.0 to make it work as asked in question? Can you please explain your reasons. 2) can we set a mask to 255.255.255.64 to make it work as asked in question? As in is it possible that one of the higher bits in mask is set to 0 and lower bit in the mask is set to 1.

I looked at various forums but nothing that gave answers specific to my questions.

I am very new to networking and learning basic things in networking. Any answers are appreciated. Thanks.

3 Answers 3

2

A subnet mask is a "mask" in that it separates the network portion of the IP address from the host portion. It is a binary masking operation, so there can only be certain values for the the subnet mask.

Consider just one octet for an example. You have 8 bits for an IP address rather than the 32 bits (4 octets * 8 bits/octet = 32 bits) in the IPv4 address space. How would you tell a system which part of the address is locally signficant? Here are the choices:

SUBNET  SUBNET    BINARY  NUMBER OF     NUMBER OF      SUBNET 
LENGTH    MASK     VALUE   SUBNETS    IP'S/SUBNET  BOUNDARIES
------  ------  --------  ---------   -----------  ----------
     0       0  00000000    1 (2^0)     256 (2^8)  None (entire subnet is local)
     1     128  10000000    2 (2^1)     128 (2^7)  Every multiple of 128 (0-127, 128-255)
     2     192  11000000    4 (2^2)      64 (2^6)  Every multiple of 64 (0-63, 64-127, etc)
     3     224  11100000    8 (2^3)      32 (2^5)  Every multiple of 32 (0-31, 32-63, etc)
     4     240  11110000   16 (2^4)      16 (2^4)  Every multiple of 16 (0-15, 16-31, etc)
     5     248  11111000   32 (2^5)       8 (2^3)  Every multiple of 8 (0-7, 8-15, etc)
     6     252  11111100   64 (2^6)       4 (2^2)  Every multiple of 4 (0-3, 4-7, etc)
     7     254  11111110  128 (2^7)       2 (2^1)  Every multiple of 2 (0-1, 2-3, etc)
     8     255  11111111  256 (2^8)       1 (2^0)  All (every host is its own subnet)

In practice, you lose two IP's per subnet because the first IP is considered the "network" address and the last IP is considered the "broadcast" address. This means that you can never route traffic to a .254 subnet mask network since it only has two possible address and both are already reserved (there is not any extra space for a gateway address and a host). The smallest possible routed subnet is using a .252 subnet mask since that gives enough space for the network, gateway, host, and broadcast addresses.

In your example, you want to separate the networks between .12 and .105. You can't use a .0 subnet mask because that means they are on the same subnet. You can't use a .128 subnet mask because both .12 and .105 in the .0-127 subnet range. You can use a .192 subnet mask because .12 would be in the .0-63 subnet while .105 would be in the .64-127 subnet.

You can use a .224 subnet mask because .12 would be in the .0-31 subnet while .105 would be in the .96-127 subnet. You can use a .240 subnet mask because .12 would be in .0-15 while .105 would be in .96-111. You can use a .248 because .12 would be in .8-15 while .105 would be in .104-111.

You cannot use a .252 subnet mask as .12 falls on the "network" address portion of the .12-15 subnet. You cannot use either a .254 or .255 subnet, as .252 is the smallest routed subnet possible.

As a side exercise, if you want to compute the largest possible subnet between two hosts, compare how similar their binary values are and that will give you the answer. In your example, let's look at the binary similarity of your IP addresses starting from the leftmost bit and moving right until we hit a difference:

152.46.69.12  10011000.00101110.01000101.00001100
152.46.69.105 10011000.00101110.01000101.01101001
              ........ ........ ........ .xxxxxxx
Subnet Length:       8       +8       +8       +1 = /25
Subnet Mask:       255     .255     .255     .128 = 255.255.255.128

Counting the similar bits from left to right, this shows that the largest possible subnet length is 25 bits. Expressed in subnet mask notation it is 255.255.255.128 (/25 in CIDR notation). Any larger subnet mask (255.255.255.192 or /26) will separate these hosts.

4
  1. No - 0.0.0.0 is the equivalent of /0 which means everything is local, nothing passes through the router.

  2. Again no - netmasks work in continuous blocks from high-to-low, setting lower bits with a "gap" would most likely be refused as illegal on most systems and just not work on others.

1

Question 2 answer, I am in advanced networking right now. When using CIDR notation you cannot set a higher bit to 0 and a lower bit to 1. There is no proper way to denote CIDR notation that way.

it works like this,

n = networking bit H = Host bit

say you are using the /26 it would look like this

nnnnnnnn.nnnnnnnn.nnnnnnnn.nnHHHHHH

the last octet would be 192, 128+64

if it is set to /27 it has to be written like this

nnnnnnnn.nnnnnnnn.nnnnnnnn.nnnHHHHH

and the last octet would be 224, 128+64+32

in CIDR notation you have to move from left to right.

Not the answer you're looking for? Browse other questions tagged .