Packettracer

From NixOS Wiki
Jump to: navigation, search

Packettracer is a network simulation software. The tool from Cisco is suitable, for example, for training as an IT specialist to learn how to deal with networks and, in particular, how to behave in the event of problems. A free and open source alternative would be GNS3

Installation

You need to enable unfree and prefetch the .deb file from Packettracer before you are able to installing it. The Package is allready available for Nix. Other Unix/Linux Distros with Nix installed can installing it on their system aswell.

 $nix-store --add-fixed sha256 CiscoPacketTracer_"version"_Ubuntu_64bit.deb
 # or with
 $nix-prefetch-url --type sha256 file:///path/to/CiscoPacketTracer_"version"_Ubuntu_64bit.deb

Declarative / Alternative .deb File

Warning: As of writing (Nixpkgs stable 24.11), this method is only available via Nixpkgs unstable.

If the specific .deb file you have sourced has not yet been explicitly supported by the Packettracer Nixpkgs source (e.g. Cisco has released a new version with a different hash), and or you wish to declaratively provide a .deb file, you can override the source .deb file using (pkgs-unstable.ciscoPacketTracer8.override { packetTracerSource = /path/to/packettracer.deb; }).

This prevents the need to manually add the .deb file to the Nix store via CLI as described above, and may be useful if you're configuring multiple systems and don't want to manually add the file to the store each time.

Note this requires storing the .deb file alongside your NixOS configuration, please ensure you are not accidentally violating relevant licencing via distribution (e.g. do not check this into a public Git repository).

Miscellaneous

Skipping Login

By default Packettracer requires logging in via a Cisco Network Academy account. This login can be subverted by preventing Packettracer from accessing the internet.

One method of preventing internet access is via Firejail. This can be achieved via CLI by first enabling Firejail via the NixOS option, and running Packettracer via firejail --noprofile --net=none packettracer8.

If you want this to be the default behavior, the following is an example module which enables Firejail and wraps the packettracer8 binary so that it runs in its own ephemeral network namespace:

{ pkgs, lib, ... }:
{
  # Packet tracer log in can be subverted if there is no internet connection
  # so use firejail to isolate packet tracer into its own network namespace
  # when running
  programs.firejail = {
    enable = true;
    wrappedBinaries = {
      packettracer8 = {
        executable = lib.getExe pkgs.ciscoPacketTracer8;

        # Will still want a .desktop entry as the package is not directly added
        desktop = "${pkgs.ciscoPacketTracer8}/share/applications/cisco-pt8.desktop.desktop";

        extraArgs = [
          # This should make it run in isolated netns, preventing internet access
          "--net=none"

          # firejail is only needed for network isolation so no futher profile is needed
          "--noprofile"

          # Packet tracer doesn't play nice with dark QT themes so this
          # should unset the theme. Uncomment if you have this issue.
          # ''--env=QT_STYLE_OVERRIDE=""''
        ];
      };
    };
  };
}

Simply running packettracer8 or launching it via the wrapped .desktop entry via your desktop environment / application launcher should now skip logging in.