惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - Franky
WordPress大学
WordPress大学
Hugging Face - Blog
Hugging Face - Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
小众软件
小众软件
人人都是产品经理
人人都是产品经理
罗磊的独立博客
博客园 - 聂微东
雷峰网
雷峰网
量子位
美团技术团队
V
V2EX
The GitHub Blog
The GitHub Blog
大猫的无限游戏
大猫的无限游戏
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
IT之家
IT之家
The Cloudflare Blog
爱范儿
爱范儿
T
Tailwind CSS Blog
博客园 - 三生石上(FineUI控件)
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
宝玉的分享
宝玉的分享
Last Week in AI
Last Week in AI
Jina AI
Jina AI

博客园 - CalvinChu

vyos syslog配置 How to upgrade pip on Debian Wheezy 指数数据解密,懂的都懂 OpenWRT and VPN Passthrough - CalvinChu 如何将 find 命令与 exec 一起使用 CentOS 7 下搭建 OpenVPN - CalvinChu esxi 直通sata控制器 Python requires an OpenSSL 1.0.2 or 1.1 compatible libssl with X509_VERIFY_P xRDP – Detected issues with Debian 11 – Oh No ! Something has gone wrong…. qemu-mips环境搭建跳坑指南 ImportError: libSM.so.6: cannot open shared object file: No such file or directory openwrt(lede)中,PPtP Client需要安装的软件包 OpenWrt中的Hotplug脚本 MAC OSX VPN自动添加静态路由 - CalvinChu fbprophet安装和使用 CentOS7安装iptables防火墙 CENTOS7下安装REDIS mysql忘记root密码解决办法 iptables命令(备忘)
How to get the ip ranges of domain
CalvinChu · 2023-01-14 · via 博客园 - CalvinChu

1. 获取想访问的的IP RANG(这里的RANG可以不全),这里以GITHUB为例, 得到图(1)的结果(以免DNS污染,建议使用国外DNS):

dig github.com TXT @8.8.8.8

 

2. 从whois.radb.net 获取组织AS NAME,或者从这个链接直接获取AS NAME[https://bgp.potaroo.net/as1221/asnames.txt]:

whois -h whois.radb.net 192.30.255.113 | grep origin 

3. 从whois.radb.net 获取IP RANGE.

whois -h whois.radb.net -- '-i origin AS36459' | grep -Eo "([0-9.]+){4}/[0-9]+"

 

参考资料及文章:
https://qastack.cn/superuser/405666/how-to-find-out-all-ip-ranges-belonging-to-a-certain-as

https://ipinfo.io

https://www.radb.net/

https://bgp.potaroo.net/as1221/asnames.txt

根据AS NAME 获取 IP RANGE的PYTHON 脚本:

import requests
from bs4 import BeautifulSoup
import re


url_base = 'http://ipinfo.io/'
as_base = 'AS'

output = open('ip_per_asn.csv', 'w')
with open('chilean_asn.csv') as f:
    lines = f.read().splitlines()
    for asn in lines:
        ASN = as_base + asn
        page = requests.get(url_base+ASN)
        html_doc = page.content
        soup = BeautifulSoup(html_doc, 'html.parser')
        for link in soup.find_all('a'):
            if asn in link.get('href'):
                auxstring = '/'+as_base+asn+'/'
                line = re.sub(auxstring, '', link.get('href'))
                printstring = asn+','+line+'\n'
                if 'AS' not in printstring:
                    output.write(printstring)
        print asn+'\n'

print 'script finished'