Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

T6411: CGNAT fix sequences for external address ranges #3534

Merged
merged 1 commit into from
May 29, 2024

Conversation

sever-sever
Copy link
Member

Change Summary

Fix the bug where address external allocation was not rely on sequences of the external IP addresses (if set)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes)
  • Migration from an old Vyatta component to vyos-1x, please link to related PR inside obsoleted component
  • Other (please describe):

Related Task(s)

Related PR(s)

Component(s) name

cgnat

Proposed changes

How to test

Initial configuration:

set nat cgnat pool external ext-01 external-port-range '1024-65535'
set nat cgnat pool external ext-01 per-user-limit port '10000'
set nat cgnat pool external ext-01 range 192.168.122.121/32
set nat cgnat pool external ext-01 range 198.51.100.23/32 seq '3'
set nat cgnat pool external ext-01 range 203.0.113.102/32 seq '10'
set nat cgnat pool internal int-01 range '100.64.0.0/28'
set nat cgnat rule 10 source pool 'int-01'
set nat cgnat rule 10 translation pool 'ext-01'

Before the fix external address allocation not rely on the seq

vyos@r4# run show nat cgnat allocation 
Internal IP    External IP      Port range
-------------  ---------------  ------------
100.64.0.0     192.168.122.121  1024-11023
100.64.0.1     192.168.122.121  11024-21023
100.64.0.2     192.168.122.121  21024-31023
100.64.0.3     192.168.122.121  31024-41023
100.64.0.4     192.168.122.121  41024-51023
100.64.0.5     192.168.122.121  51024-61023
100.64.0.6     198.51.100.23    1024-11023
100.64.0.7     198.51.100.23    11024-21023
100.64.0.8     198.51.100.23    21024-31023
100.64.0.9     198.51.100.23    31024-41023
100.64.0.10    198.51.100.23    41024-51023
100.64.0.11    198.51.100.23    51024-61023
100.64.0.12    203.0.113.102    1024-11023
100.64.0.13    203.0.113.102    11024-21023
100.64.0.14    203.0.113.102    21024-31023
100.64.0.15    203.0.113.102    31024-41023
[edit]
vyos@r4#

After the fix, we see correctly external address allocations correctly based on sequences

vyos@r4# run show nat cgnat allocation 
Internal IP    External IP      Port range
-------------  ---------------  ------------
100.64.0.0     198.51.100.23    1024-11023
100.64.0.1     198.51.100.23    11024-21023
100.64.0.2     198.51.100.23    21024-31023
100.64.0.3     198.51.100.23    31024-41023
100.64.0.4     198.51.100.23    41024-51023
100.64.0.5     198.51.100.23    51024-61023
100.64.0.6     203.0.113.102    1024-11023
100.64.0.7     203.0.113.102    11024-21023
100.64.0.8     203.0.113.102    21024-31023
100.64.0.9     203.0.113.102    31024-41023
100.64.0.10    203.0.113.102    41024-51023
100.64.0.11    203.0.113.102    51024-61023
100.64.0.12    192.168.122.121  1024-11023
100.64.0.13    192.168.122.121  11024-21023
100.64.0.14    192.168.122.121  21024-31023
100.64.0.15    192.168.122.121  31024-41023
[edit]
vyos@r4# 

Smoketest result

vyos@r4:~$ /usr/libexec/vyos/tests/smoke/cli/test_cgnat.py
test_cgnat (__main__.TestCGNAT.test_cgnat) ... ok
test_cgnat_sequence (__main__.TestCGNAT.test_cgnat_sequence) ... ok

----------------------------------------------------------------------
Ran 2 tests in 26.153s

OK
vyos@r4:~$ 

Checklist:

  • I have read the CONTRIBUTING document
  • I have linked this PR to one or more Phabricator Task(s)
  • I have run the components SMOKETESTS if applicable
  • My commit headlines contain a valid Task id
  • My change requires a change to the documentation
  • I have updated the documentation accordingly

Fix the bug where address external alocation was not rely on sequences
of the external IP addresses (if set)
@dmbaturin dmbaturin merged commit db4c7f1 into vyos:current May 29, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

3 participants