If just simulating Cisco gear is good enough and you don’t want to go through the trouble finding images for an emulator like GNS3, then Cisco’s Packet Tracer is a good option. Unfortunately it doesn’t support OpenBSD, and while I’m sure you could get it working natively with enough effort, I decided to spin-up a Debian virtual machine and install it there.
To make it behave like a native application (and since OpenBSD’s vmd(8) doesn’t support graphics), I have the guest’s X clients use the host’s X server. While it creates unnecessary overhead I use ssh’s X11 forwarding to keep things simple.
Setup
In the future maybe I’ll provide an image with Packet Tracer installed and some of the scripts I use to automate loading labs, etc., but for now here’s rough guideline on how to set it up. It’s pretty simple actually.
Debian VM
To start, download a Debian cloud image1 and resize it to fit all the packages you need to install. 10G is more than enough:
$ qemu-img resize $img 10G
You’ll also want to disable compression so that it’s compatible with vmd(8).2 Since qemu-img convert doesn’t enable qcow2 compression by default, the following will effectively disable compression:
$ qemu-img convert -O qcow2 -f qcow2 $img ${img%.qcow2}-openbsd.qcow2
Then add something like this to your “/etc/vm.conf”:
vm "pt" { owner jacob disk /home/jacob/vms/pt.qcow2 memory 4G local interface }
with some rules for the tap interface in “/etc/pf.conf”:
dns_server = 8.8.8.8 pass in on tap0 pass out on tap0 match out on egress from 100.64.0.0/10 to any nat-to (egress) pass in proto { udp tcp } from 100.64.0.0/10 to any port domain \ rdr-to $dns_server port domain
Once you load the new pf(4) ruleset and start/restart vmd(8) the vm should boot up with network access.
You can now connect to your vm with the vmctl(8) console command to setup ssh and enlarge the root partition to make use of the space you allocated with qemu-img earlier. To do that on the guest you’ll need to delete the partition with fdisk, create it again at the desired size with the same starting sector, then install cloud-utils and use resize2fs on your root partition. (Of course you should never do it this way when you have data you care about on the disk.)
Installing Packet Tracer on Debian
Download the Packet Tracer for Ubuntu, copy the .deb file to /tmp on the guest system, and run
$ dpkg --install *$pt_deb*
It still won’t run until until you install some dependencies. By editing /usr/local/bin/packettracer to stop redirecting errors to /dev/null you can discover what’s missing.
Running
Once Packet Tracer is installed you just need to setup X11 forwarding with ssh. It’s easiest to just add something like this to your ssh config:
Host pt.lan Hostname 100.64.1.3 ForwardX11 yes IdentityFile /home/jacob/.ssh/keys/vm/pt
If using the previous example, you can simply call
$ ssh pt.lan packettracer
and a Packet Tracer window will appear like any other.