In theory, can a subnet mask have zeros between ones (e.g. 255.255.0.248
) or it need to be strictly 1's followed by 0's?
As stated in RFC 950, there is only an "example" to interpret an IP as <network-number><subnet-number><host-number>
(see 2.1). And in the pseudo-code given in 2.2:
IF bitwise_and(dg.ip_dest, my_ip_mask)
= bitwise_and(my_ip_addr, my_ip_mask)
THEN
send_dg_locally(dg, dg.ip_dest)
ELSE
send_dg_locally(dg,
gateway_to(bitwise_and(dg.ip_dest, my_ip_mask)))
This seems to work with both cases as well.
My NE teacher says masks like 255.255.0.248
"are correct but not used commonly". So I'm asking here after digging around Internet with null result.