IP addresses such as telecom in Linux are summarized and displayed in CIDR Block/mask format.

Source: Internet
Author: User
Tags dbase ipcalc

Reprinted please note address: http://blog.csdn.net/kumu_Linux

APNIC is an organization that manages IP Address Allocation in the Asia Pacific region. It has a rich and accurate IP Address Allocation library and is also open to the outside world, whois3 can help us get the CIDR blocks of China Telecom, China Netcom, and China tietong in Linux:

Whois3 install

========================================================== ======================================
# Wget http://ftp.apnic.net/apnic/dbase/tools/ripe-dbase-client-v3.tar.gz
# Tar xf ripe-dbase-client-v3.tar.gz-C/usr/local/src/
# Cd/usr/local/src/whois3-3.2.2
#./Configure
# Make & make install
========================================================== ======================================

Obtain IP segments of China Netcom, China Telecom, and China tietong
========================================================== ======================================
# Whois3-H whois.apnic.net-l-I MB MAINT-CNCGROUP> CNC
# Whois3-H whois.apnic.net-l-I MB MAINT-CHINANET> Chinanet
# Whois3-H whois.apnic.net-l-I MB MAINT-CN-CRTC> CRTC
========================================================== ======================================

Process and obtain data
========================================================== ======================================
# Cat CNC | grep inetnum | awk-F: '{print $2}' | sed-r's /(*)(. *)/\ 2/'| tr-d ""> cnc_ipcalc
# Cat Chinanet | grep inetnum | awk-F: '{print $2}' | sed-r's /(*)(. *)/\ 2/'| tr-d ""> chinaet_ipcalc
# Cat CRTC | grep inetnum | awk-F: '{print $2}' | sed-r's /(*)(. *)/\ 2/'| tr-d ""> crtc_ipcalc
# Cat crtc_ipcalc // process it in a format similar to the following:
......
61.236.250.0-61.236.250.255
61.236.251.0-61.236.251.255
......
========================================================== ======================================
Ipcalc is the IP/subnet calculator in Linux.
The version of ipcalc that comes with RHEL is low. You can download the latest ipcalc from the official website.
# Wget http://jodies.de/ipcalc-archive/ipcalc-0.41.tar.gz
# Tar ipcalc-0.41.tar.gz-C/usr/local/src
#/Usr/local/src/ipcalc-0.41/ipcalc 61.236.250.0-61.236.250.255 | grep-V DEA
// The following result is what we need
61.236.250.0/24
#

# Cat ipcalc. Sh // view the following conversion script

#!/bin/bash#############by kumu#############while (( $# > 0 ))do    while read line    do        /usr/local/src/ipcalc-0.41/ipcalc $line | grep -v dea    done < $1 >> $1.txt    shiftdone# 

#./Ipcalc. Sh cnc_ipcalc chinanet_ipcalc crtc_ipcalc
# Ls *. txt
Chinanet_ipcalc.txt cnc_ipcalc.txt crtc_ipcalc.txt
# Tail-5 cnc_ipcalc.txt
210.22.0.0/16
210.21.0.0/16
218.106.240.0/20
210.13.64.0/18
220.250.32.0/19
#
This completes all the conversions. Domestic IP addresses are summarized and displayed in the network segment/mask format.

Reference: www.commandlinefu.com/commands/matching/ipcalc/axbjywxj/sort-by-votes

Http://mgmt.bjenet.cn/wiki/doku.php/freebsd/whois_get_addresses

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.