Tutorials · DevOps & Containers
How to Keep Network Configurations in Git (Configuration as Code)
Store every switch, gateway and edge-server configuration in Git: you get history, diffs, reviews and a fast way back to the last working version.
Before you start
- Git and a private repository (self-hosted or cloud)
- Read access to device configurations over SSH or the API
Step by step
Create the repository layout
One folder per site, one file per device, plus compose files and docs.
network-config/ site1/ core-sw.cfg gateway.cfg edge/compose.yaml site2/ README.md
Collect configurations automatically
Pull running configurations nightly with a script or a tool such as Oxidized, and commit only when something changed.
cd network-config && git add -A git diff --cached --quiet || git commit -m "nightly backup $(date +%F)"
Review changes
Make planned changes on a branch, review the diff with a colleague, then merge and apply.
See what changed
When something breaks, the diff shows exactly what was changed and when.
git log --oneline -- site1/core-sw.cfg git diff HEAD~1 -- site1/core-sw.cfg
Protect secrets
Strip or encrypt passwords and keys before committing (for example with git-crypt or SOPS), and limit who can read the repository.
Commands are generic, industry-standard examples. Exact syntax and menu names vary by model and firmware; check your device's manual on the Documentation page.
Pro tips
- Tag the repository before every maintenance window.
- Keep a copy of the repository off-site with your other backups.
FAQ
Frequently asked questions
Does this replace device backups?
It complements them. Keep NavCloud or device backups for full restores, and Git for history and reviews.
Keep learning
Related guides
Back up and restore network configuration
Read more →Automate switch configuration with Ansible
Read more →How to Use SSH Keys Instead of Passwords for Network Devices and Servers
Passwords can be guessed, phished and reused. Create an SSH key pair, install the public key on gateways, edge servers and Linux hosts, then turn password logins off.
Read more →How to Reach Remote Sites Safely With an SSH Jump Host
Do not expose SSH on every device. Put one hardened jump host (bastion) in front of the management network and reach everything else through it.
Read more →How to Open a Device Web Page Through an SSH Tunnel
Reach the web interface of a switch, NVR or container on a remote site without opening a firewall port: forward it through SSH.
Read more →Stuck on a step?
Ask Navijin technical support or an authorised partner for help with your configuration.