0

I am developing a code to validate that an IP and Subnet IP combination is a valid one. Say the IP address is 192.179.10.105 and its subnet mask is 255.255.0.0 - so what are the validations we can make to check that IP and Subnet combinations is valid.

I am assuming that the we can only check that IP address should not be 192.179.0.0 and 192.179.255.255 - is it correct or is there any other validation we can make?

Programmer
  • 165
  • 1
  • 10
  • Huh? Valid in what sense? – joeqwerty Jul 07 '18 at 03:12
  • Please let me know what checks can we make from a given IP and subnet / subnet masks? – Programmer Jul 07 '18 at 03:14
  • Your question doesn't make sense. Is it valid? Yes it is. What exactly do you want to glean from it? – joeqwerty Jul 07 '18 at 03:28
  • Is there a way an IP and subnet combination be configured / setup Invalid? – Programmer Jul 07 '18 at 03:33
  • 1
    Your question is too broad and doesn't really get any kind of point across. Any ip address can work with any subnet mask depending on the subnetting scheme that's being used. It all depends on the schema of your network. If you need help with this then there is software that you can use to plan and manage the subnetting that you are using. – Nasir Riley Jul 07 '18 at 03:53
  • 1
    Actually it makes sense. Subnet must be binary 1's followed by 0's, all other numbers are bad. IP Address with only 0 or 1 within a subnet is illegal. That is it. – TomTom Jul 07 '18 at 04:07
  • So 192.179.0.0 and 192.179.1.1 and 192.179.255.255 are the only illegal address in my case? – Programmer Jul 07 '18 at 04:09
  • 1
    No. 192.179.1.1 is completely fine as it's `0000000100000001` i.e. having both 0 and 1. – Esa Jokinen Jul 07 '18 at 06:38
  • Whether the subnet mask is in binary format or not is irrelevant as that has nothing to do with whether or not it can go with a certain ip address. That all depends on the schema of the network. 192.179.10.105 can go with many different subnet masks but it depends on how the entire network is subnetted. Variable length subnet masks would drastically alter which ips can go with which masks. – Nasir Riley Jul 07 '18 at 06:47
  • I think I get the validation to be done - if my IP address is 192.179.10.105 and its subnet mask is 255.255.0.0 then any IP in between 192.179.0.0 and 192.179.255.255 is valid but excluding both - please confirm if my understanding is correct – Programmer Jul 07 '18 at 07:00
  • Every one of the ip addresses, including the all 0's and the all 1's address is technically valid. The all 0's address is the network address and the all 1's address is the broadcast address. You can't assign them to hosts but they are perfectly and technically valid. Perhaps you're asking "Which IP addresses are valid Host addresses?" – joeqwerty Jul 07 '18 at 14:51

0 Answers0