• MIKROTIK ROS+PHP+MYSQL实现从数据库中配置DNS服务器


    ROS开启DNS服务器后,使用ROS脚本动态从服务端数据库时更新IP到ROS里,实现批量的动态DDNS,供客户使用

    php脚本

    <?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(" "," ","	","
    ","
    ");
                            $nnip=trim($row[1]);
                            $arrip=explode("
    ",$nnip);
                            //echo "$row[0]$port
    ";
                            foreach($arrip as $v) {
                            	$vip=str_replace($qian, '', $v);
    			}
    			$areaid=$row[2];
    	//$ipstr=$row[0] . '   ' . "ip$vip"  . ".os${areaid}.com
    ";
    	$ipstr="$dnsadd ipaddress=$row[0] ddns=" .   "ip$vip"  . ".os${areaid}.com
    ";
    	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
    
    
    
    
    
    
    }
  • 相关阅读:
    Leetcode: Find Median from Data Stream
    Leetcode: Flip Game II
    Leetcode: Flip Game
    Leetcode: Nim Game
    Leetcode: Word Pattern II
    Leetcode: Word Pattern
    Leetcode: Game of Life
    Leetcode: Alien Dictionary && Summary: Topological Sort
    Leetcode: Unique Word Abbreviation
    Leetcode: Find the Duplicate Number
  • 原文地址:https://www.cnblogs.com/ip99/p/14772420.html
Copyright © 2020-2023  润新知