Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What IP Addresses are invalid?

Status
Not open for further replies.

cpjust

Programmer
Sep 23, 2003
2,132
US
Hi, I'm writing some QA testcases for a server program and I'm adding tests to make sure the product rejects invalid Local Bind Addresses.

The only things I know for sure are that the port has to be between 1 & 65535, and the first octet cannot be 0.

I'm not sure if the last octet can be 0, or if any of them can be 255?
 
I looked at those, but I didn't find the info I needed.

I had a feeling someone was going to say "well it depends on your subnet mask..." :p But since this software could be run anywhere, I don't know the subnet mask. I need to know what IP addresses are invalid on any subnet mask.

Specifically, in which octets are 0 or 255 permitted for a LBA?

i.e. 0.x.x.x is invalid, 255.255.255.255 is invalid...
 
OK, so from that link I can infer that addresses ending in 0 or 255 are also invalid.
Here's my latest interpretation of a valid IP address:
[1-255].[0-255].[0-255].[1-254]
 
That's only true of a 24-bit subnet mask. In a 23-bit mask, 0 and 255 may well be perfectly valid.

Within any subnet, only the very first and very last (all zeroes, all ones) addresses cannot be used. Finding valid addresses without taking into account the subnet mask is quite impossible.
 
But surely 0.x.x.x cannot be a valid address no matter what the subnet is, right?

Otherwise, the only 100% invalid addresses are 0.0.0.0 & 255.255.255.255
 
I agree 100% with Nemhain. You can't answer this without a knowing the subnet mask. There are some subnet masks where 255 in the host portion is valid.

In answer to your question, I believe a 0 in the first octet can never be valid.
 
Well I guess that makes it easier for me to test. So now I'm back to where I started, with 3 invalid addresses:
0.0.0.0
255.255.255.255
0.x.x.x
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top