Skip to content
David Kittell
David Kittell

Application & System: Development / Integration / Orchestration

  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support
David Kittell

Application & System: Development / Integration / Orchestration

Bash – Get ARIN IP Information

Posted on July 16, 2021August 17, 2024 By David Kittell

A bit crude but works

# Prerequisite: brew install ipcalc
# Place all the IP Addresses in a text file IPList.txt
 
echo "IP Address|Root Owner|Owner|IP CIDR|IP RDNS" | tee ARIN.txt
 
for ip in $(cat IPList.txt | sort); do
    arin=$(whois -h whois.arin.net "$ip")
 
    rootOwner=$(echo "$arin" | grep 'Organization' | cut -d ':' -f2 | sed 's/^[ \t]*//;s/[ \t]*$//')
    # echo $rootOwner
    Owner=$(whois -h whois.arin.net "n $ip" | tr '\n' '|' | cut -d '|' -f2 | cut -d '(' -f1 | sed 's/^[ \t]*//;s/[ \t]*$//' | grep -v 'CIDR')
    ipCIDR=$(echo $(ipcalc $(echo $arin | grep 'NetRange' | cut -d ':' -f2 | sed 's/^[ \t]*//;s/[ \t]*$//') | grep -v deaggregate) | sed 's/^[ \t]*//;s/[ \t]*$//')
    # echo $ipCIDR
    ipRDNS=$(dig -x $ip | grep -v ';' | tr '\n' ' ' | awk -F" " '{print " "$5}' | sed 's/^[ \t]*//;s/[ \t]*$//')
    echo "$ip|$rootOwner|$Owner|$ipCIDR|$ipRDNS"
done | tee -a ARIN.txt 
Originally Posted on July 16, 2021
Last Updated on August 17, 2024
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.

Related

Code Mac OS X Shell Mac OSX UNIX UNIX Shell Scripts ARINCIDRIP Addressipcalcwhois

Post navigation

Previous post
Next post

Related Posts

Clean Up Database

Posted on December 12, 2013October 26, 2015

CAUTION: This is a very powerful script, use at your own risk! This script will: Drop all non-system stored procs Drop all views Drop all functions Drop all Foreign Key constraints Drop all Primary Key constraints Drop all tables USE <Database Name> /* Drop all non-system stored procs */ DECLARE…

Read More

Red Hat – Failed to initialize NSS library

Posted on August 8, 2017

If you recently updated or recently installed a Red Hat server and get a message like this when trying to run yum the below will help. # yum repolist error: Failed to initialize NSS library There was a problem importing one of the Python modules required to run yum. The…

Read More

Battery Life

Posted on May 3, 2013February 8, 2016

By its self this code is rather simple and meaningless but useful when adding to scheduled tasks or applications that take a long time to run and have the potential of running on a laptop. Before using the code below in Design View you’ll need these: 1 Progress Bar 2…

Read More

Code

Top Posts & Pages

  • PowerShell - Rename Pictures to Image Taken
  • Front Page
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions

Recent Posts

  • Javascript – Digital Clock with Style
  • BASH – Web Ping Log
  • BASH – Picture / Video File Name Manipulation
  • Mac OSX Terminal – Create SSH Key
  • Bash – Rename Picture

Top Posts

  • PowerShell - Rename Pictures to Image Taken
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions
  • SQLite - Auto-Increment / Auto Generate GUID
©2025 David Kittell | WordPress Theme by SuperbThemes
 

Loading Comments...
 

You must be logged in to post a comment.