Automating Static IP Assignment and Enabling HTTPS API on eth0 for Custom VyOS ISO
Hello VyOS community,
Thank you for the incredible work on VyOS!
I’m working on creating a custom VyOS ISO using the vyos-build project. My goal is to automate the following during the installation process:
Static IP Assignment: Configure a static IP (e.g., 192.168.1.1/24) on eth0 for every router during installation, treating it as a management port.
Enable HTTPS API: Automatically enable the HTTPS API on eth0 with a predefined secret for authentication, ensuring the system is ready for remote configuration right after installation.
Could you guide me on how to:
Inject a default configuration file or script into the custom ISO that sets up eth0 with the static IP during the first boot or installation?
Preconfigure the HTTPS API with a specific secret and ensure it binds to the eth0 interface?
If there are specific sections of the vyos-build scripts that need modification or best practices for this use case, I’d appreciate any pointers.
That’s quite simple! You don’t need to modify any scripts, just make a custom flavor.
First, copy data/build-flavors/generic.toml to a different file, like data/build-flavors/custom.toml.
Second, write your custom config and add it to the flavor, so that it will look like:
# My custom VyOS build
image_format = "iso"
# The default config
[[includes_chroot]]
path = "opt/vyatta/etc/config.boot.default"
data = '''
interfaces {
loopback lo {
}
ethernet eth0 {
address dhcp
}
}
Then you can run the build using the new flavor: sudo ./build-vyos-image --build-by umlumpa custom.
Also, if you plan to deploy it in VMs or flash to drives of some boxes, you can build a disk image right away.
For example:
# The formats of the target files, for build/manifest.json
artifact_format = ["iso", "qcow2"]
image_format = "qcow2"
image_opts = "-c"
disk_size = 4
If you are building a non-ISO flavor, makes sure to start the build container with -v /dev:/dev so that it can create loop devices for mounting and building a disk image.