Date created: Tuesday, April 9, 2024 4:44:57 PM. Last modified: Wednesday, December 11, 2024 12:00:52 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
Test netlab works with the chosen virtualisation provider:
netlab test clab
Check what system images netlab has detected:
netlab show images
Defaults
View defaults with:
netlab show defaults
Example Topology
Use the following commands to see available config options:
# Show all config options at each level
netlab show attributes
# Only show the config options for a specific level
netlab show attributes link bandwidth: int bridge: id disable: bool interfaces: null mtu: max_value: 65535 min_value: 64 type: int ...
The example config below shows some of the default values.
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
Start/Stop/Backup
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 topology.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
Export lab configs when running:
netlab collect -o configs
Previous page: napalm_with_ssh_tunnel.py
Next page: Nornir - Hello World