Date created: Tuesday, April 9, 2024 4:44:57 PM. Last modified: Wednesday, April 10, 2024 12:03:26 PM

Netlab Notes

Install

echo "deb [trusted=yes] https://apt.fury.io/netdevops/ /" | \
sudo tee -a /etc/apt/sources.list.d/netdevops.list
sudo apt update
sudo apt install containerlab
sudo apt install ansible-core
pip install netlab

 

Defaults

View defaults with:

netlab show defaults

 

Example Topology

name: basic
provider: clab

defaults:
  device: eos
  devices:
    eos.clab.image: ceos:4.31.0F

# Default config for reference
# Add IPv6 subnets in order to use IPv6
#addressing:
#  loopback:
#    ipv4: 10.0.0.0/24
#  router_id:
#    ipv4: 10.0.0.0/24
#    prefix: 32
#  lan:
#    ipv4: 172.16.0.0/16
#  p2p:
#    ipv4: 10.1.0.0/16
#  mgmt:
#    ipv4: 192.168.121.0/24
#    start: 100
#    mac: 08-4F-A9-00-00-00
#  l2only: # Used for interfaces which should get no IP address
#  vrf_loopback:
#    ipv4: 10.2.0.0/24
#    prefix: 32

vrfs:
  cust1: # This will default to 65000:1 as the RD, import RT, and export RT
  cust2: # This will default to 65000:2 as the RD, import RT, and export RT
    import:
      - '65000:2'
      - '65000:1'

nodes:
  Cust1:
    module: [bgp]
    bgp.as: 65001
  IngressPE:
    module: [isis,bgp,vrf]
    bgp.as: 65000
  EgressPE:
    module: [isis,bgp,vrf]
    bgp.as: 65000
  Cust2:
    module: [bgp]
    bgp.as: 65002

links:
  # Because two back-2-back devices are interpretted as a P2P link by default,
  # This:
  #- name: Ingress PE to Eress PE
  #  IngressPE:
  #  EgressPE:
  #  pool: p2p
  # Is the same as this one-liner:
  #- IngressPE-EgressPE

  - name: Cust1 to Ingress PE
    Cust1:
    IngressPE:
      vrf: cust1
    pool: p2p
  - name: Ingress PE to Egress PE
    IngressPE:
    EgressPE:
    pool: p2p
  - name: Egress PE to Cust2
    EgressPE:
      vrf: cust2
    Cust2:
    pool: p2p

 

Example Commands

Create the topology data (which is passed to Containerlab and Ansible) to check for issues:

netlab create -v topology.yml

These files can be deleted with

netlab down --cleanup

 

Start the lab (this will run "netlab create" to generate lab topology and configuration data and then "netlab initial" to apply the configs once the devices have started):

netlab up -v ddos_redirect.yml

 

Show the status of the lab:

netlab status

 

This will dump a massive YAML blob of all the lab configuration:

netlab inspect

 

Destroy the lab:

netlab down