Mikrotik to Mikrotik IPSec Tunnel

networking

routeros

openbsd

qemu

linux

mikrotik

In this tutorial I will be showing you how to connect two Mikrotik routers which will be hosted using QEMU. The configuration will allow both routers to communicate via an IPSec tunnel. Each router will have one or more clients connected. Here is a diagram of the network topology:




First we will need the RouterOS, and OpenBSD images so we can use QEMU to run them.

Fetch the RouterOS image:

curl -O https://download.mikrotik.com/routeros/7.11.2/chr-7.11.2.img.zip



Fetch the OpenBSD install ISO:

curl -O https://cdn.openbsd.org/pub/OpenBSD/7.3/amd64/install73.iso

Stream IPcam using Docker & Kerberos agent

kerberos

live stream

linux

ipcam

docker

Docker is required to follow along

Get and run kerberos agent image

docker run -p 80:80 --name mycamera -d --restart=always kerberos/agent:latest

Get and run rtsp docker image

docker run --name rtsp --rm -it -e MTX_PROTOCOLS=tcp -e MTX_WEBRTCADDITIONALHOSTS=<local_ip_address> -p 8554:8554 -p 1935:1935 -p 8888:8888 -p 8889:8889 -p 8890:8890/udp -p 8189:8189/udp bluenviron/mediamtx

Record video from webcam ( x264 format required )

ffmpeg -f v4l2 -framerate 60 -video_size 1280x720 -input_format mjpeg -i /dev/video0 video.mkv

Send stream to rtsp server

ffmpeg -re -stream_loop -1 -i video.mkv -f rtsp rtsp://<local_ip_address>:8554/mystream

Test stream

fplay -fflags nobuffer -rtsp_transport tcp rtsp://localhost:8554/mystream

test linux

this

linux

test linux test linux

Live Stream Webcam

ffmpeg

live stream

linux

webcam

Create dir and get source

mkdir ~/source/rtsp-simple-server && cd ~/source/rtsp-simple-server && git clone https://github.com/bhaney/rtsp-simple-server.git && cd rtsp-simple-server

Compile and run

go run .

Start recording /dev/video0 along with audio

ffmpeg -f v4l2 -framerate 25 -video_size 320x175 -i /dev/video0 -f pulse -ac 2 -i default -f rtsp -rtsp_transport tcp rtsp://localhost:8554/mystream

Play stream

ffplay -fflags nobuffer -fflags discardcorrupt -flags low_delay -framedrop -avioflags direct -rtsp_transport tcp rtsp://localhost:8554/mystream

To be able to record a video with webcam overlay and send it to streaming server the video needs to be created first then streamed.

Start recording

ffmpeg -f x11grab -video_size 1920x1080 -framerate 30 -i :0.0 -f pulse -ac 2 -i default -f v4l2 -video_size 160x120 -framerate 30 -i /dev/video0 -b:v 7000k -vcodec mpeg4 -qscale:v 1 -threads 8 -filter_complex 'overlay=main_w-overlay_w:main_h-overlay_h:format=yuv444' -vcodec libx264 -preset ultrafast -qp 0 -pix_fmt yuv444p video.mp4

Send to rtsp server

ffmpeg -re -stream_loop -1 -i video.mp4 -c copy -f rtsp rtsp://localhost:8554/mystream


New Beat

Random Beat

No Affect

Greef

Survive

networking1

routeros1

openbsd1

qemu1

linux4

mikrotik1

kerberos1

live stream2

ipcam1

docker1

this1

ffmpeg1

webcam1