fbpx

Can I send commands to a MikroTik to create users over ethernet (telnet) with an arduino?

The idea of ​​using an Arduino to send commands to a MikroTik device over Ethernet using Telnet is technically possible, but it has several considerations and limitations that you should keep in mind. Here I break down how you could try to do this, along with the complications and alternatives:

Technical viability

  1. Arduino Capability:
    • Arduino models that have network connectivity capability (such as Arduino Ethernet, Arduino Uno with an Ethernet shield, or Arduino Yún) can be programmed to use network protocols such as Telnet.
    • You will need a Telnet library for Arduino, which allows you to establish and manage Telnet connections. Not all libraries will support all the features you might need.
  2. Security and Telnet:
    • Telnet is not secure. Credentials and commands transmitted over Telnet are not encrypted, which exposes them to interception. Seriously consider the security implications, especially in a production environment.
  3. MikroTik Configuration:
    • The MikroTik must be configured to allow management via Telnet. This involves enabling the Telnet service and ensuring that the firewall allows Telnet traffic to the device.
    • You will need to configure appropriate users and permissions on the MikroTik to allow user creation via Telnet commands.

Code Example for Arduino

Here is a basic outline of how you could structure the code in Arduino to send Telnet commands:

#include <Ethernet.h>
#include <TelnetClient.h>

// Configuración de la dirección IP del MikroTik y las credenciales
IPAddress server(192, 168, 1, 1); // IP del MikroTik
int telnetPort = 23;
char* username = "admin";
char* password = "password";

EthernetClient ethClient;
TelnetClient telnet(ethClient);

void setup() {
  Ethernet.begin(mac, ip);
  telnet.begin(server, telnetPort);
  
  if (telnet.login(username, password)) {
    telnet.println("/user add name=nuevoUsuario password=nuevaContraseña group=full");
  }
}

void loop() {
  // Aquí podrías agregar lógica para enviar comandos adicionales o manejar respuestas
}

Considerations

  • Hardware Performance and Limitations: Arduino is limited in terms of memory and processing capacity, which could restrict the complexity and number of tasks it can handle.
  • Safer Alternatives: Consider using SSH instead of Telnet if possible. SSH offers encryption and is widely supported, although it can be more challenging to implement on Arduino due to the greater protocol complexity and hardware requirements for encryption.

Conclusion

Although it is technically possible to configure an Arduino to send Telnet commands to a MikroTik, you must carefully consider security, reliability, and technical limitations. Evaluate whether a more robust and secure solution like a Raspberry Pi with SSH would be a better option for your needs.

There are no tags for this post.
Did this content help you?
Facebook
Twitter
LinkedIn
WhatsApp
Telegram

Other documents in this category

Leave your comment

Your email address will not be published. Required fields are marked with *

Tutorials available at MikroLABs

No Courses Found!

DISCOUNT CODE

AN24-LIB

applies to MikroTik books and book packs

Days
Hours
Minutes
Seconds

Introduction to
OSPF - BGP - MPLS

Sign up for this Free course

MAE-RAV-ROS-240118
Days
Hours
Minutes
Seconds

Sign up for this Free course

MAS-ROS-240111

Promo for Three Kings Day!

KINGS24

15%

all the products

MikroTik courses
Academy courses
MikroTik books

Take advantage of the Three Kings Day discount code!

* promotion valid until Sunday January 7, 2024
** the code (KINGS24) applies to shopping cart
*** buy your course now and take it until March 31, 2024

New Year's Eve Promo!

NY24

20%

all the products

MikroTik courses
Academy courses
MikroTik books

Take advantage of the New Year's Eve discount code!

* promotion valid until Monday, January 1, 2024
** the code (NY24) applies to shopping cart
*** buy your course now and take it until March 31, 2024

Christmas discounts!

XMAS23

30%

all the products

MikroTik courses
Academy courses
MikroTik books

Take advantage of the discount code for Christmas!!!

**codes are applied in the shopping cart
Promo valid until Monday December 25, 2023

CYBER WEEK DISCOUNTS

CW23-MK

17%

all MikroTik OnLine courses

CW23-AX

30%

all Academy courses

CW23-LIB

25%

all MikroTik Books and Book Packs

Take advantage of the discount codes for Cyber ​​Week!!!

**codes are applied in the shopping cart
Promo valid until Sunday December 3, 2023

BLACK FRIDAY DISCOUNTS

BF23-MX

22%

all MikroTik OnLine courses

BF23-AX

35%

all Academy courses

BF23-LIB

30%

all MikroTik Books and Book Packs

Take advantage of the discount codes for Black Friday!!!

**Codes are applied in the shopping cart

codes are applied in the shopping cart
valid until Sunday November 26, 2023

Days
Hours
Minutes
Seconds

Sign up for this Free course

MAE-VPN-SET-231115

Halloween promo

Take advantage of discount codes for Halloween.

Codes are applied in the shopping cart

HW23-MK

11% discount on all MikroTik OnLine courses

11%

HW23-AX

30% discount on all Academy courses

30%

HW23-LIB

25% discount on all MikroTik Books and Book Packs

25%

Register and participate in the free course Introduction to Advanced Routing with MikroTik (MAE-RAV-ROS)

Today (Wednesday) October 11, 2023
7pm to 11pm (Colombia, Ecuador, Peru)

MAE-RAV-ROS-231011