# SPF redirect= Modifier vs include: Mechanism: Precedence, Fallback, and Silent Ignore Traps

> Learn the exact RFC 7208 §5.2 vs §6.1 execution difference between include: and redirect=, including why combining redirect= with ~all/-all silently disables redirect=.

- **Canonical URL**: https://opslint.dev/spf/redirect-modifier-vs-include-mechanism-precedence/
- **Category**: `SPF`
- **Interactive Workbench**: [Open in Live Workbench](https://opslint.dev/spf/#domain=google.com)
- **Normative Specifications**: `RFC 7208 §5.2 ('include' Mechanism Match/No-Match Table)`, `RFC 7208 §6.1 ('redirect' Modifier: Ignored When 'all' Exists!)`

## Incident Symptom & Root Cause

**Production Symptom**: An engineer writes 'v=spf1 ip4:198.51.100.10 redirect=_spf.example.com -all' expecting corporate mail to fall through to _spf.example.com—and 100% of cloud mail bounces with SPF Fail because redirect= is completely ignored whenever 'all' is present! Conversely, replacing -all with include: without a terminal 'all' leaves unmatched IPs returning Neutral (?all)!

**Protocol / Engine Root Cause**: include: is a positional mechanism evaluated left-to-right that ONLY triggers when the child record returns Pass (ignoring child ~all/-all Fail results and continuing to the next token in the parent!). redirect= is a whole-policy modifier evaluated ONLY at the very end if zero mechanisms matched—AND RFC 7208 §6.1 explicitly mandates that ANY 'all' mechanism anywhere in the record causes redirect= to be ignored!

## Remediation Diff (Broken vs Verified Fix)

### Two Opposite include: vs redirect= Precedence Bugs

```text
; BUG 1: Presence of '-all' causes RFC 7208 §6.1 parsers to IGNORE redirect= completely!
; Only 198.51.100.10 passes; _spf.google.com is NEVER queried!
subsidiary-a.com. 3600 IN TXT "v=spf1 ip4:198.51.100.10 redirect=_spf.google.com -all"

; BUG 2: Using 'include:' with NO terminal '-all'/'~all' in parent!
; Child '-all' inside _spf.corp.com does NOT propagate Fail out of include: -> defaults to ?all Neutral!
subsidiary-b.com. 3600 IN TXT "v=spf1 include:_spf.corp.com"
```

### Correct Composition (include: + -all) vs Pure Alias Delegation (redirect= Alone)

```text
; Pattern 1 — Combining local IPs + external policy: use 'include:' PLUS terminal '-all'!
subsidiary-a.com. 3600 IN TXT "v=spf1 ip4:198.51.100.10 include:_spf.google.com -all"

; Pattern 2 — 100% identical shared policy across 20 brand domains: use 'redirect=' WITH NO 'all'!
; Final -all/~all qualifier inside _spf.corp.com becomes subsidiary-b.com's exact result!
subsidiary-b.com. 3600 IN TXT "v=spf1 redirect=_spf.corp.com"
```

## Engineering Deep Dive

Understanding how RFC 7208 §5.2 isolates child qualifiers inside include: unlocks every advanced SPF pattern. When example.com evaluates include:_spf.vendor.com, the verifier runs a sub-evaluation of _spf.vendor.com: if that sub-evaluation returns Pass, include: matches! Crucially, if that sub-evaluation hits '-all' (Fail) or '~all' (SoftFail) or '?all' (Neutral), include: does NOT abort the parent evaluation—it simply treats include: as 'not matched' and moves on to the next mechanism in example.com! That is why an aggressive '-all' inside one vendor's SPF record never blocks later includes in your parent record, AND why omitting your own terminal '-all' or '~all' leaves unmatched IPs falling off the end to implicit Neutral (?all)!

By contrast, redirect=_spf.corp.com (RFC 7208 §6.1) means 'replace the remainder of my SPF evaluation—including the final ~all or -all disposition!—with _spf.corp.com's policy.' That makes redirect= ideal for organizations managing 30 regional brand domains (example.de, example.fr, example.co.jp) that share the exact same central email infrastructure: updating _spf.corp.com from ~all to -all updates all 30 domains instantaneously in one DNS edit.

Keep two hard RFC 7208 §6.1 constraints in mind whenever using redirect=: (1) NEVER include any all mechanism (?all, ~all, -all, +all) in the same record as redirect=, or redirect= is silently skipped; (2) redirect= DOES count as +1 toward the 10-mechanism DNS lookup limit, and if the target domain of redirect= has no valid v=spf1 TXT record, the evaluation returns PermError (just like a broken include: target).

## include: Mechanism vs redirect= Modifier Behavioral Matrix

| Case / Engine | Protocol Behavior | Production Remediation |
| :--- | :--- | :--- |
| **Child record ends with -all (Fail)** (`#diff-child-fail-propagation`) | include: treats child Fail as 'no match' and continues parent; redirect= returns Fail immediately! | Always end records using include: with your own explicit ~all or -all. |
| **Record contains both redirect= and -all** (`#diff-coexistence-with-all`) | -all wins unconditionally; redirect= is NEVER executed per RFC 7208 §6.1! | Remove -all when delegating via redirect=, or replace redirect= with include: before -all. |
| **Multiple occurrences in one SPF record** (`#diff-multiple-count`) | Multiple include: mechanisms allowed; >1 redirect= modifier in one record is an immediate PermError! | Use include: whenever aggregating 2+ providers; use redirect= at most once. |
| **%{d} macro domain context in target** (`#diff-macro-domain-context`) | Both include: and redirect= update %{d} to the target domain (that is why redirect= exists instead of CNAME!). | Never CNAME an apex domain; use 'v=spf1 redirect=_spf.corp.com' for multi-brand SPF sharing. |

## Frequently Asked Engineering Questions

### Wait: what happens if an include: child record returns PermError (for example >10 lookups or syntax error)?

Per RFC 7208 §5.2 Table 1, while child Fail/SoftFail/Neutral simply evaluate as 'no match', a child TempError propagates TempError AND a child PermError or None (missing SPF record!) immediately aborts the ENTIRE parent SPF check with PermError!

### Can I prepend local ip4: addresses before redirect= (like 'v=spf1 ip4:198.51.100.5 redirect=_spf.corp.com')?

Yes! That is completely valid RFC 7208 §6.1 as long as there is NO 'all' mechanism in the record: 198.51.100.5 matches ip4: and returns Pass immediately, while any other IP reaches the end with no 'all' and executes redirect=_spf.corp.com.

### Does negated '-include:bad-actor.com' work in SPF?

Syntactically yes! Putting a '-' qualifier in front of include: inverts a child Pass into an immediate parent Fail (-). In practice it is rarely needed unless carving an exception out of a broader CIDR later in the record.

## Related Problem-Cluster Guides

- [Fix Multiple SPF TXT Records PermError: How to Merge Two v=spf1 Records Safely](https://opslint.dev/spf/multiple-spf-txt-records-merge-guide/) — Why publishing two separate v=spf1 TXT records on the same hostname triggers immediate RFC 7208 §4.5 PermError, and the exact algorithm to merge them into one.
- [Fix SPF PermError: Too Many DNS Lookups (Exceeding the RFC 7208 10-Lookup Limit)](https://opslint.dev/spf/permerror-too-many-dns-lookups-10-limit/) — Understand which SPF mechanisms count toward RFC 7208 §4.6.4's hard 10-lookup ceiling, why nested vendor includes blow the budget, and how to cut lookups safely.
- [SPF ~all (SoftFail) vs -all (HardFail) Under DMARC Enforcement: RFC Truth & Forwarding](https://opslint.dev/spf/softfail-tilde-all-vs-hardfail-minus-all-dmarc/) — Compare SPF ~all SoftFail, -all Fail, and ?all Neutral under RFC 7208 and RFC 7489 DMARC, including why forwarded DKIM-signed mail interacts differently with -all.
- [Fix SPF Void Lookups Limit Exceeded (>2 NXDOMAIN or Empty DNS Answers)](https://opslint.dev/spf/void-lookups-limit-2-nxdomain-permerror/) — Why dead SaaS includes and non-existent A/MX mechanisms trigger RFC 7208 §4.6.4 PermError after just 2 void lookups, even when total lookups are under 10.
