netlab Documentation

repository·dev·Indexed 20 days ago

https://github.com/ipspace/netlab

An infrastructure-as-code tool for automating the creation, configuration, and management of virtual networking labs using YAML-based intent. It supports virtualization via libvirt/KVM and containerlab, automates IPv4/IPv6 addressing and routing protocols (OSPF, BGP, IS-IS, EIGRP, RIP), and generates Ansible inventory. Key features include support for VLANs, VRFs, VXLAN, MPLS, EVPN, and SRv6, along with tools for packet capture, link impairment, and topology graphing.

Tokens
234.1K
Snippets
745
Records
1.1K
Agent score
72%

What's inside netlab

  1. Overview of netlab capabilities

    dev

    netlab is a virtual networking labbing tool that allows you to build labs using CLI and infrastructure-as-code principles. Instead of using a GUI, you describe a high-level lab topology in YAML format.

    Key Capabilities:

    • Topology Abstraction: Define labs in YAML without worrying about specific implementation details.
    • Multi-Provider Support: Use the same topology with KVM/libvirt, Docker containers, or physical devices.
    • Automated Configuration: Automatically generates Vagrant/containerlab files and Ansible inventories. It handles IP addressing (IPv4/IPv6), routing protocols (OSPF, BGP, IS-IS, etc.), VLANs, VRFs, VXLAN, and more.
    • Infrastructure Management: Can start external management tools like Graphite, SuzieQ, or Cisco NSO as specified in your topology.
  2. Overview of the BGP Routing Policies Plugin

    dev

    The bgp.policy plugin allows you to implement simple BGP routing policies in your netlab topologies. It supports:

    • Per-neighbor attributes: AS-path prepending, BGP link bandwidth, BGP local preference, BGP MED, and BGP weights.
    • Default local preference: Setting a node-wide default.
    • RFC 9234 BGP Roles: Implementing route-leak prevention on EBGP sessions.
    • Generic Routing Policies: Applying inbound and outbound generic routing policies to EBGP neighbors.

    Note: You can also use this plugin to apply generic routing policies to EBGP neighbors.

  3. Overview of the MPLS Configuration Module

    dev

    The mpls configuration module in netlab provides automated configuration for several MPLS-related technologies:

    • LDP-based label distribution: Uses Label Distribution Protocol for label exchange.
    • BGP Labeled Unicast (BGP-LU): Supports IPv4 and IPv6 over IBGP and/or EBGP sessions.
    • BGP/MPLS L3VPN: Supports VPNv4 and VPNv6 address families for IBGP and EBGP (inter-AS option B) sessions.
    • 6PE: Enables 6PE over IBGP and/or EBGP sessions.

    Note: Segment routing for MPLS is handled by a different module (sr-mpls.md).

  4. Overview of netlab show command capabilities

    dev

    The netlab show command is used to inspect various system settings and metadata. It supports outputting data in table, text, or yaml formats, making it suitable for both human reading and automated scripting.

    Available subcommands include:

    • attributes: Supported lab topology attributes.
    • defaults: User/system defaults.
    • devices: Supported devices.
    • images: Vagrant box or container names for supported devices.
    • modules: Configuration modules.
    • module-support: Configuration modules support matrix.
    • outputs: Output modules used by netlab create.
    • reports: Shipped report templates.
    • providers: Virtualization providers.
  5. Overview of the netlab CLI

    dev

    The netlab command is the primary CLI interface for managing virtual network labs. It provides a unified way to handle:

    • Data Model Transformations: Converting lab topology definitions into usable formats.
    • Lab Lifecycle: Creating, starting, restarting, and destroying virtual labs.
    • Device Configuration: Deploying initial and custom configurations using Ansible playbooks and Jinja2 templates.
    • Connectivity & Control: Connecting to device consoles, executing commands, and performing packet captures.
    • Reporting & Visualization: Generating topology graphs, addressing reports, and inspecting data structures.
  6. Overview of the SRv6 Configuration Module

    dev

    The srv6 module configures Segment Routing over IPv6 (SRv6) using IS-IS with IBGP. It uses advertised SIDs for both global connectivity and VPN services.

    Supported Features:

    • SIDs: End SIDs (nodes) and End-x SIDs (links), all statically allocated.
    • Routing: IS-IS with SRv6 TLVs.
    • Transport: SRv6 transport for global IPv4/IPv6 BGP routes.
    • VPN: BGP IPv4/IPv6 L3VPN over SRv6.

    Dependency: This module requires the isis module to be enabled in your network topology. If isis is missing, a configuration error will be triggered.

  7. Overview of the Generic Routing Configuration Module

    dev

    The Generic Routing Configuration Module in netlab provides a standardized way to implement various routing features across different network platforms. It supports the following capabilities:

    • Routing policies (route maps)
    • Prefix filters (prefix-lists)
    • BGP AS-path filters
    • BGP community filters
    • Static routes
    • Access control lists (ACLs)
  8. Overview of netlab

    dev

    netlab is an infrastructure-as-code tool for networking labs. It allows you to describe a high-level network topology and routing design in a YAML file, which the tool then uses to automate the creation and configuration of a virtual lab environment.

    Key capabilities include:

    • Virtualization Support: Generates Vagrantfile configurations for libvirt/KVM or containerlab configurations for Docker containers.
    • Automation: Creates Ansible inventory and configuration files.
    • Network Design: Automates IPv4/IPv6 addressing and complex routing protocols (OSPF, BGP, IS-IS, EIGRP, RIP, etc.).
    • Protocol Configuration: Supports a wide range of features including VLANs, VRFs, VXLAN, MPLS, EVPN, SR-MPLS, SRv6, L3VPN, and more.
    • Lab Management: Provides tools for link impairment, packet capture, and generating topology graphs/reports.
  9. Overview of the EVPN Configuration Module

    dev

    The Ethernet Virtual Private Network (EVPN) configuration module configures the BGP EVPN address family to implement L2VPN or L3VPN. It supports various transport methods and service models:

    • Transport: VXLAN-based (over IPv4 and IPv6) or MPLS-based (using LDP or SR-MPLS).
    • Service Models:
      • VLAN-Based Service: Bridging a single VLAN within an EVPN Instance.
      • VLAN-Aware Bundle Service: Bridging multiple related VLANs inside a single EVPN Instance.
      • Integrated Routing and Bridging (IRB): Supports both Symmetric and Asymmetric IRB, as well as Layer-3-only VPN (L3VPN) with symmetric IRB.
    • Design Scenarios: Supports standard and complex designs like IBGP-over-EBGP or EBGP-over-EBGP.
  10. Control Link Impairment with netlab tc

    dev

    The netlab tc command allows you to manage netem traffic control (link impairment) parameters on libvirt virtual machines or containerlab-created Docker containers. You can use it to enable, disable, display, or modify impairments like delay, loss, jitter, and rate.

    Warning: You cannot configure link impairment on point-to-point links between libvirt virtual machines that do not have tc attributes; these must be changed to Linux bridges to support traffic control.

    usage: netlab tc [-h] [-v] [-q] [--instance INSTANCE] {enable,disable,show,set} ...
  11. Configure RIPv2/RIPng features and platform support

    dev

    The ripv2 configuration module enables RIPv2 (IPv4) and RIPng (IPv6) routing. It supports passive interfaces and VRF instances depending on the operating system.

    Platform Support Matrix

    Operating systemIPv4 (RIPv2)IPv6 (RIPng)Passive interfacesRoute importVRF instancesRIP timers
    Arista EOS
    Cisco IOS/IOS XE
    Cumulus Linux
    FRR
    Nokia SR OS
    OpenBSD
    VyOS

    Note: For Cisco IOS/IOS XE, support includes IOSv, IOSv L2, CSR 1000v, Catalyst 8000v, IOL, and IOL L2. For Nokia SR OS, support includes SR-SIM and vSIM.

    To see which route types can be imported into RIPv2/RIPng for your specific environment, use the CLI command: netlab show modules -m ripv2

  12. Configure Spanning Tree Protocol (STP) with the STP Module

    dev

    The STP configuration module enables Spanning Tree Protocol (STP) to prevent network loops by dynamically blocking ports. While many platforms enable STP by default, this module allows you to explicitly control the protocol flavor, priorities, and port types across the lab.

    Key capabilities include:

    • Selecting the STP flavor (STP, MSTP, RSTP, or PVRST).
    • Setting global, node-specific, or interface-specific STP parameters.
    • Configuring STP per-VLAN by setting stp.enable within a vlans dictionary.
    # Example conceptual structure
    # stp.enable: True (Global default)
    # stp.protocol: 'rstp' (Global default)
    # nodes:
    #   node1:
    #     stp.priority: 4096
    #     interfaces:
    #       eth1:
    #         stp.port_type: 'edge'