Guest User

Untitled

a guest
Jun 29th, 2020
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. use strict;
  4. use 5.010;
  5. use MikroTik::API;
  6.  
  7. my $host = "192.168.88.1";
  8. my $user = "admin";
  9. my $pass = "password";
  10.  
  11. my $api = MikroTik::API->new ({
  12. host => $host,
  13. username => $user,
  14. password => $pass,
  15. use_ssl => 0,
  16. debug => 1,
  17. timeout => 3
  18. });
  19. $api->set_probe_before_talk (3);
  20. $api->set_reconnect_after_failed_probe (0);
  21.  
  22. my ($result, @instances) = $api->query ("/routing/bgp/instance/print", {".proplist" => ".id,router-id"}, {"name" => "default"});
  23. foreach (@instances) {
  24. my $id = $_->{".id"};
  25. my $rid = $_->{"router-id"};
  26. say "$id,$rid";
  27. $api->cmd ("/ip/address/add", {
  28. "interface" => "lo",
  29. "address" => $rid
  30. });
  31. }
Add Comment
Please, Sign In to add comment