静态目标 NAT
在 IPv4 网络中配置静态目标地址转换
要使用目标地址转换,池地址空间的大小必须大于或等于目标地址空间。您必须为 destination-pool 语句指定一个名称,该名称可以包含多个地址、范围或前缀,只要池中的 NAT 地址数量大于语句中的 from 目标地址数量即可。
要在 IPv4 网络中配置目标地址转换:
以下示例将转换类型配置为 dnat-44。
[edit services]
user@host# show
service-set s1 {
nat-rules rule-dnat44;
interface-service {
service-interface ms-0/1/0;
}
}
nat {
pool dest-pool {
address 4.1.1.2/32;
}
rule rule-dnat44 {
match-direction input;
term t1 {
from {
destination-address {
20.20.20.20/32;
}
}
then {
translated {
destination-pool dest-pool;
translation-type {
dnat-44;
}
}
}
}
}
}
adaptive-services-pics {
traceoptions {
flag all;
}
}
在以下配置中, term1 为从任何专用地址到任何公共地址的流量配置源地址转换。该翻译适用于所有服务。 term2 对从任何公共地址到服务器的虚拟 IP 地址的超文本传输协议 (HTTP) 流量执行目标地址转换。虚拟服务器 IP 地址将转换为内部 IP 地址。
[edit services nat]
rule my-nat-rule {
match-direction input;
term my-term1 {
from {
source-address private;
destination-address public;
}
then {
translated {
source-pool my-pool; # pick address from a pool
translation-type napt-44; # dynamic NAT with port translation
}
}
}
}
rule my-nat-rule2 {
match-direction input;
term my-term2 {
from {
destination-address 192.168.137.3; # my server’s virtual address
application http;
}
then {
translated {
destination-pool nat-pool-name;
translation-type dnat-44; # static destination NAT
}
}
}
}
}
以下配置使用目标前缀 20.20.10.0/32 执行 NAT,而不定义池。
[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;
}
}
}
}