Netlab is an great opensource project for easy deployment of network labs, initiated and managed by Ivan Pepelnjak. Here's just some of my notes about installation and operation:
The application is installed in /usr/local/lib/python3.10/dist-packages/netsim. There you can find files like /defaults/addressing.yml where we can customize ips or change them to ipv6
The below process is for bare metal server in equinix metal but is easily extrapolatable to other bare metal env.
! Be sure you create the instance with Ubuntu LTS ! Manually scp image ! ! Via 'user data' #!/bin/bash apt remove needrestart -y sudo add-apt-repository universe apt-get update -y apt install python3-pip -y python3 -m pip install netsim-tools ! (consider) python3 -m pip3 install --upgrade pyopenssl cryptography ! ! APPLY THIS MANUALLY netlab install ubuntu ansible libvirt -y usermod -a -G libvirt $USER echo 'user = "root"' >> /etc/libvirt/qemu.conf echo 'group = "root"' >> /etc/libvirt/qemu.conf service libvirtd restart netlab libvirt package eos vEOS-lab-4.28.0F.vmdk ! Manually: follow recipe here and box is automatically added: LINK AT THE BOTTOM! git clone https://github.com/jotasantos/netsim-labs.git git clone git@github.com:jotasantos/ansible.git ! ! create topology file.. netlab up
https://softbackbone.duckdns.org/doku.php?id=virtualization:containerlab:veosinitial
https://softbackbone.duckdns.org/doku.php?id=virtualization:containerlab:csr100vinstall
LIFECYCLE NETLAB PROJECT - LIBVIRT ! First use
netlab up !! work on the lab netlab collect netlab down
Here I come back to work on the lab
vagrant up netlab initial ansible-playbook -i hosts.yml pusheos.yml !! work in the lab netlab collect git add,commit.push netlab down
Containerlab saves automatically the nodes configuration. If we want versioning control on out lab we can push the content to github. Nowever this uses quite a lot of space. We can prevent git to push the nodes configuration with the .gitignore below. If we need to share the devices configuration, use the command with tarball also below to save/share configs:
cat .gitignore **/archive/ **/schedule/ **/flash/ **/.vagrant/ vault.key .Python [Bb]in [Ii]nclude [Ll]ib [Ll]ib64 [Ll]ocal [Ss]cripts pyvenv.cfg .venv .env pip-selfcheck.json ! This to save all the containerlab configs at once: netlab clab tarball
—-
TROUBLESHOOTING
virsh net-dhcp-leases --network vagrant-libvirt # this is to see the dhcp leases for given by libvirt for management cat /var/lib/libvirt/dnsmasq/virbr0.* vim /etc/libvirt/qemu/networks/vagrant-libvirt.xml
Now manage Cumulus-VX instances:
netsim multicast lab
sudo vtysh / sh run / wr sudo vi /etc/frr/daemons # enable pim sudo systemctl restart frr sudo vtysh ! paste the saved configuration (twice, for ospf) wr interface swp1 ip pim interface swp2 ip pim interface swp3 ip pim interface swp4 ip pim exit wr
NEXUS
# Download image from cisco: site nexus9300v.9.3.5.box vagrant box add nexus9300v.9.3.5.box --name cisco/nexus9300v vagrant mutate cisco/nexus9300v libvirt
FOLDERS AND DEV ADVICES:
See: https://netlab.tools/dev/module-attributes/
# Default loopback, LAN, and P2P prefixes loopback: ipv6: 2001:db8:0::/48 router_id: ipv4: 10.0.0.0/24 prefix: 32 lan: ipv6: 2001:db8:3e8::/48 p2p: ipv6: 2001:db8:3e9::/48 mgmt: ipv4: 192.168.121.0/24 start: 100 mac: 08-4F-A9-00-00-00 l2only: vrf_loopback: ipv6: 2001:db8:3ea::/48
TCPDUMP IN NETLAB: https://netlab.tools/netlab/capture/
netlab up -p libvirt:p2p_bridge # otherwise impossible to capture in lobvirt p2p links netlab capture r1 GigabitEthernet0/3 icmp -l netlab capture r1 GigabitEthernet0/3 -U -s0 -w - | sudo wireshark -k -i -