mirror of
https://github.com/EvilFreelancer/docker-routeros.git
synced 2025-08-03 17:44:34 +02:00
Single interface mode updated to same version as for 8 interfaces
This commit is contained in:
parent
c032c743ed
commit
9097a0e503
1 changed files with 23 additions and 29 deletions
|
@ -1,8 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# A bridge of this name will be created to host the TAP interface created for
|
||||
# the VM
|
||||
QEMU_BRIDGE='qemubr0'
|
||||
QEMU_BRIDGE_ETH1='qemubr1'
|
||||
default_dev1='eth0'
|
||||
|
||||
# DHCPD must have an IP address to run, but that address doesn't have to
|
||||
# be valid. This is the dummy address dhcpd is configured to use.
|
||||
|
@ -15,31 +14,25 @@ QEMU_IFDOWN='/routeros/qemu-ifdown'
|
|||
# The name of the dhcpd config file we make
|
||||
DHCPD_CONF_FILE='/routeros/dhcpd.conf'
|
||||
|
||||
function default_intf() {
|
||||
ip -json route show | jq -r '.[] | select(.dst == "default") | .dev'
|
||||
}
|
||||
|
||||
# First step, we run the things that need to happen before we start mucking
|
||||
# with the interfaces. We start by generating the DHCPD config file based
|
||||
# on our current address/routes. We "steal" the container's IP, and lease
|
||||
# it to the VM once it starts up.
|
||||
/routeros/generate-dhcpd-conf.py $QEMU_BRIDGE > $DHCPD_CONF_FILE
|
||||
default_dev=`default_intf`
|
||||
/routeros/generate-dhcpd-conf.py $QEMU_BRIDGE_ETH1 >$DHCPD_CONF_FILE
|
||||
|
||||
# Now we start modifying the networking configuration. First we clear out
|
||||
# the IP address of the default device (will also have the side-effect of
|
||||
# removing the default route)
|
||||
ip addr flush dev $default_dev
|
||||
|
||||
# Next, we create our bridge, and add our container interface to it.
|
||||
ip link add $QEMU_BRIDGE type bridge
|
||||
ip link set dev $default_dev master $QEMU_BRIDGE
|
||||
|
||||
# Then, we toggle the interface and the bridge to make sure everything is up
|
||||
# and running.
|
||||
ip link set dev $default_dev up
|
||||
ip link set dev $QEMU_BRIDGE up
|
||||
function prepare_intf() {
|
||||
#First we clear out the IP address and route
|
||||
ip addr flush dev $1
|
||||
# Next, we create our bridge, and add our container interface to it.
|
||||
ip link add $2 type bridge
|
||||
ip link set dev $1 master $2
|
||||
# Then, we toggle the interface and the bridge to make sure everything is up
|
||||
# and running.
|
||||
ip link set dev $1 up
|
||||
ip link set dev $2 up
|
||||
}
|
||||
|
||||
prepare_intf $default_dev1 $QEMU_BRIDGE_ETH1
|
||||
# Finally, start our DHCPD server
|
||||
udhcpd -I $DUMMY_DHCPD_IP -f $DHCPD_CONF_FILE &
|
||||
|
||||
|
@ -49,11 +42,12 @@ udhcpd -I $DUMMY_DHCPD_IP -f $DHCPD_CONF_FILE &
|
|||
# -serial mon:stdio: use "monitored stdio" as our serial output.
|
||||
# -nic: Use a TAP interface with our custom up/down scripts.
|
||||
# -drive: The VM image we're booting.
|
||||
# mac: Set up your own interfaces mac addresses here, cause from winbox you can not change these later.
|
||||
exec qemu-system-x86_64 \
|
||||
-nographic -serial mon:stdio \
|
||||
-vnc 0.0.0.0:0 \
|
||||
-m 512 \
|
||||
-smp 4,sockets=1,cores=4,threads=1 \
|
||||
-nic tap,id=qemu0,script=$QEMU_IFUP,downscript=$QEMU_IFDOWN \
|
||||
"$@" \
|
||||
-hda $ROUTEROS_IMAGE
|
||||
-nographic -serial mon:stdio \
|
||||
-vnc 0.0.0.0:0 \
|
||||
-m 512 \
|
||||
-smp 4,sockets=1,cores=4,threads=1 \
|
||||
-nic tap,id=qemu1,mac=54:05:AB:CD:12:31,script=$QEMU_IFUP,downscript=$QEMU_IFDOWN \
|
||||
"$@" \
|
||||
-hda $ROUTEROS_IMAGE
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue