Skip to content

fix: scope VPC SNAT rule to exclude locally-generated packets (#13942) - #13943

Open
waterWang wants to merge 1 commit into
apache:mainfrom
waterWang:fix/13942-vpc-snat-local
Open

waterWang wants to merge 1 commit into
apache:mainfrom
waterWang:fix/13942-vpc-snat-local

Conversation

@waterWang

Copy link
Copy Markdown

Problem

On a VPC with public IPs from more than one range/VLAN, the virtual router installs an unscoped source NAT rule on every public interface using the single VPC source NAT address. Because the rule has no source match (-s), it also rewrites traffic the router itself originates, so the VR cannot emit packets with the correct source address from any public interface other than the source-NAT one.

Fix

Add -m addrtype ! --src-type LOCAL to the elif SNAT rule generated in CsAddress.py. This excludes packets whose source is an address on the router, while forwarded (guest) traffic still matches and is SNATed as before.

Verification

The reporter verified the fix manually on the VR:

iptables -t nat -D POSTROUTING -o eth2 -j SNAT --to-source 10.1.30.5
iptables -t nat -A POSTROUTING -o eth2 -m addrtype ! --src-type LOCAL -j SNAT --to-source 10.1.30.5

Closes: #13942

…#13942)

On a VPC with public IPs from more than one range/VLAN, the virtual router
installs an unscoped source NAT rule on every public interface using the
single VPC source NAT address. Because the rule has no source match, it
also rewrites traffic the router itself originates, so the VR cannot emit
packets with the correct source address from any public interface other
than the source-NAT one.

Fix: add `-m addrtype ! --src-type LOCAL` to the elif SNAT rule so it only
matches forwarded (guest) traffic, not locally-generated packets.

Closes: apache#13942

@DaanHoogland DaanHoogland left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rebase on 4.22

@DaanHoogland DaanHoogland moved this from Backlog to conflict/waiting in CloudStack Testing Sep 1, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: conflict/waiting

Development

Successfully merging this pull request may close these issues.

VPC router applies the VPC source NAT IP to locally-generated traffic on secondary public interfaces, breaking gateway health checks

2 participants