Code Monkey home page Code Monkey logo

docker-routeros's Introduction

Mikrotik RouterOS in Docker

This project comprises a Docker image that runs a MikroTik's RouterOS virtual machine inside QEMU.

It's designed to simulate MikroTik's RouterOS environment, making it an excellent tool for development and testing purposes, especially for those working with the RouterOS API.

This Docker image is particularly useful for unit testing the routeros-api-php library, allowing developers to test applications in a controlled environment that closely mimics a real RouterOS setup.

For users seeking a fully operational RouterOS environment for production use within Docker, the VR Network Lab project is recommended as an alternative.

Getting Started

Pulling the Image from Docker Hub

To use the image directly from Docker Hub, you can pull it and run a container as shown below. This will start a RouterOS instance with ports configured for SSH, API, API-SSL, and VNC access.

docker pull evilfreelancer/docker-routeros
docker run -d -p 2222:22 -p 8728:8728 -p 8729:8729 -p 5900:5900 -ti evilfreelancer/docker-routeros

Use in docker-compose.yml

For those preferring docker-compose, an example configuration is provided below. More examples is here.

version: "3.9"
services:
  routeros:
    image: evilfreelancer/docker-routeros:latest
    restart: unless-stopped
    cap_add:
      - NET_ADMIN
    devices:
      - /dev/net/tun
      - /dev/kvm
    ports:
      - "2222:22"
      - "23:23"
      - "80:80"
      - "5900:5900"
      - "8728:8728"
      - "8729:8729"

Creating a Custom Dockerfile

You can easily create your own Dockerfile to include custom scripts or configurations. The Docker image supports various tags, which are listed here. By default, the latest tag is used if no tag is specified.

FROM evilfreelancer/docker-routeros
ADD ["your-scripts.sh", "/"]
RUN /your-scripts.sh

Building from Source

If you prefer to build the Docker image from source, the commands below will guide you through cloning the repository, building the image, and running a RouterOS container.

git clone https://github.com/EvilFreelancer/docker-routeros.git
cd docker-routeros
docker build . --tag ros
docker run -d -p 2222:22 -p 8728:8728 -p 8729:8729 -p 5900:5900 -ti ros

After launching the container, you can access your RouterOS instance via VNC (port 5900) and SSH (port 2222).

Exposed Ports

The table below summarizes the ports exposed by the Docker image, catering to various services and protocols used by RouterOS.

Description Ports
Defaults 21, 22, 23, 80, 443, 8291, 8728, 8729
IPSec 50, 51, 500/udp, 4500/udp
OpenVPN 1194/tcp, 1194/udp
L2TP 1701
PPTP 1723

Links

For more insights into Docker and virtualization technologies related to RouterOS and networking, explore the following resources:

  • Mikrotik RouterOS in Docker using Qemu - An article on Habr that provides a guide on setting up Mikrotik RouterOS in Docker using Qemu, ideal for developers and network engineers interested in RouterOS virtualization.
  • RouterOS API Client - GitHub repository for the RouterOS API PHP library, useful for interfacing with MikroTik devices.
  • VR Network Lab - A project for running network equipment in Docker containers, recommended for production-level RouterOS simulations.
  • qemu-docker - A resource for integrating QEMU with Docker, enabling virtual machine emulation within containers.
  • QEMU/KVM on Docker - Demonstrates using QEMU/KVM virtualization within Docker containers for improved performance.

docker-routeros's People

Contributors

dependabot[bot] avatar evilfreelancer avatar lcuevastodoit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

docker-routeros's Issues

db failure: database or disk is full:stoppped

Hello my friend.
I use this image as a server for the Dude. Today I encountered such a problem while trying connect to server.
I freed up a couple megabytes of space on routeros but still can't connect to the dude. How can fix it? May be is it possible to create a volume for a specific folder, or what may be the options?

QEMU password

May I ask what password is required when I connect with VNC?

There was an error running this Docker on the Alpine Linux system, please resolve the issue!

attached the log information:

Failed to send flush request: Operation not permitted
RTNETLINK answers: Operation not permitted
Error: argument "qemubr1" is wrong: Device does not exist

RTNETLINK answers: Operation not permitted
Cannot find device "qemubr1"
KVM not available, running in emulation mode. This will be slow.
udhcpd: started, v1.36.1
udhcpd: max_leases=235 is too big, setting to 1
udhcpd: can't open '/var/lib/udhcpd/udhcpd.leases': No such file or directory
udhcpd: ioctl 0x8933 failed: No such device
qemu-system-x86_64: -nic tap,id=qemu1,mac=54:05:AB:CD:12:31,script=/routeros/qemu-ifup,downscript=/routeros/qemu-ifdown: could not open /dev/net/tun: No such file or directory
๐ŸŒ

This vs. VM

I want to see this image is more efficient or Virtual machine
Because you are using qemu inside alphine

exec format error

Hi, I'm trying to install this on raspberry pi 4. When I checked the log on the portainer, it's giving me this.
exec user process caused: exec format error
how to fix this?

Unable to start

It keeps throwing the below error

udhcpd: started, v1.36.1
udhcpd: max_leases=235 is too big, setting to 1
udhcpd: can't open '/var/lib/udhcpd/udhcpd.leases': No such file or directory
Enabling KVM
qemu-system-x86_64: -hda chr-7.15.1.vdi: Could not open 'chr-7.15.1.vdi': No such file or directory
udhcpd: started, v1.36.1
udhcpd: max_leases=235 is too big, setting to 1
udhcpd: can't open '/var/lib/udhcpd/udhcpd.leases': No such file or directory

Error when run Cannot find device "qemubr1"

i have error when running this image on my docker vps, this is details

Cannot find device "qemubr1"
udhcpd: started, v1.31.1
udhcpd: max_leases=235 is too big, setting to 1
udhcpd: can't open '/var/lib/udhcpd/udhcpd.leases': No such file or directory
udhcpd: ioctl 0x8933 failed: No such device
qemu-system-x86_64: could not open /dev/net/tun: No such file or directory

no internert

hi..
I installed and logged in ROS but no internet in router..where is problem

unable to start

Hello, failed to start using least image.

docker logs routeros

Failed to send flush request: Operation not permitted
RTNETLINK answers: Operation not permitted
Error: argument "qemubr0" is wrong: Device does not exist

RTNETLINK answers: Operation not permitted
Cannot find device "qemubr0"
udhcpd: started, v1.31.1
udhcpd: max_leases=235 is too big, setting to 1
udhcpd: can't open '/var/lib/udhcpd/udhcpd.leases': No such file or directory
udhcpd: ioctl 0x8933 failed: No such device
qemu-system-x86_64: could not open /dev/net/tun: No such file or directory

How to activate KVM

the cpu usage is too high
how to activate -enable-kvm on QEMU and config docker to access to KVM module?

dst-nat to another network not work when we have 2 ether

I create a docekr-compose like this

services:
    nginx:
        build: docker/nginx
        hostname: asterisk.docker
        # network_mode: none
        cap_add:
          - NET_ADMIN        
        environment:
          - GW=172.16.16.2
        networks:
          lan_net:
            ipv4_address: 172.16.16.3


    routeros:
      build: docker/routeros
      restart: unless-stopped
      cap_add:
        - NET_ADMIN
      devices:
        - /dev/net/tun
      ports:
        - "12222:22"
        - "8291:8291"
        - "12223:23"
        - "18728:8728"
        - "18729:8729"
        - "8090:80"
      networks:
        lan_internal:
          priority: 1000
          ipv4_address: 182.18.18.2
        lan_net:
          priority: 900
          ipv4_address: 172.16.16.2

networks:
    lan_net:
      driver: bridge
      ipam:
        driver: default
        config:
          - subnet: "172.16.16.0/24"
            gateway: 172.16.16.1
    lan_internal:
      ipam:
        driver: default
        config:
          - subnet: "182.18.18.0/24"
            gateway: 182.18.18.1

and in nginx add

if [ -n "$GW" ]; then
    ip route delete default ;
    ip route add default via $GW ;
fi

and my config is

/disk
set sata1 disabled=no
/interface wireless security-profiles
set [ find default=yes ] supplicant-identity=MikroTik
/port
set 0 name=serial0
/ip address
add address=172.16.16.2/24 interface=ether2 network=172.16.16.0
/ip dhcp-client
add interface=ether1
/ip firewall address-list
add address=182.18.18.2 list=Valid
/ip firewall nat
add action=masquerade chain=srcnat out-interface=ether1 src-address=\
    172.16.16.0/24
add action=dst-nat chain=dstnat dst-address-list=Valid dst-port=80\
    in-interface=ether1 protocol=tcp to-addresses=172.16.16.3

but ds-nat to nginx not working

Connection problem

Hi, i made docker run -d -p 2222:22 -p 8728:8728 -p 8729:8729 -p 5900:5900 -ti ros and can connect via ssh to localhost but i can not connect by winbox.

Initial configuration

Hi, thank you for the repo, it is a really nice idea.

I have one doubt regarding the RouterOS initial configuration, I have one docker-compose and I want to run some command or something in order to configure it (configure ppoe and radius).
do you have any way or idea of how to run a script to initially configure the Mikrotik?

isprouter:
                image: evilfreelancer/docker-routeros
                restart: unless-stopped
                cap_add:
                        - NET_ADMIN
                devices:
                        - /dev/net/tun
                ports:
                        - "2222:22"
                        - "2223:23"
                        - "8728:8728"
                        - "8729:8729"
                        - "8291:8291"
                networks:
                        static-network:
                                ipv4_address: 172.20.128.5

Add ports

Is there any way to add ethernet ports to ROS in this container?

problem other ports

hello and thanks for a good job

but I try many more and only MikroTik IP Service works behind docker and other services like VPNs and speedtest and etc.. not work!

in this case, I can connect with winbox and web but I can't start speedtest or any type of VPNs, I try to input router logs everything, but no traffic incoming the router!

output traffic it's ok, but input nothing.

docker run --privileged --name CHR -d -p 2000:2000/udp -p 8291:8291 -p 1701:1701 -p 1701:1701/udp -p 1723:1723 -p 1723:1723/udp -p 500:500/udp -p 4500:4500/udp -p 50:50 -p 50:50/udp -p 51:51 -p 51:51/udp -p 8998:80 -p 47:47 -ti evilfreelancer/docker-routeros:6.46.4

can you tell me my wrong !?

How to run in host mode?

Hi I use this command run :

docker run --cap-add=NET_ADMIN --device=/dev/net/tun --network host -ti evilfreelancer/docker-routeros

It start ok but cant connected with winbox and mikrotik self cant ping the gateway

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.