VyOS example
VyOS is a fully open-source network OS that runs on a wide range of hardware, virtual machines, and cloud providers (https://vyos.io/). Because of its open-source nature, it is gaining wide support in the open-source community. Many open-source projects are using VyOS as the default platform for testing. In the last section of the chapter, we will look at a quick VyOS example.
The VyOS image can be downloaded in various formats: https://wiki.vyos.net/wiki/Installation. Once it’s downloaded and initialized, we can install the Python library on our management host:
(venv) $ pip install vymgmt
The example script, vyos_1.py
, is very simple:
#!/usr/bin/env python3
import vymgmt
vyos = vymgmt.Router('192.168.2.116', 'vyos', password='vyos')
vyos.login()
vyos.configure()
vyos.set("system domain-name networkautomationnerds.net")
vyos.commit()
vyos.save()
vyos.exit()
vyos.logout()
We can execute the script to...