# Config Drift: How to Detect It in Terraform and Networks

> What config drift is, how to detect it with terraform plan, Ansible check mode and network config backups, how to audit firewall rules and record each change.

Canonical: https://origindatapartners.com/guides/config-drift
By: Origin Data Partners
Status: Published
Published: 2026-11-17
Updated: 2026-11-17
Sources checked: 2026-11-17

## Quick answer

Config drift is the gap between how a system is supposed to be configured and how it really is, usually caused by changes made by hand outside the normal process. You find it by comparing the two: terraform plan -refresh-only for cloud resources, Ansible check mode for servers, and nightly config backups with diffs for routers and firewalls. You prevent it with change records and regular rule reviews.

## Key points

- Drift starts with a change made outside the code or the change process, often during an incident.
- terraform plan -refresh-only shows what changed in the real infrastructure without touching it.
- Network teams catch drift with tools such as Oxidized or RANCID, which save device configs to version control and diff them.
- NIST says firewall rule sets belong under formal change control, with periodic reviews and a log of every change.

## What is config drift?

Config drift, or configuration drift, is the difference between a system's intended configuration and its actual configuration. The intended version lives somewhere written down: Terraform files, Ansible playbooks, a golden router config. The actual version is what is running. When the two disagree, the system has drifted.

HashiCorp's tutorial names the usual cause: "You should not make manual changes to resources controlled by Terraform, because the state file will be out of sync" with the real infrastructure ([HashiCorp tutorial](https://developer.hashicorp.com/terraform/tutorials/state/resource-drift)). The same happens on networks when an engineer logs in to a firewall during an outage and adds a rule that never reaches the backup or the change system.

The written-down version is often called a baseline. NIST defines a baseline configuration as "a documented set of specifications for a system, or a configuration item within a system, that has been formally reviewed and agreed on at a given point in time, and which can be changed only through change control procedures" ([NIST glossary](https://csrc.nist.gov/glossary/term/baseline_configuration)). Drift is any departure from it that did not go through those procedures.


## How do you detect configuration drift?

Every method compares the baseline with the live system on a schedule. What differs is how each tool reads the live side.

| Where | How to check | What the tool documentation says |
| --- | --- | --- |
| Terraform-managed cloud | terraform plan -refresh-only | "Run terraform plan -refresh-only to determine the drift between your current state file and actual configuration." |
| Terraform in a pipeline | terraform plan with -detailed-exitcode | Exit code "2 = Succeeded with non-empty diff (changes present)" |
| Servers under Ansible | ansible-playbook --check playbook.yaml | Check mode "allows you to execute a playbook without applying any alterations to your systems." |
| Routers, switches, firewalls | Scheduled config backups to git, then a diff | Oxidized "is a network device configuration backup tool." |
| GitOps clusters | The reconciling agent | Agents "continuously observe actual system state and attempt to apply the desired state." |

Sources: [HashiCorp tutorial](https://developer.hashicorp.com/terraform/tutorials/state/resource-drift), [terraform plan](https://developer.hashicorp.com/terraform/cli/commands/plan), [Ansible documentation](https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_intro.html), [Oxidized](https://github.com/ytti/oxidized), [OpenGitOps](https://opengitops.dev/). A refresh-only run "does not attempt to modify your infrastructure to match your Terraform configuration", so it is safe to schedule. HashiCorp also warns that routine use of -target "can lead to undetected configuration drift".


## What is network config management?

Network config management means keeping a saved, versioned copy of every router, switch and firewall configuration, and knowing who changed what. Two open-source tools do the core job. RANCID "monitors a router's (or more generally a device's) configuration, including software and hardware (cards, serial numbers, etc)" and uses version control, including "Subversion or Git to maintain history of changes" ([RANCID](https://shrubbery.net/rancid/)). It can email the differences after each run.

Oxidized describes itself as "a network device configuration backup tool" and "a RANCID replacement" that "supports over 130 operating system types" ([Oxidized](https://github.com/ytti/oxidized)). When syslog tells it a device changed, it can fetch the new config at once, and with its git output "'git blame' will show who changed each line". The result is the same kind of history an IaC repo has, for devices that were never managed as code.


## How do you run a firewall rule audit?

NIST's firewall guide is direct: "Firewall rulesets and policies should be managed by a formal change management control process because of their potential to impact security and business operations, with ruleset reviews or tests performed periodically" ([NIST SP 800-41 Rev. 1](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-41r1.pdf)). It adds that "at a minimum, a log should be kept of all policy decisions and ruleset changes", and that verification "should include both reviewing it manually and testing whether the rules work as expected".

A practical audit walks through the rule set with the change log beside it.

- Match every rule to a ticket or a documented reason. Rules with no owner are the first to question.
- Look for rules that allow any source, any port or any protocol, and for temporary rules that were never removed.
- Find rules that never match traffic, using the firewall's hit counters, and rules hidden behind broader rules above them.
- Compare the running config with the last approved backup to catch drift.
- Bring in an outside view now and then. NIST suggests "overall ruleset audits by people who are not part of the normal policy review team" ([NIST SP 800-41 Rev. 1](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-41r1.pdf)).


## What does a change advisory board do?

A change advisory board (CAB) reviews proposed changes before they happen. Atlassian describes it as "a group of people from different facets of a business who provide oversight and guidance to change management teams" ([Atlassian](https://www.atlassian.com/itsm/change-management/change-advisory-board)). Most teams send only risky or unusual changes to the CAB and pre-approve routine ones, so it does not become a bottleneck.

Whether or not a CAB meets, each change should leave a record. The fields below are what make drift explainable months later.

| Field | Why it matters |
| --- | --- |
| Change ID and linked incident or request | Explains why the change was made |
| Systems and rules affected | Lets you find every change to one firewall or route |
| Planned and actual time, in UTC | Puts the change in order with alerts and logs |
| The diff or pull request | Shows exactly what changed |
| Approver and implementer | Shows who decided and who acted |
| Result and rollback, if any | Shows whether the change worked |


## Config drift example: an emergency firewall rule

At 01:40 UTC an on-call engineer opens port 8443 on an edge firewall so a payment partner can reach a failover server. The change fixes the outage, but it is made by hand and no ticket is updated. At 02:00 the nightly config backup saves the new rule, and the diff below lands in the network team's channel. The next morning the rule is either written into the approved rule set with a ticket or removed.

| Time (UTC) | Event | Record it leaves |
| --- | --- | --- |
| 01:12 | Alert: payment callbacks failing | Monitoring alert and on-call page |
| 01:40 | Engineer adds the 8443 rule by hand | Firewall syslog entry, chat message |
| 01:46 | Callbacks recover | Monitoring recovery event |
| 02:00 | Backup diff flags the new rule | Git commit in the config repository |
| 09:30 | Change ticket raised and approved after the fact | Change record linked to the incident |

Nightly backup diff showing one new rule on edge-fw-01:

```diff
--- edge-fw-01  backup 2026-03-02 02:00 UTC
+++ edge-fw-01  backup 2026-03-03 02:00 UTC
@@ access-list OUTSIDE_IN @@
 access-list OUTSIDE_IN extended permit tcp any host 198.51.100.10 eq 443
+access-list OUTSIDE_IN extended permit tcp any host 198.51.100.20 eq 8443
 access-list OUTSIDE_IN extended deny ip any any log
```

Illustrative example written for this page; no real company, device or partner. 198.51.100.0/24 is a documentation address range.


## Common mistakes with config drift

Drift is rarely one big error. It builds up from small habits.

- Fixing an incident by hand and closing the ticket without writing the change back into code or the approved rule set.
- Running Terraform with -target as a routine shortcut, which hides drift in the resources left out.
- Backing up device configs without version history, so you know the current state but not when it changed.
- Reviewing firewall rules without the change log, so nobody can say why a rule exists.
- Reverting drift automatically without asking why it happened, and undoing a fix that kept a service up.
- Keeping change records and incident records in systems that share no IDs, so the two can never be joined.


## Are firewall rule sets and change records also a data asset?

They can be, for the company's own network. AI data buyers have asked Origin for configuration history, including firewall rule sets and routing, kept under version control with the commits and reviews and going back years, with each change tied to the ticket, chat thread and incident that caused it and the outcome. They also asked for the runbooks, on-call records and postmortems from the same period. The first step is a sample of two or three incidents end to end plus a slice of the config history. See [incident timelines](https://origindatapartners.com/guides/incident-timeline-template), [infrastructure as code history](https://origindatapartners.com/guides/infrastructure-as-code-examples) and [ISP network operations records](https://origindatapartners.com/guides/isp-network-operations-data-ai).

Origin is an independent data partner. Your company decides what is shared and signs any license itself, and a buyer may pay Origin when a deal closes.

- Secrets in configs: device passwords, SNMP communities, VPN pre-shared keys and API tokens come out first, and should be rotated.
- Addresses and names: public IP addresses, customer prefixes, hostnames and site names can identify the company and its customers. See [anonymizing logs and captures](https://origindatapartners.com/guides/anonymize-pcap-files-logs).
- Client networks: configs of networks run for clients belong to those clients unless they have agreed.
- Personal data: engineer names in commits, tickets and chat need masking or consistent pseudonyms.
- Ticket exports: if change records live in a tracker, see [how to export Jira and Confluence data](https://origindatapartners.com/guides/export-jira-confluence-data).

Does your company hold records like these? [See what your data is worth](https://origindatapartners.com/check-fit).


## Questions and answers

### What causes configuration drift?

Configuration drift is usually caused by changes made outside the normal process: a fix typed into a console during an outage, a setting changed by a vendor tool, an update applied to some servers but not others, or a resource left out of a Terraform run. Each one makes the live system differ from the version written down in code or in the approved baseline.

### How does terraform plan detect drift?

Running terraform plan -refresh-only reads the real infrastructure and compares it with the Terraform state, then lists the objects that changed outside Terraform. It does not change any infrastructure. In a pipeline, the -detailed-exitcode option returns exit code 2 when changes are present, which a scheduled job can use to raise an alert.

### What tools back up network device configurations?

Two widely used open-source tools are RANCID and Oxidized. Both log in to routers, switches and firewalls on a schedule, save the configuration, and keep its history in version control such as Git. Oxidized supports over 130 operating system types and can fetch a config as soon as syslog reports a change, recording who made it.

### How often should firewall rules be reviewed?

NIST SP 800-41 does not set a fixed interval. It says rule sets should be under formal change control, with reviews or tests performed periodically, and a log kept of every rule change. Many teams review on a set cycle and after major incidents or network changes. Your security policy and any standard you follow should set the period.

### Does every change need to go to a change advisory board?

No. Most teams send only high-risk or unusual changes to a change advisory board and pre-approve routine, low-risk changes so they can move quickly. Emergency changes made during an incident are usually reviewed after the fact. Every change should still leave a record with its reason, the diff, the approver and the result.

### What is the difference between config drift and a baseline configuration?

A baseline configuration is the reviewed and approved version of a system's settings, which can change only through change control. Config drift is any difference between that baseline and what is actually running. Detecting drift means comparing the live system with the baseline and either approving the difference as a new baseline or reverting it.

### Can firewall rule sets and routing configs be shared outside the company?

They can be shared for the company's own network once secrets, public addresses, customer prefixes and personal data are removed or replaced, and once any client networks are left out unless those clients agree. Rule sets are most useful with their change history and the incidents behind each change. Check confidentiality terms in vendor and customer contracts first.

## Sources

- [HashiCorp tutorial: Manage resource drift](https://developer.hashicorp.com/terraform/tutorials/state/resource-drift)
- [Terraform documentation: terraform plan command](https://developer.hashicorp.com/terraform/cli/commands/plan)
- [Ansible Community Documentation: Ansible playbooks](https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_intro.html)
- [Oxidized on GitHub: network device configuration backup tool](https://github.com/ytti/oxidized)
- [RANCID: Really Awesome New Cisco confIg Differ](https://shrubbery.net/rancid/)
- [NIST SP 800-41 Rev. 1: Guidelines on Firewalls and Firewall Policy](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-41r1.pdf)
- [NIST Computer Security Resource Center glossary: baseline configuration](https://csrc.nist.gov/glossary/term/baseline_configuration)
- [Atlassian: Change advisory board (CAB)](https://www.atlassian.com/itsm/change-management/change-advisory-board)

## Related reading

- [Audit Log Examples: Fields, SIEM Logs and CloudTrail](https://origindatapartners.com/guides/audit-log-examples)
- [Export Jira Data and Confluence Spaces: Complete Guide](https://origindatapartners.com/guides/export-jira-confluence-data)
- [Can a security company license alerts and incident data to AI?](https://origindatapartners.com/guides/license-security-incident-data-ai)
- [Infrastructure as Code Examples: Terraform, Ansible, State](https://origindatapartners.com/guides/infrastructure-as-code-examples)
- [WAF Rules: Managed vs Custom Rules and False Positives](https://origindatapartners.com/guides/waf-rules)
- [Incident Timeline Template: Alert to Fix, On-Call Handoff](https://origindatapartners.com/guides/incident-timeline-template)
