mirror of
https://bitbucket.org/mangelo/snippets.git
synced 2024-11-22 02:41:00 +02:00
117 lines
4.0 KiB
Plaintext
117 lines
4.0 KiB
Plaintext
### Install RouterOS:
|
|
|
|
# Download RouterOS CD Image from https://mikrotik.com/download.
|
|
Select the X86 version.
|
|
wget https://download.mikrotik.com/routeros/X.XX.X/mikrotik-X.XX.X.iso
|
|
|
|
# Create a hard disk:
|
|
qemu-img create -f qcow2 mikrotik.qcow2 1G
|
|
|
|
# Install RouterOS:
|
|
qemu-system-x86_64 \
|
|
-name MIKRO1 \
|
|
-m 512 \
|
|
-smp cpus=1 \
|
|
-enable-kvm \
|
|
-hda mikrotik.qcow2 \
|
|
-cdrom mikrotik-X.XX.X.iso \
|
|
-serial telnet::2000,server,nowait \
|
|
-monitor tcp:127.0.0.1:4000,server,nowait \
|
|
-curses \
|
|
-boot d \
|
|
-net none \
|
|
-net nic,model=e1000,vlan=1,macaddr=4c:5e:0c:01:02:01 \
|
|
-net nic,model=e1000,vlan=2,macaddr=4c:5e:0c:01:02:02 \
|
|
-net nic,model=e1000,vlan=3,macaddr=4c:5e:0c:01:02:03 \
|
|
-net nic,model=e1000,vlan=4,macaddr=4c:5e:0c:01:02:04 \
|
|
-net socket,vlan=1,udp=127.0.0.1:9011,localaddr=:9001 \
|
|
-net socket,vlan=2,udp=127.0.0.1:9012,localaddr=:9002 \
|
|
-net socket,vlan=3,udp=127.0.0.1:9013,localaddr=:9003 \
|
|
-net socket,vlan=4,udp=127.0.0.1:9014,localaddr=:9004
|
|
|
|
# Install the required packages.
|
|
|
|
# Once the packages are installed, the router boots and enter
|
|
in the installation again. To poweroff the router and exit,
|
|
open another terminal, enter to the qemu monitor console
|
|
with 'telnet 127.0.0.1 4000' and execute the 'quit' command.
|
|
|
|
# Done!. RouterOS is installed in the hard disk.
|
|
|
|
|
|
### Use RouterOS.
|
|
|
|
# Power on the router:
|
|
qemu-system-x86_64 \
|
|
-name MIKRO1 \
|
|
-m 512 \
|
|
-smp cpus=1 \
|
|
-enable-kvm \
|
|
-hda mikrotik.qcow2 \
|
|
-serial telnet::2000,server,nowait \
|
|
-monitor tcp:127.0.0.1:4000,server,nowait \
|
|
-display none \
|
|
-daemonize \
|
|
-net none \
|
|
-net nic,model=e1000,vlan=1,macaddr=4c:5e:0c:01:02:01 \
|
|
-net nic,model=e1000,vlan=2,macaddr=4c:5e:0c:01:02:02 \
|
|
-net nic,model=e1000,vlan=3,macaddr=4c:5e:0c:01:02:03 \
|
|
-net nic,model=e1000,vlan=4,macaddr=4c:5e:0c:01:02:04 \
|
|
-net socket,vlan=1,udp=127.0.0.1:9011,localaddr=:9001 \
|
|
-net socket,vlan=2,udp=127.0.0.1:9012,localaddr=:9002 \
|
|
-net socket,vlan=3,udp=127.0.0.1:9013,localaddr=:9003 \
|
|
-net socket,vlan=4,udp=127.0.0.1:9014,localaddr=:9004
|
|
|
|
# For TAP connection:
|
|
As root:
|
|
tunctl -u <username> -t <devname>
|
|
ifconfig <devname> <dirip> netmask <mask> up
|
|
|
|
qemu:
|
|
-net nic,model=e1000,vlan=<N>,macaddr=4c:5e:0c:01:02:0<N> \
|
|
-net tap,vlan=<N>,ifname=<devname>,script=no
|
|
|
|
For delete the TAP interface:
|
|
tunctl -d <devname>
|
|
|
|
# For bridge connection to real ethernet interface:
|
|
As root:
|
|
ip link add <brname> type bridge
|
|
ip addr flush dev <ethN> # <-- WARNING!
|
|
ip tuntap add dev <tapname> mode tap user <username>
|
|
ip link set <ethN> master <brname>
|
|
ip link set <tapname> master <brname>
|
|
ip link set dev <brname> up
|
|
ip link set dev <tapname> up
|
|
ip link set dev <ethN> up
|
|
ip addr add <dirip/mask> dev <brname>
|
|
|
|
qemu:
|
|
-net nic,model=e1000,vlan=<N>,macaddr=4c:5e:0c:01:02:0<N> \
|
|
-net tap,vlan=<N>,ifname=<tapname>,script=no
|
|
|
|
Delete interfaces:
|
|
ip link delete <brname>
|
|
ip link delete <tapname>
|
|
ip link set dev <ethN> down
|
|
|
|
# Enter to the router serial console:
|
|
telnet 127.0.0.1 2000
|
|
username: admin
|
|
password: <blank>
|
|
|
|
# To poweroff the router:
|
|
* Inside RouterOS: /system shutdown
|
|
* Outside RouterOS: telnet 127.0.0.1 4000
|
|
quit
|
|
|
|
# Warning: the ethernet interfaces can be out of order, check
|
|
the mac address and interfaces names:
|
|
[admin@MikroTik] > /interface ethernet print
|
|
Flags: X - disabled, R - running, S - slave
|
|
# NAME MTU MAC-ADDRESS ARP
|
|
0 R ether1 1500 4C:5E:0C:01:02:03 enabled
|
|
1 R ether2 1500 4C:5E:0C:01:02:04 enabled
|
|
2 R ether3 1500 4C:5E:0C:01:02:01 enabled
|
|
3 R ether4 1500 4C:5E:0C:01:02:02 enabled
|