Community discussions

MikroTik App
 
SimonAngatia
just joined
Topic Author
Posts: 5
Joined: Sat Apr 09, 2022 7:43 am

Connecting to Mikrotik router remotely from application running on the server through API

Sat May 07, 2022 5:46 am

Let me start by saying that I am not a networking expert but more of a software developer. I have been working on a web application to manage WIFI hotspot users using the Mikrotik API interface.
This is how the application works:
When a user connects to the hotspot, they are redirected to the hotspot plans page where they are asked to choose a hotspot plan and pay for it. After they have paid for that plan, the application automatically creates a user on the user-manager database using the details they provided and activates their profile so that the user can access the internet(I am using the radius server to authenticate users). The application works very well on my local computer using localhost.
My Problem
The problem arises when I host the application on the server(online). When I try connecting to the router from the online application, the connection does not go through. I get an error saying "Error connecting to RouterOS".
How I am doing it
  
  use PEAR2\Net\RouterOS;
  //connectng to the router
  $client = new RouterOS\Client('198.162.164.49', 'admin', 'password');
  //interacting with the router
  
The same code is working on localhost. I did some research and someone suggested that I should use the public IP address but it doesn't work with the public IP address as well.
The web application is hosted on a VPS running ubuntu os. Could someone suggest to me what I am supposed to do or what I am doing wrongly here?
Thank you.
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3291
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: Connecting to Mikrotik router remotely from application running on the server through API

Sat May 07, 2022 9:03 am

Take care when setting up remote access to the router over internet. VPN is the best option. Se my post here:

viewtopic.php?t=177280

Who is online

Users browsing this forum: Majestic-12 [Bot], rogerioqueiroz and 15 guests