Red Hat Bugzilla – Bug 498568
ipcalc could allow recombining netmask and offset to derive host address
Last modified: 2014-03-16 23:18:33 EDT
Description of problem:
Sometimes it's useful to have a base address (such as the beginning of a DHCP pool) and be able to synthesize addresses offset from that address. Ipcalc would be the best tool to do this, but it lacks that capability.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
I'm proposing a '-o' option, such that:
ipcalc -o 192.168.1.32 50
I'm not sure of the usecase for this - is this for static assignment on the client? Or just as a shortcut for doing the math?
(In reply to comment #1)
> I'm not sure of the usecase for this - is this for static assignment on the
> client? Or just as a shortcut for doing the math?
Yes, doing math for assigning devices to subordinate pool devices (like printers, VoIP phones, security cameras, etc) when you need to pre-populate a DHCP database from an init script...
I'm not sure if this is the right component for this report, because is dhclient ( from package dhclient ) that set address ip to interfaces and initscripts only call them, afaik.
Bill, what you think?
Thanks for your report Philipp
Keeping it as NEW.
It's the correct component, but I'm not convinced it's a necessary fix.
Heck, you can do the simple math in bash:
for offset in 1 2 3 4 5 6 7 ; do
(In reply to comment #4)
> It's the correct component, but I'm not convinced it's a necessary fix.
> Heck, you can do the simple math in bash:
> for offset in 1 2 3 4 5 6 7 ; do
> echo "IPADDR=192.168.1.$((BASE+offset))"
Ok, and what if my netmask is not a multiple of 8?
What if I have a really large DHCP pool, say 192.168.2.2-192.168.3.63?
There are other ipcalc features I've been thinking of, as well... various address relation operators. "lt", "in", "overlaps", etc.
The fact of the matter is that IP addresses *can't* be handled as 4 unrelated small integers... it doesn't make sense.
The only other possible fix is to add a built-in operator to bash's $(( ... )) that does dotted-quad to unsigned int and unsigned int to dotted-quad conversion so that then one could do arithmetic, comparisons, etc.