|
发表于 2008-7-3 16:51:55
|
显示全部楼层
1,启用ROS上的DNS缓存
2,建立如图所示的计划任务,定时搜索IP
3,客户机用ROS做DNS,并经常打开给定的域名(网站),以便在DNS缓存上留下记录而被检测到
4,经过一些时日,IP会逐步驱于完整达到实用的程度
以下是脚本代码:
#自动获取给定域名的IP地址
#-----------------------------------
#域名关键字,多个关键字之间用逗号分隔
:set DOM-STR "163.com,sina.com"
#目标地址列表名
:set ADD-LST "D-TEST"
#-----------------------------------
#检查本ROS的DNS缓存设置
:set dns [/ip dns get allow-remote-requests]
:if($dns=false) do={:log errog "获取域名IP:请先启用DNS缓存"}
# 取得DNS缓存记录的ID
:set ids [/ip dns cache all find]
#对记录进行分析
:foreach i in=$ids do={
# 取得域名
:set dom [/ip dns cache all get $i name]
# 判断域名中是否包含有指定的关键字
:foreach j in=$DOM-STR do={
# 找到关键字
:if([:find $dom $j]!=[:nothing]) do={
# 取得IP地址
:set ip [:resolve $dom]
# 检查该IP在列表里是否存在
:set fond ""
:set fond [/ip firewall address-list find list=$ADD-LST address=$ip]
# 若是新IP,则添加到地址列表里
:if($fond="") do={
/ip firewall address-list add list=$ADD-LST address=$ip disabled=no
}
}
}
}
#清除缓存,以便寻找新的IP
/ip dns cache flush |
评分
-
查看全部评分
|