Dynamische reine Adressübersetzung
Konfiguration der dynamischen Nur-Adress-Quellübersetzung in IPv4-Netzwerken
In IPv4-Netzwerken ist Dynamic Address Translation (Dynamic NAT) ein Mechanismus zur dynamischen Übersetzung des Zieldatenverkehrs ohne Portzuordnung. Um dynamisches NAT zu verwenden, müssen Sie einen Quellpoolnamen angeben, der eine Adresskonfiguration enthält.
So konfigurieren Sie dynamisches NAT in IPv4-Netzwerken:
Im folgenden Beispiel wird der Übersetzungstyp als dynamic-nat44 konfiguriert.
[edit services]
user@host# show
service-set s1 {
nat-rules rule-dynamic-nat44;
interface-service {
service-interface ms-0/1/0;
}
}
nat {
pool source-dynamic-pool {
address 10.1.1.0/24;
}
rule rule-dynamic-nat44 {
match-direction input;
term t1 {
from {
source-address {
3.1.1.0/24;
}
}
then {
translated {
destination-pool source-dynamic-pool;
translation-type {
dynamic-nat44;
}
}
}
}
}
}
adaptive-services-pics {
traceoptions {
flag all;
}
}
Die folgende Konfiguration gibt an, dass NAT nicht für eingehenden Datenverkehr von der Quelladresse 192.168.20.24/32 ausgeführt wird, indem ein NAT-Regelterm t0 bereitgestellt wird, der no-translationkonfiguriert wird. Dynamisches NAT wird für jeden anderen eingehenden Datenverkehr ausgeführt, wie durch die Bedingungen t1 der NAT-Regel konfiguriert. Die no-translation Option wird auf Routern der MX-Serie mit MS-DPCs und auf Routern der M Series mit MS-100-, MS-400- und MS-500-MultiServices-PICS unterstützt. Die no-translation Option wird auf Routern der MX-Serie mit MS-MPCs und MS-MICs ab Junos OS Version 15.1R1 unterstützt.
[edit services nat]
pool my-pool {
address-range low 10.10.10.1 high 10.10.10.16;
port automatic;
}
rule src-nat {
match-direction input;
term t0 {
from {
source-address 192.168.20.24/32;
}
then {
no-translation;
}
}
term t1 {
then {
translated {
translation-type dynamic-nat44;
source-pool my-pool;
}
}
}
}
Die folgende Konfiguration führt NAT mit dem Quellpräfix 20.20.10.0/24 durch, ohne einen Pool zu definieren.
[edit services nat]
rule src-nat {
match-direction input;
term t1 {
then {
translation-type dynamic-nat44;
source-prefix 20.20.10.0/24;
}
}
}
Die folgende Konfiguration führt NAT mit dem Zielpräfix 20.20.10.0/32 durch, ohne einen Pool zu definieren.
[edit services nat]
rule src-nat {
match-direction input;
term t1 {
from {
destination-address 10.10.10.10/32;
then {
translation-type dnat44;
destination-prefix 20.20.10.0/24;
}
}
}
}
Beispiel: Dynamic Source NAT als Next-Hop-Service
Das folgende Beispiel zeigt dynamisches Quell-NAT, das als Next-Hop-Dienst angewendet wird:
[edit interfaces]
ge-0/2/0 {
unit 0 {
family mpls;
}
}
sp-1/3/0 {
unit 0 {
family inet;
}
unit 20 {
family inet;
}
unit 32 {
family inet;
}
}
[edit routing-instances]
protected-domain {
interface ge-0/2/0.0;
interface sp-1/3/0.20;
instance-type vrf;
route-distinguisher 10.58.255.17:37;
vrf-import protected-domain-policy;
vrf-export protected-domain-policy;
routing-options {
static {
route 0.0.0.0/0 next-hop sp-1/3/0.20;
}
}
}
[edit policy-options]
policy-statement protected-domain-policy {
term t1 {
then reject;
}
}
[edit services]
stateful-firewall {
rule allow-all {
match-direction input;
term t1 {
then {
accept;
}
}
}
}
nat {
pool my-pool {
address 10.58.16.100;
port automatic;
}
rule hide-all {
match-direction input;
term t1 {
then {
translated {
source-pool my-pool;
translation-type napt-44;
}
}
}
}
}
service-set null-sfw-with-nat {
stateful-firewall-rules allow-all;
nat-rules hide-all;
next-hop-service {
inside-service-interface sp-1/3/0.20;
outside-service-interface sp-1/3/0.32;
}
}
Beispiel: Adressen aus einem dynamischen Pool für die statische Verwendung zuweisen
Die folgende Konfiguration weist eine Teilmenge von Adressen, die als Teil eines dynamischen Pools (dynamic-pool) konfiguriert sind, zwei separaten statischen Pools (static-pool und static-pool2) statisch zu.
[edit services nat]
pool dynamic-pool {
address 20.20.10.0/24;
}
pool static-pool {
address-range low 20.20.10.10 high 10.20.10.12;
}
pool static-pool2 {
address 20.20.10.15/32;
}
rule src-nat {
match-direction input;
term t1 {
from {
source-address 30.30.30.0/24;
}
then {
translation-type dynamic-nat44;
source-pool dynamic-pool;
}
}
term t2 {
from {
source-address 10.10.10.2;
}
then {
translation-type basic-nat44;
source-pool static-pool;
}
}
term t3 {
from {
source-address 10.10.10.10;
}
then {
translation-type basic-nat44;
source-pool static-pool2;
}
}
}