forked from BenMenking/routeros-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request BenMenking#14 from MrSam/master
Example6 with list,delete and add calls
- Loading branch information
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
/* 3 step action | ||
1) fetch all static dns hosts | ||
2) remove all static dns hosts | ||
3) add example host | ||
*/ | ||
|
||
require('../routeros_api.class.php'); | ||
$API = new RouterosAPI(); | ||
|
||
if ($API->connect('111.111.111.111', 'LOGIN', 'PASSWORD')) { | ||
# Get all current hosts | ||
$API->write('/ip/dns/static/print'); | ||
$ips = $API->read(); | ||
|
||
# delete them all ! | ||
foreach($ips as $num => $ip_data) { | ||
$API->write('/ip/dns/static/remove', false); | ||
$API->write("=.id=" . $ip_data[".id"], true); | ||
} | ||
|
||
#add some new | ||
$API->comm("/ip/dns/static/add", array( | ||
"name" => "jefkeklak", | ||
"address" => "1.2.3.4", | ||
"ttl" => "1m" | ||
)); | ||
|
||
#show me what you got | ||
$API->write('/ip/dns/static/print'); | ||
$ips = $API->read(); | ||
var_dump($ips); | ||
$API->disconnect(); | ||
} |