Bug 498568 - ipcalc could allow recombining netmask and offset to derive host address
ipcalc could allow recombining netmask and offset to derive host address
Status: CLOSED WONTFIX
Product: Fedora
Classification: Fedora
Component: initscripts (Show other bugs)
rawhide
All Linux
low Severity low
: ---
: ---
Assigned To: Bill Nottingham
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2009-05-01 03:07 EDT by Philip Prindeville
Modified: 2014-03-16 23:18 EDT (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2009-06-01 21:21:57 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Philip Prindeville 2009-05-01 03:07:40 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):

8.76.4-1

How reproducible:

n/a

Steps to Reproduce:
1. n/a
2.
3.
  
Actual results:

Expected results:

I'm proposing a '-o' option, such that:

    ipcalc -o 192.168.1.32 50

would output:

    ADDRESS=192.168.1.82

for example.

Additional info:
Comment 1 Bill Nottingham 2009-05-01 09:37:43 EDT
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?
Comment 2 Philip Prindeville 2009-05-01 16:15:11 EDT
(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...
Comment 3 iarly selbir 2009-06-01 19:59:47 EDT
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.
Comment 4 Bill Nottingham 2009-06-01 21:21:57 EDT
It's the correct component, but I'm not convinced it's a necessary fix.

Heck, you can do the simple math in bash:

BASE=50
for offset in 1 2 3 4 5 6 7 ; do
   echo "IPADDR=192.168.1.$((BASE+offset))"
done
Comment 5 Philip Prindeville 2009-06-01 21:25:59 EDT
(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:
> 
> BASE=50
> for offset in 1 2 3 4 5 6 7 ; do
>    echo "IPADDR=192.168.1.$((BASE+offset))"
> done  

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.

Note You need to log in before you can comment on or make changes to this bug.