Mantra Networking Mantra Networking

Batfish: Snapshot

Batfish: Snapshot
Created By: Lauren R. Garcia

Table of Contents

  • Overview
  • Snapshot Contents
  • Creating a Snapshot
  • Common Commands Related to Snapshots
  • Best Practices for Snapshots
  • Snapshot in Batfish Analysis Workflow
  • Conclusion

Batfish Snapshots: Overview

What Is a Batfish Snapshot?

A Batfish snapshot is a point-in-time capture of your network’s configuration and supporting files. Think of it as a self-contained folder or archive that holds all the data needed to describe how your network is set up at a certain moment. This includes device configs (like routers, switches, firewalls), optional topology maps, and other supplemental information.

Batfish uses these snapshots as the main input for its analysis engine. By working with a snapshot, Batfish can simulate network behavior, check reachability, validate policy enforcement, and detect configuration errors—without touching your production environment.

Why You Should Know About Snapshots

  • Consistent, Reliable Analysis: Snapshots let you analyze your network as it actually exists, reducing guesswork and improving confidence in the results.
  • Change Tracking: By creating and storing snapshots over time, you can track configuration changes, quickly pinpoint what changed, and correlate those changes with network issues.
  • Safe Testing and Validation: Snapshots provide an isolated way to test configuration edits or design changes before rolling them out live, helping prevent outages or security lapses.
  • Automation Friendly: They fit naturally into modern, automated workflows—making it easy to integrate network validation into CI/CD pipelines or scheduled compliance checks.

How Batfish Snapshots Work

  1. Collection: You gather all necessary device configurations and any relevant support files, then organize them into the required structure for Batfish.
  2. Packaging: These files are bundled into a “snapshot” directory. Additional files, such as topology mappings or interface databases, can be included as needed.
  3. Upload/Initialization: The snapshot is uploaded or initialized in the Batfish environment (using CLI, API, or integration scripts).
  4. Analysis: Batfish parses the files in the snapshot, builds a network model, and performs analyses—such as simulating packet flow, checking access policies, and identifying inconsistencies.
  5. Iteration: As your network changes, you can create new snapshots, analyze differences, and continually validate the environment as part of your workflow.

A solid understanding of Batfish snapshots is fundamental to unlocking the power of automated network verification. Whether you’re deploying new devices, troubleshooting, or running ongoing audits, snapshots keep your analysis tightly aligned with reality—making your operations safer and more predictable.

Snapshot Contents

A Batfish snapshot is a collection of files that represent the state of your network at a single point in time. The main components included in a typical snapshot are structured to allow Batfish to perform detailed network analyses.

  • Device Configuration Files (configs): Store the raw configuration files from all network devices (routers, switches, firewalls, etc.). These files must be placed in a configs directory inside the snapshot folder. Batfish supports most major vendors and can handle configs from mixed environments.
  • Topology and Connectivity Data: Optional supplemental files that describe Layer 1 and Layer 2 topologies, device connections, and host relationships. Examples include layer1_topology.json or hosts files to map out physical or virtual connections.
  • Cloud Provider Data: For cloud environments, snapshots may include exports from platforms like AWS, placed in designated folders (such as aws_configs), following Batfish’s required formats for VPC, subnet, and gateway data.
  • Supporting and Supplementary Files: Additional files such as VLAN databases, interface mappings, or custom JSON files to further specify aspects of the network not captured in base configs. These provide Batfish with more context for accurate modeling.

This file structure makes it possible for Batfish to parse, validate, and simulate the entire network as captured in the snapshot, supporting both on-prem and cloud-native architectures.

Creating a Snapshot

Creating a snapshot in Batfish involves capturing your network's configuration files and packaging them for analysis. This process can be done manually or automated for efficiency.

Step 1: Prepare Configuration Files

Gather the configuration files from all your network devices, such as routers, switches, and firewalls. Organize these files into a directory, making sure the directory structure matches Batfish’s expected format (e.g., a configs folder inside the snapshot directory).

Step 2: Initialize Batfish Session

Start by initializing a Batfish session using the CLI to connect with the Batfish server:

bf init

Step 3: Upload and Initialize the Snapshot

Use the bf snapshot --init command to upload your configuration directory and create the snapshot on the server. Replace /path/to/configs and snapshotName with your directory path and desired snapshot name:

bf snapshot --init /path/to/configs snapshotName

Step 4: Verify Snapshot Upload

After uploading, verify that the snapshot is available by listing all uploaded snapshots:

bf snapshot --list

Optional: Automate Snapshot Creation

Integrate snapshot creation commands into scripts or CI/CD pipelines to automatically generate and upload snapshots when network configuration changes occur. This helps keep analyses current without manual intervention.

Common Commands Related to Snapshots

This section outlines the main commands used to manage and interact with Batfish snapshots through the CLI.

Step 1: Initialize Batfish Session

Before using snapshot commands, initialize your Batfish session:

bf init

Step 2: Upload and Initialize a Snapshot

Create or update a snapshot on the Batfish server from your configuration directory:

bf snapshot --init <path_to_configs> <snapshot_name>

Step 3: List All Snapshots

View all snapshots currently available in your project:

bf snapshot --list

Step 4: Delete a Snapshot

Remove a specific snapshot from the server when it is no longer needed:

bf snapshot --delete <snapshot_name>

Step 5: Rename a Snapshot

Change the name of an existing snapshot:

bf snapshot --rename <old_name> <new_name>

Step 6: Show Snapshot Details

Display detailed information about a particular snapshot:

bf snapshot --info <snapshot_name>

Using these commands, you can effectively manage your snapshots for analysis and automation.

Best Practices for Snapshots

Following these guidelines can help ensure that your Batfish snapshots are efficient, manageable, and useful for accurate network analysis.

Step 1: Keep Snapshots Focused

Include only the configuration files and support data necessary for the analysis. Avoid adding unrelated files to keep snapshots concise and reduce processing time.

Step 2: Use Version Control

Manage your snapshot directories using version control systems like Git. This helps track changes, enables collaboration, and provides history for troubleshooting.

Step 3: Update Snapshots Regularly

Create new snapshots whenever network configurations change or on a scheduled basis. This ensures your analysis reflects the current network state.

Step 4: Apply Clear Naming Conventions

Name snapshots in a way that clearly identifies their purpose, date, or affected devices. This makes it easier to find and distinguish different snapshots.

Step 5: Automate Snapshot Creation

Incorporate snapshot creation into automated workflows using scripts or CI/CD pipelines. Automation reduces manual effort and helps maintain up-to-date snapshots consistently.

Snapshot in Batfish Analysis Workflow

This section explains the typical steps involved in using a snapshot to perform network analyses with Batfish.

Step 1: Upload or Initialize a Snapshot

Start by uploading your network configuration files as a snapshot to the Batfish server, or initialize an existing snapshot for use in analysis.

Step 2: Specify the Snapshot in Your Queries

When running Batfish analyses, specify the snapshot name to indicate the dataset on which the queries will operate.

Step 3: Run Network Analyses

Execute various analyses such as reachability checks, routing policy verification, or forwarding state simulations based on the snapshot data.

Step 4: Review and Interpret Results

Examine the output from Batfish to identify possible misconfigurations, policy violations, or network behavior insights.

Step 5: Iterate and Update Snapshots

Based on findings, update network configurations as needed and create new snapshots to continue validation and monitoring.

Conclusion

Throughout this post, we explored how Batfish snapshots serve as a fundamental foundation for accurate network analysis by capturing your network configurations and related data at a specific moment. We learned what goes into a snapshot, how to create and manage snapshots through common CLI commands, and how incorporating them into your workflow can streamline network validation and troubleshooting.

Maintaining organized, focused, and regularly updated snapshots, along with automating their creation when possible, can greatly enhance your efficiency and confidence in network change management. By consistently using snapshots in your Batfish workflows, you ensure your network is continuously analyzed against a reliable and current dataset.

Thank you for following along! I hope this guide empowers you to integrate Batfish snapshots effectively into your network automation and validation processes. Feel free to share your experiences or reach out if you have any questions — happy analyzing!