Skip to content

Conversation

@MrMarvin
Copy link

In #198 we discussed some use cases of a way to explicitly masquerade, vs the current non-masquerade approach. This PR is an attempt at implementing this feature.

forceMasqueradeCIDRs

  • Add new config param forceMasqueradeCIDRs that can be used exactly like the existing nonMasqueradeCIDRs list of CIDR ranges, but inverse.
  • Render iptables rules with explicit -j MASQUERADE early whenever a destination matches.

Example rule output

root@gke-foobar-e4ed6188-wdl7:~# iptables -t nat -n -L IP-MASQ
Chain IP-MASQ (2 references)
target     prot opt source               destination
RETURN     all  --  0.0.0.0/0            169.254.0.0/16       /* ip-masq-agent: local traffic is not subject to MASQUERADE */
MASQUERADE  all  --  0.0.0.0/0            10.8.0.0/16          /* ip-masq-agent: specific outbound traffic is subject to MASQUERADE (must be before nonMasqRules in chain) */ random-fully
RETURN     all  --  0.0.0.0/0            0.0.0.0/0            /* ip-masq-agent: local traffic is not subject to MASQUERADE */
MASQUERADE  all  --  0.0.0.0/0            0.0.0.0/0            /* ip-masq-agent: outbound traffic is subject to MASQUERADE (must be last in chain) */ random-fully

Happy for any input on this PR - please let me know what y'all think! ✌️

Fixes #198

@linux-foundation-easycla
Copy link

CLA Not Signed

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: MrMarvin
Once this PR has been reviewed and has the lgtm label, please assign bowei for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot requested review from MrHohn and thockin August 18, 2025 16:41
@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Aug 18, 2025
@k8s-ci-robot
Copy link
Contributor

Welcome @MrMarvin!

It looks like this is your first PR to kubernetes-sigs/ip-masq-agent 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/ip-masq-agent has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Aug 18, 2025
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle stale
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Nov 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Proposal: Add inverse operation of nonMasqueradeCIDRs to config

3 participants