Internal to a Linux system (RHEL8/CentOS8), what linux commands can assist in detemining that a given IP/Netmask (CIDR) is correct for the network assigned to these hosts?
For the following examples, the assigned class C network is "192.168.1.0" with a netmask of "255.255.255.0"; which equates to a CIDR of "/24". Both example hosts have a single NIC with simple/standard IPv4 networking utilized (no trunking, or anthing else complicated). These hosts 'could' be physical or virtual; I don't believe the solution should care either way.
Example #1: The IP address assigned to one of the hosts is "192.168.1.5", with a netmask of "255.255.255.0"; conforming to a CIDR of "/24". In ifcfg-ens192: IPADDR="192.168.1.5" and NETMASK="255.255.255.0". This appears to be correctly configured.
Example #2: The IP address assigned to one of the other hosts is "192.168.1.6", with a netmask of "255.255.255.128"; conforming to a CIDR of "/25". In ifcfg-ens192: IPADDR="192.168.1.6" and NETMASK="255.255.255.128". This is incorrectly configured.
+++++
Of course the way I've described it, Example#2 is incorrectly configured, one would either run applicable nmcli commands, or edit ifcfg-ens192, with the correct netmask and then restart networking services, or even reboot.
What I'm looking for is what linux commands, internal to each host, can be executed to test the network functionality versus the existing configuration, such that one or more commands indicate in their output that the Example#1 host is configured correctly, and the same commands would indicate that the Example#2 host is NOT configured correctly?
I'm seeking to apply this to a larger enterprise, where I don't easily have the ability to manually validate the network configs for individual systems against some master list of subnets, networking components, etc...
I have not found any method at the linux command line to validate any given IP and netmask combination as valid.
The actual issue is that there are 1000+ linux RHEL7/RHEL8 Linux hosts across many dozens of disseparate neworks/subnets in the environment. While troubleshooting other problems, a handful of these hosts, in fact, have been found as having incorrect IPv4 address/netmask assignments. The goal was to seek a method to query some commands IN the host in an effort to validate if the IPv4 address/netmask were actually correct for the given network.
ipcalc
? – Gilles Quénot Feb 24 '23 at 06:14