MIKROTIK ROS+PHP+MYSQL实现从数据库中配置DNS服务器
ROS开启DNS服务器后,使用ROS脚本动态从服务端数据库时更新IP到ROS里,实现批量的动态DDNS,供客户使用
php脚本
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | <?php header( 'Content-type: text/plain' ); $id =filter_input(INPUT_GET, 'id' ); echo ": global dnsadd do ={ ##/ip dns static remove [find regexp=\ $ddns address!=\ $ipaddress ] /ip dns static remove [find regexp=\ $ddns ] /ip dns static add address=\ $ipaddress regexp=\ $ddns ttl=20s } "; //$dnsadd ipaddress=1.1.1.1 ddns=www.ip99.com require_once 's5admin/db/db.php' ; $sql = "select publicipaddress,pppoeid,areaid from s5 where areaid='$id' order by (0+pppoeid)" ; $res =mysqli_query( $conn , $sql ); while ( $row =mysqli_fetch_row( $res )) { $qian = array ( " " , " " , "\t" , "\n" , "\r" ); $nnip =trim( $row [1]); $arrip = explode ( "\n" , $nnip ); //echo "$row[0]$port\r\n"; foreach ( $arrip as $v ) { $vip = str_replace ( $qian , '' , $v ); } $areaid = $row [2]; //$ipstr=$row[0] . ' ' . "ip$vip" . ".os${areaid}.com\r\n"; $ipstr = "\$dnsadd ipaddress=$row[0] ddns=" . "ip$vip" . ".os${areaid}.com\r\n" ; echo $ipstr ; } mysqli_close( $conn ); ?> |
ROS脚本
{ :local nowstart 0 :local newstart 0 :local EOF true :local url "http://serverip/dns.php\?id=82" :local ipaddress "" :local ddns "" :put $url /tool fetch url=$url keep-re=yes dst-path=dns /import file=dns }
分类:
MIKROTIK ROS相关
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)