From d2841792729f0802a3ed8614522394e19d59b0af Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Sat, 24 Sep 2022 13:04:47 +0100 Subject: [PATCH] script and README to start routeros configured for pppoe --- tests/support/ppp-server/README.md | 28 ++++++++++++++++++++++++ tests/support/ppp-server/chr.sh | 12 ++++++++++ tests/support/ppp-server/routeros.config | 24 ++++++++++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 tests/support/ppp-server/README.md create mode 100755 tests/support/ppp-server/chr.sh create mode 100644 tests/support/ppp-server/routeros.config diff --git a/tests/support/ppp-server/README.md b/tests/support/ppp-server/README.md new file mode 100644 index 0000000..41b92f0 --- /dev/null +++ b/tests/support/ppp-server/README.md @@ -0,0 +1,28 @@ +# ppp-server + +To test a router, we need an upstream connection. In this directory, +find + +* run.sh, a script that will start a RouterOS image in qemu. + Login when prompted, username is "admin", blank password +* routeros.config, a set of commands you can feed into routeros + to set up PPPoE + +To get the chr-7.5.img image, visit https://mikrotik.com/download and +look in the section titled "Cloud Hosted Router" for "Raw disk image" + +You may need to open your firewall a bit to allow multicast packets +so that the upstream and the liminix qemu instances may communicate + +config.networking.firewall.extraCommands = '' +ip46tables -A nixos-fw -m pkttype --pkt-type multicast -p udp --dport 1234:1236 -j nixos-fw-accept +''; + +## To connect to the routeros serial + +The Qemu instance running RouterOS is headless, but it creates +two unix sockets for serial port and monitor. + + socat -,raw,echo=0,icanon=0,isig=0,icrnl=0,escape=0x0f tests/support/ppp-server/qemu-console + + socat -,raw,echo=0,icanon=0,isig=0,icrnl=0,escape=0x0f tests/support/ppp-server/qemu-monitor diff --git a/tests/support/ppp-server/chr.sh b/tests/support/ppp-server/chr.sh new file mode 100755 index 0000000..a028f50 --- /dev/null +++ b/tests/support/ppp-server/chr.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env sh +/nix/store/ydwiiagdhczynh2lbqh418rglibv93rv-qemu-host-cpu-only-7.0.0/bin/qemu-kvm \ + -M q35 -display none \ + -m 1024 \ + -accel kvm \ + -daemonize \ + -serial unix:qemu-console,server,nowait -monitor unix:qemu-monitor,server,nowait \ + -drive file=chr-7.5.img,format=raw,if=virtio \ + -netdev socket,id=access,mcast=230.0.0.1:1234 \ + -device virtio-net-pci,disable-legacy=on,disable-modern=off,netdev=access,mac=ba:ad:1d:ea:11:02 \ + -netdev socket,id=world,mcast=230.0.0.1:1236 \ + -device virtio-net-pci,disable-legacy=on,disable-modern=off,netdev=world,mac=ba:ad:1d:ea:11:01 diff --git a/tests/support/ppp-server/routeros.config b/tests/support/ppp-server/routeros.config new file mode 100644 index 0000000..fe2fc26 --- /dev/null +++ b/tests/support/ppp-server/routeros.config @@ -0,0 +1,24 @@ +# sep/23/2022 21:05:02 by RouterOS 7.5 +# software id = +# +# run "/export show-sensitive" to recreate this +# +/interface ethernet +set [ find default-name=ether1 ] disable-running-check=no name=access +set [ find default-name=ether2 ] disable-running-check=no name=world +/disk +set sata1 disabled=no +/interface wireless security-profiles +set [ find default=yes ] supplicant-identity=MikroTik +/ip pool +add name=pppoe-pool ranges=192.168.100.10-192.168.100.99 +/port +set 0 name=serial0 +/ppp profile +add local-address=192.168.100.1 name=pppoe-profile remote-address=pppoe-pool +/interface pppoe-server server +add default-profile=pppoe-profile disabled=no interface=access service-name=internet +/ip dhcp-client +add interface=*1 +/ppp secret +add name=db123@a.1 password=NotReallyTheSecret profile=pppoe-profile service=pppoe