中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --

联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!

中国DOS联盟论坛
现在时间是 2026-08-12 07:54
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » 如何根据相应的关键字生成网通电信路由表 查看 1,234 回复 2
楼 主 如何根据相应的关键字生成网通电信路由表 发表于 2010-04-22 02:44 ·  中国 上海 电信
高级用户
★★★
积分 916
发帖 377
注册 2004-03-08 00:00
22年会员
UID 19523
性别 男
状态 离线
linux下自动获取网通电信路由表
http://www.hebaodans.com/index.php/2010/04/l-i-n-u-x-xia-zi-dong-huo-qu-wang-tong-dian-xin-lu-you-biao/

上面的这篇是linux下生成的方法,比对了网上已经生成的路由表还是根据http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest
这个地址的IP地址来生成数据量比较多一点,
但是似乎它的查询方法已经失效

whois $ip@whois.apnic.net

好不容易搜到个whosip
http://www.nirsoft.net/utils/whosip.html
就想能不能用windows来处理

get_cn_ipv4.cmd

del aa.txt /q
wget -c -O aa.txt "http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest"
del b.txt /q
for /f "tokens=1,* delims=|" %%a in ('type aa.txt^|findstr "CN|ipv4"') do (
for /f "tokens=3,4 delims=|" %%i in ("%%b") do (echo %%i %%j>>b.txt)
)


在线进行查询然后再根据像unicom chinanet之类的关键词进行分类,哈哈实在写不下去了,find findstr也不知道怎么用,怎么也达不到自己想要的效果,大家帮忙看看



setlocal enabledelayedexpansion

for /f "tokens=1,* delims= " %%i in (b.txt) do (

for /f "eol=O tokens=1,* delims=:" %%a in ('whosip %%i^|findstr "Network"') do (
set aa="%%b"
echo %%b>a.txt
find "UNICOM" a.txt | echo %%i %%j>>unicom.txt
)
)
endlocal
2 发表于 2010-04-22 17:16 ·  中国 上海 电信
高级用户
★★★
积分 916
发帖 377
注册 2004-03-08 00:00
22年会员
UID 19523
性别 男
状态 离线
whosip.cmd


setlocal enabledelayedexpansion

for /f "tokens=1,* delims= " %%i in (b.txt) do (

for /f "eol=O tokens=1,* delims=:" %%a in ('whosip %%i^|findstr "Network"') do (
echo %%i %%j %%b>>all.txt
)
)
endlocal


build.cmd


for %%i in (unicom,chinanet,cncgroup,crtc,cernet,cstnet,gwbn,chinabtn,colnet) do (del %%i.txt /q)

::联通
for /f "tokens=1,2,* delims= " %%a in ('type all.txt^|findstr "UNICOM"') do (
echo %%a %%b>>UNICOM.txt
)
::电信
for /f "tokens=1,2,* delims= " %%a in ('type all.txt^|findstr "CHINANET"') do (
echo %%a %%b>>CHINANET.txt
)
::网通
for /f "tokens=1,2,* delims= " %%a in ('type all.txt^|findstr "CNCGROUP"') do (
echo %%a %%b>>CNCGROUP.txt
)
::铁通
for /f "tokens=1,2,* delims= " %%a in ('type all.txt^|findstr "CRTC"') do (
echo %%a %%b>>CRTC.txt
)
::教育网
for /f "tokens=1,2,* delims= " %%a in ('type all.txt^|findstr "CERNET"') do (
echo %%a %%b>>CERNET.txt
)
::中国科学网
for /f "tokens=1,2,* delims= " %%a in ('type all.txt^|findstr "CSTNET"') do (
echo %%a %%b>>CSTNET.txt
)
::长宽
for /f "tokens=1,2,* delims= " %%a in ('type all.txt^|findstr "GWBN"') do (
echo %%a %%b>>GWBN.txt
)
::广电
for /f "tokens=1,2,* delims= " %%a in ('type all.txt^|findstr "CHINABTN"') do (
echo %%a %%b>>CHINABTN.txt
)
::有线通
for /f "tokens=1,2,* delims= " %%a in ('type all.txt^|findstr "COLNET"') do (
echo %%a %%b>>COLNET.txt
)
3 发表于 2010-05-13 11:51 ·  中国 上海 电信
高级用户
★★★
积分 916
发帖 377
注册 2004-03-08 00:00
22年会员
UID 19523
性别 男
状态 离线
get_cn_ipv4.cmd


del apnic_all.txt /q
wget -c -O apnic_all.txt "http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest"
del cn_ipv4.txt /q
for /f "tokens=1,* delims=|" %%a in ('type apnic_all.txt^|findstr "CN|ipv4"') do (
for /f "tokens=3,4 delims=|" %%i in ("%%b") do (echo %%i %%j>>cn_ipv4.txt)
)


whosip_all.cmd
http://www.nirsoft.net/utils/whosip.html


setlocal enabledelayedexpansion
for /f "tokens=1,* delims= " %%i in (cn_ipv4.txt) do (
for /f "tokens=1,* delims=:" %%a in ('start /B /low /wait whosip -r %%i^|findstr "mnt-by:"') do set "maint=%%b"
echo %%i %%j !maint!>>whosip_cn_all.txt
)
endlocal


build.cmd


for %%i in (unicom,chinanet,cncgroup,crtc,cernet,cstnet,gwbn,chinabtn,colnet) do (del %%i.txt 
/q)
::联通
for /f "tokens=1,2,* delims= " %%a in ('type whosip_cn_all.txt^|findstr "UNICOM"') do (
echo %%a %%b>>UNICOM.txt
)
::电信
for /f "tokens=1,2,* delims= " %%a in ('type whosip_cn_all.txt^|findstr "CHINANET"') do (
echo %%a %%b>>CHINANET.txt
)
::网通
for /f "tokens=1,2,* delims= " %%a in ('type whosip_cn_all.txt^|findstr "CNCGROUP"') do (
echo %%a %%b>>CNCGROUP.txt
)
::铁通
for /f "tokens=1,2,* delims= " %%a in ('type whosip_cn_all.txt^|findstr "CRTC"') do (
echo %%a %%b>>CRTC.txt
)
::教育网
for /f "tokens=1,2,* delims= " %%a in ('type whosip_cn_all.txt^|findstr "CERNET"') do (
echo %%a %%b>>CERNET.txt
)
::中国科学网
for /f "tokens=1,2,* delims= " %%a in ('type whosip_cn_all.txt^|findstr "CSTNET"') do (
echo %%a %%b>>CSTNET.txt
)
::长宽
for /f "tokens=1,2,* delims= " %%a in ('type whosip_cn_all.txt^|findstr "GWBN"') do (
echo %%a %%b>>GWBN.txt
)
::广电
for /f "tokens=1,2,* delims= " %%a in ('type whosip_cn_all.txt^|findstr "CHINABTN"') do (
echo %%a %%b>>CHINABTN.txt
)
::有线通
for /f "tokens=1,2,* delims= " %%a in ('type whosip_cn_all.txt^|findstr "COLNET"') do (
echo %%a %%b>>COLNET.txt
)
论坛跳转: