Generic Linux Devices¶
You can run Linux hosts or routers in virtual machines or containers. The default image used for a Linux virtual machine is Ubuntu 20.04, the default container image is Python 3.9 container running on Alpine Linux.
To use any other Linux distribution or container, or to start a home-built Vagrant box or Docker container, add image attribute with the name of Vagrant box or Docker container to the node data. The only requirements for a Linux virtual machine is working Python environment (to support Ansible playbooks used in netlab initial command) and the presence of ip command used in initial device configuration. Docker containers have no requirements (see below)
Generic Linux device is an IP host that by default does not support IP forwarding or IP routing protocols. It uses static routes set up as follows:
IPv4 default route points to Vagrant- or containerlab management interface (set by Vagrant/DHCP or containerlab).
IPv6 default route points to whichever adjacent device is sending IPv6 Route Advertisement messages (default Linux behavior).
IPv4 static routes for all IPv4 address pools defined in lab topology point to the subnet default gateway on the first non-management interface.
The default gateway on a subnet is set by the gateway module. If you’re not using that module, netlab sets the default gateway to the interface IP address of the first non-host device connected to the subnet.
Packet Forwarding on Linux Hosts¶
IPv4 and IPv6 packet forwarding on Linux devices is controlled with the role node parameter:
host (default): a Linux device does not perform packet forwarding and cannot be the default gateway for other hosts.
gateway: a Linux device does not perform packet forwarding but acts as the default gateway for other hosts. You will have to install a proxy (or a similar solution) for inter-subnet packet forwarding.
router: A Linux device performs packet forwarding but does not run routing protocols. Use frr or cumulus device if you want to run routing protocols on a Linux server.
netlab does not configure a global loopback IP address on Linux nodes with role set to host (the default netlab setting).
A loopback IP address is allocated to a Linux node if you set role to any other value, and the initial configuration script configures an additional IP address on the lo interface, for example:
vagrant@host:~$ ip addr 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet 10.0.0.1/32 scope global lo valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 08:4f:a9:00:00:01 brd ff:ff:ff:ff:ff:ff inet 192.168.121.101/24 brd 192.168.121.255 scope global dynamic eth0 valid_lft 3587sec preferred_lft 3587sec inet6 fe80::a4f:a9ff:fe00:1/64 scope link valid_lft forever preferred_lft forever 3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 52:54:00:50:03:5a brd ff:ff:ff:ff:ff:ff inet 10.1.0.1/30 brd 10.1.0.3 scope global eth1 valid_lft forever preferred_lft forever inet6 fe80::5054:ff:fe50:35a/64 scope link valid_lft forever preferred_lft forever
LLDP is started on Ubuntu virtual machines if the netlab_lldp_enable group variable is set to True (default setting). LLDP is not started in Linux containers or in non-Ubuntu Linux virtual machines.
To disable LLDP on Ubuntu virtual machines, set the netlab_lldp_enable node parameter or defaults.devices.linux.group_vars.netlab_lldp_enable variable to False.
Initial Configuration on Linux Virtual Machines¶
netlab supports two Linux networking configuration mechanisms:
Netplan-based configuration on Ubuntu – used when the netlab_linux_distro group variable is set to ubuntu (default setting)
Traditional configuration with ip commands.
You might have to change the initial configuration mechanism to traditional configuration if you’re using Linux virtual machines that are not based on Ubuntu. To do that, set the node netlab_linux_distro parameter to vanilla or set defaults.devices.linux.provider.group_vars.netlab_linux_distro variable to vanilla.
Ubuntu Package Installation During Initial Configuration¶
If needed the netlab initial configuration script installs lldpd and net-tools Ubuntu packages.
net-tools package is installed if the netlab_net_tools variable is set to True (default setting) and if the arp command cannot be found.
lldpd package is installed if the netlab_lldp_enable variable is set to True (default setting) and if the lldpd.service is not running.
The package installation is performed only when the netlab_linux_distro variable is set to ubuntu (see Initial Configuration on Linux Virtual Machines)
netlab initial configuration script will skip Ubuntu package installation if it can find arp command or if the lldpd.service is already running, allowing you to build Vagrant boxes that require no Internet access during the initial configuration.
You can also disable package installation by setting netlab_net_tools and netlab_lldp_enable node parameters or corresponding defaults.devices.linux.group_vars.variable variables to False.
Initial Configuration on Linux Containers¶
The initial configuration process (netlab initial) does not rely on commands executed within Linux containers:
Interface IP addresses and static routes to default gateway (see Host Routing) are configured with ip commands executed on the Linux host but within the container network namespace.
Static default route points to the management interface.
You can therefore use any container image as a Linux node.