0

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.

Peregrino69
  • 2,417
  • 4
    How would host 2 know that it's meant to be on a /24 network and not a /25 ? The point of CIDR is that it is classless; 192.168.1.6/25 is a valid address. – Stephen Harris Feb 24 '23 at 00:15
  • None, and I can't see how there even could be. On the client's point of view 10.0.0.100/17 is perfectly valid IP even if you connect it to 192.168.1.0/24 and vice versa; there's just no communication on Layer 3. Subnets and network prefixes are purely human concepts. So what's the actual issue you want to resolve or prevent? – Peregrino69 Feb 24 '23 at 00:30
  • The actual issue is that there are 1000+ linux RHEL7/RHEL8 linux hosts across many dozens of disseperate 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. – Joseph Wulf Feb 24 '23 at 02:18
  • Did you tried ipcalc ? – Gilles Quénot Feb 24 '23 at 06:14
  • Thanks, that helps. For the future, rather than answering in comments it's better to edit the question itself to put the answer there. This way it stays up-to-date and gets more focused, and the relevant info is readily available. I added the previous now for you verbatim, the edit will become visible when another member of the community approves it. – Peregrino69 Feb 24 '23 at 09:55
  • 1
    Anyway that's still not clear enough. I understand that you expected a /24 and not a /25. But then you should rephrase your question and write "I expected to have all of out networks as /24 because we don't use /25 anywhere". If that's not correct that really means it was not clear, and you should add additional complete examples. – A.B Feb 24 '23 at 10:12
  • If your users or admins are incorrectly setting the host/mask, then I suggest you configure them via dhcp. – Bib Feb 24 '23 at 10:59
  • I think you should consider a proper management application. Here's one list of free ones, widely used, to get you started. – Peregrino69 Feb 24 '23 at 11:32

0 Answers0