1

Given an IP address and Netmask. I want to check if the combination is valid or not. Example

IP Address: 23.1.1.1 Netmask: 255.0.0.0

Here the combination is wrong.

What are the rule to validate the combination and also netmask

Divyesh
  • 237
  • 2
  • 6
  • Why would it be wrong? If you can't calculate it manually, you can't do it programmatically either. – MSalters Feb 22 '17 at 11:08
  • That is a perfectly valid address and mask combination. If you have an address and mask (or mask length), you can determine everything else. – Ron Maupin Feb 22 '17 at 14:43
  • 1
    https://stackoverflow.com/questions/21060645/js-validation-ipport The above link helps to solve with Javascript! – Manjula Reshmi Mar 26 '20 at 11:15

1 Answers1

0

Check sipcalc tool. You can install it on Debian-based distros with

$ apt-get install sipcalc

For the proposed IP/netmask pair, you get this:

$ sipcalc 23.1.1.1 255.0.0.0
-[ipv4 : 23.1.1.1 255.0.0.0] - 0

[CIDR]
Host address        - 23.1.1.1
Host address (decimal)  - 385941761
Host address (hex)  - 17010101
Network address     - 23.0.0.0
Network mask        - 255.0.0.0
Network mask (bits) - 8
Network mask (hex)  - FF000000
Broadcast address   - 23.255.255.255
Cisco wildcard      - 0.255.255.255
Addresses in network    - 16777216
Network range       - 23.0.0.0 - 23.255.255.255
Usable range        - 23.0.0.1 - 23.255.255.254
aicastell
  • 2,182
  • 2
  • 21
  • 33