I’m new here, and this is my first post , so
hi everybody , nice to meet you and thanks to accept me }
I have to implement a CarrierGradeNat 1:8 where a single public /24 subnet maps eight private /24 subnets, with source-port translation … the configuration should be like this
PRIVATE -> PUBLIC PORTS
100.65.0.0/24 -> XYZ.0.65.0/24 1500:9499
100.65.1.0/24 -> XYZ.0.65.0/24 9500:17499
100.65.2.0/24 -> XYZ.0.65.0/24 17500:25499
100.65.3.0/24 -> XYZ.0.65.0/24 25500:33499
100.65.4.0/24 -> XYZ.0.65.0/24 33500:41499
100.65.5.0/24 -> XYZ.0.65.0/24 41500:49499
100.65.6.0/24 -> XYZ.0.65.0/24 49500:57499
100.65.7.0/24 -> XYZ.0.65.0/24 57500:65499
100.66.0.0/24 -> XYZ.0.66.0/24 1500:9499
100.66.1.0/24 -> XYZ.0.66.0/24 9500:17499
100.66.2.0/24 -> XYZ.0.66.0/24 17500:25499
100.66.3.0/24 -> XYZ.0.66.0/24 25500:33499
100.66.4.0/24 -> XYZ.0.66.0/24 33500:41499
100.66.5.0/24 -> XYZ.0.66.0/24 41500:49499
100.66.6.0/24 -> XYZ.0.66.0/24 49500:57499
100.66.7.0/24 -> XYZ.0.66.0/24 57500:65499
100.67.0.0/24 -> XYZ.0.67.0/24 1500:9499
100.67.1.0/24 -> XYZ.0.67.0/24 9500:17499
100.67.2.0/24 -> XYZ.0.67.0/24 17500:25499
100.67.3.0/24 -> XYZ.0.67.0/24 25500:33499
100.67.4.0/24 -> XYZ.0.67.0/24 33500:41499
100.67.5.0/24 -> XYZ.0.67.0/24 41500:49499
100.67.6.0/24 -> XYZ.0.67.0/24 49500:57499
100.67.7.0/24 -> XYZ.0.67.0/24 57500:65499
These rules are already implemented in a MIKROTIK CCR and they work correctly
the ip 100.65.0.1 is mapped to XYZ.0.65.1 (and ports translated into range 1500:9499)
the ip 100.65.0.2 is mapped to XYZ.0.65.2 (and ports translated into range 1500:9499)
the ip 100.65.0.3 is mapped to XYZ.0.65.3 (and ports translated into range 1500:9499)
and so on
the ip 100.65.1.1 is mapped to XYZ.0.65.1 (and ports translated into range 9500:17499)
the ip 100.65.1.2 is mapped to XYZ.0.65.2 (and ports translated into range 9500:17499)
the ip 100.65.1.3 is mapped to XYZ.0.65.3 (and ports translated into range 9500:17499)
and so on
…
Now I need to do the same thing on a Vyos 1.3 z
After reading the public guide I wrote these simple rules
set nat source rule 6500 outbound-interface ‘eth1’
set nat source rule 6500 protocol ‘tcp_udp’
set nat source rule 6500 source address ‘100.65.0.0-100.65.0.255’
set nat source rule 6500 translation address ‘10.0.65.0-10.0.65.255’
set nat source rule 6500 translation options address-mapping ‘persistent’
set nat source rule 6500 translation port ‘1500-5499’
set nat source rule 6501 outbound-interface ‘eth1’
set nat source rule 6501 protocol ‘tcp_udp’
set nat source rule 6501 source address ‘100.65.1.0-100.65.1.255’
set nat source rule 6501 translation address ‘XYZ.0.65.0-10.0.65.255’
set nat source rule 6501 translation options address-mapping ‘persistent’
set nat source rule 6501 translation port ‘9500-17499’
… etc …
set nat source rule 6507 outbound-interface ‘eth1’
set nat source rule 6507 protocol ‘tcp_udp’
set nat source rule 6507 source address ‘100.65.7.0-100.65.7.255’
set nat source rule 6507 translation address ‘XYZ.0.65.0-10.0.65.255’
set nat source rule 6507 translation options address-mapping ‘persistent’
set nat source rule 6507 translation port ‘57500-65499’
And it almost works, the port contrains are ok, but the IP-translation is mapped randomly, and I need to translate .1->.1 .2->.2
So I tried with prefix mapping (netmap 1:1) changing to
set source address ‘100.65.X.0/24’
set translation address ‘XYZ.0.65.0/24’
but it does not commit, with this error
“Cannot use ports with an IPv4net type translation address as it statically maps a whole network of addresses onto another network of addresses”
so I tried to set two consecutive rules, one for port-translation and one for address-mapping … but only the first matching rule is applied.
Any idea to implement it?
Thanks