EvilFreelancer / docker-routeros

Mikrotik RouterOS inside Docker container
https://hub.docker.com/r/evilfreelancer/docker-routeros/
MIT License
369 stars 132 forks source link

Add ports #1

Closed reinethernal closed 5 years ago

reinethernal commented 5 years ago

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

EvilFreelancer commented 5 years ago

Hello!

Yep, you may use docker-compose config, for example:

version: "3"

services:

  routeros-6-42:
    image: evilfreelancer/docker-routeros:6.42.12
    restart: unless-stopped
    ports:
      - "12222:22"
      - "12223:23"
      - "18728:8728"
      - "18729:8729"
      ....list of additional ports....

Or pure docker way via -p key with list of ports

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

First number is port of your host machine, second is internal container port, via iptable both these ports will be communicated

reinethernal commented 5 years ago

Oh, sorry for the inaccuracy. I meant adding network interfaces, like ethernet 2, etc to be available at ROS.

EvilFreelancer commented 5 years ago

Hm, I think this is not possible for current solution, because docker container has only one erhernet adapter by default (mean eth0, you can login to container and print all available interfaces).

Probably you may use network_mode: "host" in docker compose config and container will see all available interfaces, then need to modify entrypoint.sh file and add required interfaces.

reinethernal commented 5 years ago

Could you please tell me login and entry point /bin/sh or /bin/bash? and credentials would be helpfull too)

EvilFreelancer commented 5 years ago

docker-compose exec routeros-6-42 bash or docker-compose exec routeros-6-42 sh by default ROS has no password, you can login via telnet as admin user

reinethernal commented 5 years ago

Thx, i'll try)

reinethernal commented 5 years ago

I tried to add some interfaces, but get stuck. I have an idea to add several bridgesm because host network has only one interface. Is it possible?

EvilFreelancer commented 5 years ago

Yeah, you can add few networks to docker container (networks also mean network interfaces), probably best solution for this is rewriting entrypoint and docker compose file.

I've tried to create few intefaces for qemu inside docker container, but seems it's not so easy as I expected. My second idea is VDE switch http://wiki.virtualsquare.org/wiki/index.php/VDE_Basic_Networking and connect qemu to docker interfaces via this switch, because I've checked TAP tunnels and seems it's not work.

reinethernal commented 5 years ago

I reached my goal by adding following lines to the entrypoint.sh -device e1000,netdev=net1 \ -netdev user,id=net1 \ -device e1000,netdev=net2 \ -netdev user,id=net2 \ -device e1000,netdev=net3 \ -netdev user,id=net3. tried to add more, but startup take too long. idk hy so, but 4 interfaces is more than enough for me. Thank you for help. Issue can be closed)

EvilFreelancer commented 5 years ago

So you just was needed few interfaces which not actually work? (Probably by test reasons) Because your solution looks like "just create few interfaces which not connected to external network" Or it's really working with external network??? :)

reinethernal commented 5 years ago

Yes, but then i connected them to additional bridges

EvilFreelancer commented 5 years ago

Can you please provide complete solution? (maybe via gist or somehow else) I'll add it to this repo as alternative edition of docker image, because for right now this container is for test purposes only.

reinethernal commented 5 years ago

Sure. Here in is https://gist.github.com/reinethernal/c5eb0c376714d21120369c07bc9be10e

EvilFreelancer commented 5 years ago

I've added yet another entrypoint by your gist https://github.com/EvilFreelancer/docker-routeros/blob/master/entrypoint_with_four_interfaces.sh All next releases will be with this file (you already may use image with latest tag) For use this you just will need set another entrypoint via your docker-compose file