This page looks best with JavaScript enabled

GNS3 + Cisco Router + Mikrotik Router-QEmu + VirtualBox Hosts

 ·  🎃 kr0m

In this article, we will use a variety of technologies to simulate practically any network scenario we need. GNS3 is a very complete network simulator, Dynamips is a Cisco hardware emulator, QEmu is a processor emulator and virtualization software, and VirtualBox is virtualization software.

In this scenario, we will use a Cisco router, a Mikrotik router, and two Gentoo virtual machines that will act as hosts. Having real virtual machines will allow us greater flexibility and the ability to test any type of attack/exploit on Mikrotik or Cisco routers.

There will be 3 networks:

  1. Between Gentoo-1 and the Mikrotik router: 192.168.2.0/24
  2. Between the Mikrotik router and the Cisco router: 192.168.1.0/24
  3. Between the Cisco router and Gentoo-3: 192.168.3.0/24

We install everything we need:

emerge -av app-emulation/qemu net-misc/gns3-server net-misc/gns3-gui app-emulation/dynamips net-misc/ubridge

To link the GNS3 network architecture with the VBox virtual machines, we will use ubridges . We add the user who will run the VBox, GNS3, and Qemu software to the ubridge group:

gpasswd -a kr0m ubridge

We start GNS3:

gns3

We configure the ubridge binary path:

Edit -> Preferences -> Server -> Ubirdge path:
/usr/bin/ubridge

We create the Qemu and VirtualBox virtual machines in the config so that they will appear as available in the menu of available network elements:

Edit -> Preferences -> Qemu -> Qemu VMs:
New
Edit -> Preferences -> VirtualBox -> VirtualBox VMs:
New

We create a 1G disk image where we will install Mikrotik’s RouterOS:

qemu-img create -f qcow2 mikrotik.img 1024M

We download the RouterOS installation image from the Mikrotik website:
https://mikrotik.com/download/archive

We boot from the ISO and install the OS and tools:

qemu-system-x86_64 mikrotik.img -boot d -cdrom mikrotik-6.40.9.iso

We boot the router from the hard disk:

qemu-system-x86_64 mikrotik.img -boot c

We log in to the router:

admin
ENTER


We configure the two interfaces and let it know through static routing that the 192.168.3.0/24 network is accessible through 192.168.1.2:

[admin@MikroTik] >
/ip address
add address=192.168.1.1/24 interface=ether1 network=192.168.1.0
add address=192.168.2.1/24 interface=ether2 network=192.168.2.0
/ip route add dst-address=192.168.3.0/24 gateway=192.168.1.2

We configure the two interfaces on the Cisco router and let it know through static routing that the 192.168.2.0/24 network is accessible through 192.168.1.1:

Cisco3640c3640#configure terminal
Cisco3640c3640(config)#interface FastEthernet0/0
Cisco3640c3640(config-if)#ip address 192.168.1.2 255.255.255.0
Cisco3640c3640(config-if)#no shutdown
Cisco3640c3640(config-if)#exit

Cisco3640c3640(config)#interface fastEthernet1/0
Cisco3640c3640(config-if)#ip address 192.168.3.1 255.255.255.0
Cisco3640c3640(config-if)#no shutdown
Cisco3640c3640(config-if)#exit

Cisco3640c3640(config)#ip route 192.168.2.0 255.255.255.0 192.168.1.1
Cisco3640c3640(config)#end
Cisco3640c3640#copy running-config startup-config

NOTE: When adding VirtualBox virtual machines from GNS3 (dragging from the left), they will have the network config with ubridge.

We configure the IP and GW of the first Gentoo:

ifconfig enp0s3 192.168.2.2 netmask 255.255.255.0
route add -net 192.168.2.0/24 dev enp0s3
route add default gw 192.168.2.1

We configure the IP and GW of the second Gentoo:

ifconfig enp0s3 192.168.3.2 netmask 255.255.255.0
route add -net 192.168.3.0/24 dev enp0s3
route add default gw 192.168.3.1

Now both networks are routed and fully accessible.

If you liked the article, you can treat me to a RedBull here