Comments (14)
Rocky9 :
$ ipcalc --version
ipcalc 1.0.0
$ ipcalc "104.154.0.0-104.155.255.255"
ipcalc: bad IPv4 address: 104.154.0.0-104.155.255.255
IPCalc 1.0.1 (compiled from sources) :
$ ./ipcalc "104.154.0.0-104.155.255.255"
ipcalc: bad IPv4 address: 104.154.0.0-104.155.255.255
Same with 104.154.0.0 - 104.155.255.255
.
from asn.
Hi @odoucet, I cannot seem to reproduce the issue locally. Output works fine here, for that same AS:
What is happening on your side is either a wrong or mangled response from the RIPE whois server while querying INETNUM objects for the target AS prefixes, or ipcalc
failing to resolve the INETNUM objects into CIDR prefixes.
Please paste this into your terminal: echo "inetnum: 104.154.0.0 - 104.155.255.255" | awk '{print $2"-"$4}' | xargs ipcalc -r | tail -n1
If the output is 104.154.0.0/15
, then I guess something is happening with RIPE's whois server, and a good first step would be to try the tool on another Internet connection to see if it has to do with that.
If the output isn't that, then you should likely see an error generated by ipcalc
, and we can proceed from there.
Also, please specify your OS and ipcalc
version and make sure you use the latest available asn
version
from asn.
Hello,
Thank you for the quick feedback !
It appears ipcalc is unable to compute CIDR :
$ echo "inetnum: 104.154.0.0 - 104.155.255.255" | awk '{print $2"-"$4}' | xargs ipcalc -r | tail -n1
ipcalc: bad IPv4 prefix: 104.154.0.0-104.155.255.255
$ ipcalc -v
ipcalc 0.2.4
$ cat /etc/centos-release
Rocky Linux release 8.6 (Green Obsidian)
from asn.
Moreover, -r
option seems unsuitable with what my ipcalc version does :
ipcalc --help
Usage: ipcalc [OPTION...]
-c, --check Validate IP address
-r, --random-private=PREFIX Generate a random private IP network using
-S, --split=PREFIX Split the provided network using the
provided prefix/netmask
-i, --info Print information on the provided IP address
(default)
--all-info Print verbose information on the provided IP
address
--reverse-dns Print network in a the reverse DNS format
-4, --ipv4 Explicitly specify the IPv4 address family
-6, --ipv6 Explicitly specify the IPv6 address family
Specific info options:
-b, --broadcast Display calculated broadcast address
-m, --netmask Display netmask for IP
-n, --network Display network address
-p, --prefix Display network prefix
--minaddr Display the minimum address in the network
--maxaddr Display the maximum address in the network
--addresses Display the maximum number of addresses in
the network
--addrspace Display the address space the network
resides on
-h, --hostname Show hostname determined via DNS
-o, --lookup-host=STRING Show IP as determined via DNS
-g, --geoinfo Show Geographic information about the
provided IP
Other options:
--class-prefix When specified the default prefix will be determined
by the IPv4 address class
--no-decorate Print only the requested information
-s, --silent Don't ever display error messages
-v, --version Display program version
-?, --help Show this help message
--usage Display brief usage message
from asn.
Upgrading to Rocky Linux 9 that gives package ipcalc-1.0.0-5.el9.x86_64
adds a new feature :
-d, --deagrregate=IP1-IP2 Deaggregate the provided address range
Editing "asn" program and using ipcalc -d
instead of ipcalc -r
makes it work again :)
from asn.
Ok so this is somewhat related to #21 ... apparently the history of ipcalc
is rather convoluted, with this fork on Gitlab being the norm on Redhat-based (I think it's a C rewrite that implemented deaggregation further down the road, as you found out), while the Perl original (also forked on Github) being shipped with Ubuntu and (I guess) Debian-based. I'm not a Rocky user myself, but perhaps @robert-scheck can assist here to suggest a consistent way to have a one-size-fits-all ipcalc
under all mentioned distros. Will leave this issue open for another while, and if nothing can be done I'll remove Rocky from the compatibility list in the README.
Thanks for reporting your findings!
from asn.
We may issue an "ipcalc --help" at the beginning of the program to check which flag to use (-d or -r). I may provide a pull request if you are OK with that kind of check.
from asn.
From what I can see, we have:
- RHEL/CentOS 7: ipcalc from initscripts v9.49.53
- CentOS/RHEL/Rocky 8: ipcalc v0.2.4
- CentOS/RHEL/Rocky 9: ipcalc v1.0.0
ipcalc from initscripts v9.49.53:
$ ipcalc --help
Usage: ipcalc [OPTION...]
-c, --check Validate IP address for specified address family
-4, --ipv4 IPv4 address family (default)
-6, --ipv6 IPv6 address family
-b, --broadcast Display calculated broadcast address
-h, --hostname Show hostname determined via DNS
-m, --netmask Display default netmask for IP (class A, B, or C)
-n, --network Display network address
-p, --prefix Display network prefix
-s, --silent Don't ever display error messages
Help options:
-?, --help Show this help message
--usage Display brief usage message
$
ipcalc v.0.2.4:
$ ipcalc --help
Usage: ipcalc [OPTION...]
-c, --check Validate IP address
-r, --random-private=PREFIX Generate a random private IP network using
-S, --split=PREFIX Split the provided network using the
provided prefix/netmask
-i, --info Print information on the provided IP address
(default)
--all-info Print verbose information on the provided IP
address
--reverse-dns Print network in a the reverse DNS format
-4, --ipv4 Explicitly specify the IPv4 address family
-6, --ipv6 Explicitly specify the IPv6 address family
Specific info options:
-b, --broadcast Display calculated broadcast address
-m, --netmask Display netmask for IP
-n, --network Display network address
-p, --prefix Display network prefix
--minaddr Display the minimum address in the network
--maxaddr Display the maximum address in the network
--addresses Display the maximum number of addresses in
the network
--addrspace Display the address space the network
resides on
-h, --hostname Show hostname determined via DNS
-o, --lookup-host=STRING Show IP as determined via DNS
-g, --geoinfo Show Geographic information about the
provided IP
Other options:
--class-prefix When specified the default prefix will be determined
by the IPv4 address class
--no-decorate Print only the requested information
-s, --silent Don't ever display error messages
-v, --version Display program version
-?, --help Show this help message
--usage Display brief usage message
$
ipcalc v1.0.0:
$ ipcalc --help
Usage: ipcalc [OPTION...]
-c, --check Validate IP address
-r, --random-private=PREFIX Generate a random private IP network using
the supplied prefix or mask.
-S, --split=PREFIX Split the provided network using the
provided prefix/netmask
-d, --deagrregate=IP1-IP2 Deaggregate the provided address range
-i, --info Print information on the provided IP address
(default)
--all-info Print verbose information on the provided IP
address
Specific info options:
--reverse-dns Print network in a the reverse DNS format
-a, --address Display IP address
-b, --broadcast Display calculated broadcast address
-m, --netmask Display netmask for IP
-n, --network Display network address
-p, --prefix Display network prefix
--minaddr Display the minimum address in the network
--maxaddr Display the maximum address in the network
--addresses Display the maximum number of addresses in
the network
--addrspace Display the address space the network
resides on
-h, --hostname Show hostname determined via DNS
-o, --lookup-host=STRING Show IP as determined via DNS
-g, --geoinfo Show Geographic information about the
provided IP
Other options:
-4, --ipv4 Explicitly specify the IPv4 address family
-6, --ipv6 Explicitly specify the IPv6 address family
--class-prefix When specified the default prefix will be determined
by the IPv4 address class
--no-decorate Print only the requested information
-j, --json JSON output
-s, --silent Don't ever display error messages
-v, --version Display program version
-?, --help Show this help message
--usage Display brief usage message
$
from asn.
Please paste this into your terminal:
echo "inetnum: 104.154.0.0 - 104.155.255.255" | awk '{print $2"-"$4}' | xargs ipcalc -r | tail -n1
Well…what does Jodies (Debian/Ubuntu) ipcalc actually say to the following?
echo "inetnum: 185.81.68.0 - 185.81.68.254" | awk '{print $2"-"$4}' | xargs ipcalc -r | tail -n1
echo "inetnum: 185.81.68.255 - 185.81.68.255" | awk '{print $2"-"$4}' | xargs ipcalc -r | tail -n1
Ok so this is somewhat related to #21 ... apparently the history of
ipcalc
is rather convoluted, with this fork on Gitlab being the norm on Redhat-based (I think it's a C rewrite that implemented deaggregation further down the road, as you found out), while the Perl original (also forked on Github) being shipped with Ubuntu and (I guess) Debian-based.
No, Red Hat ipcalc is IMHO not a fork or C rewrite of Jodies (Debian/Ubuntu) ipcalc. Jodies ipcalc dates back to about 2000-09-25 with v0.15, while Red Hat ipcalc (as part of initscripts v5.22) dates clearly back to 1998-03-10. When comparing the feature sets of the early versions, they IMHO just co-existed with the same name.
from asn.
docker run --rm --net=host -ti ubuntu bash
root@docker-desktop:/# echo "inetnum: 185.81.68.0 - 185.81.68.254" | awk '{print $2"-"$4}' | xargs ipcalc -r | tail -n1
185.81.68.254/32
root@docker-desktop:/# echo "inetnum: 185.81.68.255 - 185.81.68.255" | awk '{print $2"-"$4}' | xargs ipcalc -r | tail -n1
185.81.68.255/32
root@docker-desktop:/# cat /etc/debian_version
bookworm/sid
root@docker-desktop:/# ipcalc --help
IP Calculator 0.5
Enter your netmask(s) in CIDR notation (/25) or dotted decimals
(255.255.255.0). Inverse netmask are recognized. If you mmit the
netmask, ipcalc uses the default netmask for the class of your
network.
Look at the space between the bits of the addresses: The bits before
it are the network part of the address, the bits after it are the host
part. You can see two simple facts: In a network address all host bits
are zero, in a broadcast address they are all set.
The class of your network is determined by its first bits.
If your network is a private internet according to RFC 1918 this is
remarked. When displaying subnets the new bits in the network part of
the netmask are marked in a different color.
The wildcard is the inverse netmask as used for access control lists
in Cisco routers. You can also enter netmasks in wildcard notation.
Do you want to split your network into subnets? Enter the address and
netmask of your original network and play with the second netmask
until the result matches your needs.
Questions? Comments? Drop me a mail: krischan at jodies.de
http://jodies.de/ipcalc
Thanks for your nice ideas and help to make this tool more useful:
Bartosz Fenski
Denis A. Hainsworth
Foxfair Hu
Frank Quotschalla
Hermann J. Beckers
Igor Zozulya
Kevin Ivory
Lars Mueller
Lutz Pressler
Oliver Seufer
Scott Davis
Steve Kent
Sven Anderson
Torgen Foertsch
Edward
Nick Clifford
Victor Engmark
Usage: ipcalc [options] <ADDRESS>[[/]<NETMASK>] [NETMASK]
ipcalc takes an IP address and netmask and calculates the resulting
broadcast, network, Cisco wildcard mask, and host range. By giving a
second netmask, you can design sub- and supernetworks. It is also
intended to be a teaching tool and presents the results as
easy-to-understand binary values.
-n --nocolor Don't display ANSI color codes.
-c --color Display ANSI color codes (default).
-b --nobinary Suppress the bitwise output.
-c --class Just print bit-count-mask of given address.
-h --html Display results as HTML (not finished in this version).
-v --version Print Version.
-s --split n1 n2 n3
Split into networks of size n1, n2, n3.
-r --range Deaggregate address range.
--help Longer help text.
Examples:
ipcalc 192.168.0.1/24
ipcalc 192.168.0.1/255.255.128.0
ipcalc 192.168.0.1 255.255.128.0 255.255.192.0
ipcalc 192.168.0.1 0.0.63.255
ipcalc <ADDRESS1> - <ADDRESS2> deaggregate address range
ipcalc <ADDRESS>/<NETMASK> --s a b c
split network to subnets
where a b c fits in.
! New HTML support not yet finished.
ipcalc 0.5
from asn.
Well…what does Jodies (Debian/Ubuntu) ipcalc actually say to the following?
* `echo "inetnum: 185.81.68.0 - 185.81.68.254" | awk '{print $2"-"$4}' | xargs ipcalc -r | tail -n1` * `echo "inetnum: 185.81.68.255 - 185.81.68.255" | awk '{print $2"-"$4}' | xargs ipcalc -r | tail -n1`
The output for the first range is misleading, since ipcalc
here will report all the prefixes required to "fill up" that IP range:
185.81.68.0/25
185.81.68.128/26
185.81.68.192/27
185.81.68.224/28
185.81.68.240/29
185.81.68.248/30
185.81.68.252/31
185.81.68.254/32
but of course, the tail -n1
part will cut you only the last line, and the output would be 185.81.68.254/32
. But that's not going to happen with INETNUM
objects, since you'd have a .255
last octet, not .254
if the range was a /24.
The output for the second range is 185.81.68.255/32
, which this time is correct.
from asn.
But that's not going to happen with
INETNUM
objects, since you'd have a.255
last octet, not.254
if the range was a /24.
Then I would like to suggest kindly to perform a whois lookup for this IPv4 network, even it's outside of the scope of this issue.
The way of checking ipcalc --help
during run-time to identify the ipcalc implementation and version, as suggested by @odoucet, seems to be the only option, from my point of view.
from asn.
Then I would like to suggest kindly to perform a whois lookup for this IPv4 network, even it's outside of the scope of this issue.
that is indeed out of the scope of this issue, anyway:
> whois -h whois.ripe.net -- "-T inetnum -K -L --resource 185.81.68.0"
[...]
inetnum: 185.81.68.0 - 185.81.68.255
inetnum: 185.81.68.0 - 185.81.68.254
> whois -h whois.ripe.net -- "-T inetnum -K -L --resource 185.81.68.255"
[...]
inetnum: 185.81.68.0 - 185.81.68.255
inetnum: 185.81.68.255 - 185.81.68.255
as you can see the reference INETNUM in both cases is 185.81.68.0 - 185.81.68.255
, which is exactly what I meant by "it's gonna have a .255 if it's a /24". The fact that anyone can make up internal divisions for their network and create an INETNUM object for them, doesn't make them a valid prefix, nor a routable one. Infact, this ISP is not going to be able to route 185.81.68.0 - 185.81.68.254
no matter how hard they try: it can't be made into a single, atomic CIDR prefix, and that means it only exists in their internal "division" scope, not globally on any other router. My point being any valid routable prefix appearing "in the wild" won't be affected by ipcalc
's behavior (which is to fill up IP ranges by using multiple CIDR prefixes if necessary). Hope I could explain myself clearly.
The way of checking ipcalc --help during run-time to identify the ipcalc implementation and version, as suggested by @odoucet, seems to be the only option, from my point of view.
Ok thanks a lot for your input, I'll consider it!
from asn.
Just found out that running ipcalc 104.154.0.0 - 104.155.255.255
(i.e. without any option) automatically detects the IP range and deaggregates it on v0.41 (Jodies).
Can you guys please try running the same command on your ipcalc version? Maybe it could be a viable solution for all implementations to converge (i.e. without specifying -d
or -r
). Of course this doesn't solve the Rocky 8 problem (ipcalc there not having the feature at all), I guess Rocky 9 should be specified in the README.
from asn.
Related Issues (20)
- Installed ipcalc not detected HOT 3
- Some IPv6 ranges not picked up HOT 1
- ipcalc bad argument HOT 4
- `jq: error (at <stdin>:1): Cannot iterate over null (null)` HOT 1
- zsh: killed bash (exec 3<>/dev/tcp/whois.ripe.net/43) HOT 6
- Last AS missing in AS path information HOT 6
- Feature request: add option to always query IPQualityScore and pass settings HOT 3
- IPv6 traceroute refusing to start on my host HOT 2
- Issue with obtaining v4 and v6 prefixes on MACOS HOT 11
- Suggestion: IP geolocation and proxy detection using IP2Location.io HOT 2
- Feature question - Bulk name/ip lookup HOT 1
- [Feature Request] Support IP2Location.io API to Query ASN HOT 1
- Add support for docker, automatically start in server mode. HOT 2
- Use HTTPS when it's available HOT 1
- Stuck on "retrieving information for ipv4 prefix..." HOT 2
- Exciting News: 'asn' Tool Soon to be Included in Debian! HOT 9
- upstream/transit HOT 1
- Bulk geolocation incorrect results HOT 1
- [Feature Request] IPInfo.io for core IP based operation HOT 3
- Consider adding IP2Location.io API for IP geolocation HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from asn.