简体   繁体   中英

Validate IP Address/ Netmask

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM