Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use strict;
- use 5.010;
- use MikroTik::API;
- my $host = "192.168.88.1";
- my $user = "admin";
- my $pass = "password";
- my $api = MikroTik::API->new ({
- host => $host,
- username => $user,
- password => $pass,
- use_ssl => 0,
- debug => 1,
- timeout => 3
- });
- $api->set_probe_before_talk (3);
- $api->set_reconnect_after_failed_probe (0);
- my ($result, @instances) = $api->query ("/routing/bgp/instance/print", {".proplist" => ".id,router-id"}, {"name" => "default"});
- foreach (@instances) {
- my $id = $_->{".id"};
- my $rid = $_->{"router-id"};
- say "$id,$rid";
- $api->cmd ("/ip/address/add", {
- "interface" => "lo",
- "address" => $rid
- });
- }
Add Comment
Please, Sign In to add comment