1、SRX防火墙Static NAT解决内网无法通过公网访问内网服务问题

本文涉及的产品
云防火墙,500元 1000GB
简介:

1、实验拓扑图

wKioL1hqy4qybEYXAACwWtygUxk505.png-wh_50


2、实验配置

2.1、内网服务器访问Internet
set system host-name SRX1
set system time-zone Asia/Shanghai
set system name-server 114.114.114.114
set system services ssh
set system services web-management http
set system ntp server 62.201.225.9
set interfaces ge-0/0/0 unit 0 family inet address 192.168.130.22/24
set interfaces ge-0/0/1 unit 0 family inet address 1.1.1.254/24
set routing-options static route 0.0.0.0/0 next-hop 192.168.130.2

set security nat source rule-set Source-NAT from zone trust
set security nat source rule-set Source-NAT to zone untrust
set security nat source rule-set Source-NAT rule Source-NAT-Rule match source-address 1.1.1.0/24
set security nat source rule-set Source-NAT rule Source-NAT-Rule then source-nat interface

set security policies from-zone trust to-zone untrust policy Source-NAT-Plicy match source-address any
set security policies from-zone trust to-zone untrust policy Source-NAT-Plicy match destination-address any
set security policies from-zone trust to-zone untrust policy Source-NAT-Plicy match application any
set security policies from-zone trust to-zone untrust policy Source-NAT-Plicy then permit

set security zones security-zone untrust host-inbound-traffic system-services ping
set security zones security-zone untrust host-inbound-traffic system-services ssh
set security zones security-zone untrust host-inbound-traffic system-services http
set security zones security-zone untrust interfaces ge-0/0/0.0
set security zones security-zone trust host-inbound-traffic system-services ping
set security zones security-zone trust host-inbound-traffic system-services ssh
set security zones security-zone trust host-inbound-traffic system-services http
set security zones security-zone trust interfaces ge-0/0/1.0

2.2、对外提供3389服务
set security nat static rule-set static-nat from zone untrust
set security nat static rule-set static-nat rule  Outside10-TO-Inside10-rule match destination-address 192.168.130.10/32
set security nat static rule-set static-nat rule  Outside10-TO-Inside10-rule then static-nat prefix 1.1.1.10/32
set security nat proxy-arp interface ge-0/0/0.0 address 192.168.130.10/32   

set security zones security-zone trust address-book address  Outside10-TO-Inside10-address 1.1.1.10/32
set security zones security-zone trust address-book address-set  Outside10-TO-Inside10-address-set address  Outside10-TO-Inside10-address

set applications application  Outside10-TO-Inside10-application term 3389 protocol tcp
set applications application  Outside10-TO-Inside10-application term 3389 destination-port 3389

set security policies from-zone untrust to-zone trust policy  Outside10-TO-Inside10-policy match source-address any
set security policies from-zone untrust to-zone trust policy  Outside10-TO-Inside10-policy match destination-address  Outside10-TO-Inside10-address-set
set security policies from-zone untrust to-zone trust policy  Outside10-TO-Inside10-policy match application  Outside10-TO-Inside10-application
set security policies from-zone untrust to-zone trust policy  Outside10-TO-Inside10-policy then permit

2.3、内网服务器通过192.168.130.10访问1.1.1.10的3389服务
set security nat source rule-set Source-NAT to zone trust
set security nat static rule-set static-nat from zone trust
set security policies from-zone trust to-zone trust policy Source-NAT-Plicy match source-address any
set security policies from-zone trust to-zone trust policy Source-NAT-Plicy match destination-address any
set security policies from-zone trust to-zone trust policy Source-NAT-Plicy match application any
set security policies from-zone trust to-zone trust policy Source-NAT-Plicy then permit


2.4、1.1.1.20对外提供3389服务,内网服务器通过192.168.130.20访问1.1.1.20的3389服务
set security nat static rule-set static-nat from zone trust
set security nat static rule-set static-nat from zone untrust
set security nat static rule-set static-nat rule  Outside20-TO-Inside20-rule match destination-address 192.168.130.20/32
set security nat static rule-set static-nat rule  Outside20-TO-Inside20-rule then static-nat prefix 1.1.1.20/32
set security nat proxy-arp interface ge-0/0/0.0 address 192.168.130.20/32   

set security zones security-zone trust address-book address  Outside20-TO-Inside20-address 1.1.1.20/32
set security zones security-zone trust address-book address-set  Outside20-TO-Inside20-address-set address  Outside20-TO-Inside20-address

set applications application  Outside20-TO-Inside20-application term 3389 protocol tcp
set applications application  Outside20-TO-Inside20-application term 3389 destination-port 3389

set security policies from-zone untrust to-zone trust policy  Outside20-TO-Inside20-policy match source-address any
set security policies from-zone untrust to-zone trust policy  Outside20-TO-Inside20-policy match destination-address  Outside20-TO-Inside20-address-set
set security policies from-zone untrust to-zone trust policy  Outside20-TO-Inside20-policy match application  Outside20-TO-Inside20-application
set security policies from-zone untrust to-zone trust policy  Outside20-TO-Inside20-policy then permit

3、总结

Static NAT映射后,内网服务器无法通过外网IP访问内网服务器:需要在untrust和trust两个方向同时做Source NAT和Static NAT。


最终配置如下:

root@SRX1# show | display set 

set version 12.1X44.4

set system host-name SRX1

set system time-zone Asia/Shanghai

set system root-authentication encrypted-password "$1$rzXSdTNv$xhvtt2I62Mf/LJCFfq.Xz/"

set system name-server 114.114.114.114

set system services ssh

set system services web-management http

set system ntp server 62.201.225.9

set interfaces ge-0/0/0 unit 0 family inet address 192.168.130.22/24

set interfaces ge-0/0/1 unit 0 family inet address 1.1.1.254/24

set routing-options static route 0.0.0.0/0 next-hop 192.168.130.2

set security nat source rule-set Source-NAT from zone trust

set security nat source rule-set Source-NAT to zone trust

set security nat source rule-set Source-NAT to zone untrust

set security nat source rule-set Source-NAT rule Source-NAT-Rule match source-address 1.1.1.0/24

set security nat source rule-set Source-NAT rule Source-NAT-Rule then source-nat interface

set security nat static rule-set static-nat from zone trust

set security nat static rule-set static-nat from zone untrust

set security nat static rule-set static-nat rule Outside10-TO-Inside10-rule match destination-address 192.168.130.10/32

set security nat static rule-set static-nat rule Outside10-TO-Inside10-rule then static-nat prefix 1.1.1.10/32

set security nat static rule-set static-nat rule Outside20-TO-Inside20-rule match destination-address 192.168.130.20/32

set security nat static rule-set static-nat rule Outside20-TO-Inside20-rule then static-nat prefix 1.1.1.20/32

set security nat proxy-arp interface ge-0/0/0.0 address 192.168.130.10/32

set security nat proxy-arp interface ge-0/0/0.0 address 192.168.130.20/32

set security policies from-zone trust to-zone untrust policy Source-NAT-Plicy match source-address any

set security policies from-zone trust to-zone untrust policy Source-NAT-Plicy match destination-address any

set security policies from-zone trust to-zone untrust policy Source-NAT-Plicy match application any

set security policies from-zone trust to-zone untrust policy Source-NAT-Plicy then permit

set security policies from-zone untrust to-zone trust policy Outside10-TO-Inside10-policy match source-address any

set security policies from-zone untrust to-zone trust policy Outside10-TO-Inside10-policy match destination-address Outside10-TO-Inside10-address-set

set security policies from-zone untrust to-zone trust policy Outside10-TO-Inside10-policy match application Outside10-TO-Inside10-application

set security policies from-zone untrust to-zone trust policy Outside10-TO-Inside10-policy then permit

set security policies from-zone untrust to-zone trust policy Outside20-TO-Inside20-policy match source-address any

set security policies from-zone untrust to-zone trust policy Outside20-TO-Inside20-policy match destination-address Outside20-TO-Inside20-address-set

set security policies from-zone untrust to-zone trust policy Outside20-TO-Inside20-policy match application Outside20-TO-Inside20-application

set security policies from-zone untrust to-zone trust policy Outside20-TO-Inside20-policy then permit

set security policies from-zone trust to-zone trust policy Source-NAT-Plicy match source-address any

set security policies from-zone trust to-zone trust policy Source-NAT-Plicy match destination-address any

set security policies from-zone trust to-zone trust policy Source-NAT-Plicy match application any

set security policies from-zone trust to-zone trust policy Source-NAT-Plicy then permit

set security zones security-zone untrust host-inbound-traffic system-services ping

set security zones security-zone untrust host-inbound-traffic system-services ssh

set security zones security-zone untrust host-inbound-traffic system-services http

set security zones security-zone untrust interfaces ge-0/0/0.0

set security zones security-zone trust address-book address Outside10-TO-Inside10-address 1.1.1.10/32

set security zones security-zone trust address-book address Outside20-TO-Inside20-address 1.1.1.20/32

set security zones security-zone trust address-book address-set Outside10-TO-Inside10-address-set address Outside10-TO-Inside10-address

set security zones security-zone trust address-book address-set Outside20-TO-Inside20-address-set address Outside20-TO-Inside20-address

set security zones security-zone trust host-inbound-traffic system-services ping

set security zones security-zone trust host-inbound-traffic system-services ssh

set security zones security-zone trust host-inbound-traffic system-services http

set security zones security-zone trust interfaces ge-0/0/1.0

set applications application Outside10-TO-Inside10-application term 3389 protocol tcp

set applications application Outside10-TO-Inside10-application term 3389 destination-port 3389

set applications application Outside20-TO-Inside20-application term 3389 protocol tcp

set applications application Outside20-TO-Inside20-application term 3389 destination-port 3389






      本文转自开源殿堂 51CTO博客,原文链接:http://blog.51cto.com/kaiyuandiantang/1888442,如需转载请自行联系原作者




相关文章
|
8月前
|
网络协议
地址重叠时,用户如何通过NAT访问对端IP网络?
地址重叠时,用户如何通过NAT访问对端IP网络?
|
2月前
|
运维 安全 Linux
全面提升系统安全:禁用不必要服务、更新安全补丁、配置防火墙规则的实战指南
全面提升系统安全:禁用不必要服务、更新安全补丁、配置防火墙规则的实战指南
61 12
|
2月前
|
域名解析 弹性计算 网络安全
CEN+私网NAT实现跨地域访问云服务需求-CEN企业版
本文介绍了如何通过企业版云企业网和私网NAT配置,实现ECS内网跨地域访问OSS资源的方法。该方法避免了跨地域配置云服务网段时可能出现的管控异常问题,适用于其他云服务如MQ等。
|
7月前
|
安全 网络协议 Shell
【内网安全】 域防火墙&入站出站规则&不出网隧道上线&组策略对象同步
【内网安全】 域防火墙&入站出站规则&不出网隧道上线&组策略对象同步
106 0
|
3月前
|
网络安全 Docker 容器
【Bug修复】秒杀服务器异常,轻松恢复网站访问--从防火墙到Docker服务的全面解析
【Bug修复】秒杀服务器异常,轻松恢复网站访问--从防火墙到Docker服务的全面解析
76 0
|
4月前
|
网络协议 安全 小程序
编程突破TCP/IP过滤防火墙进入内网
编程突破TCP/IP过滤防火墙进入内网
|
5月前
|
存储 安全 API
【Azure API Management】实现在API Management服务中使用MI(管理标识 Managed Identity)访问启用防火墙的Storage Account
【Azure API Management】实现在API Management服务中使用MI(管理标识 Managed Identity)访问启用防火墙的Storage Account
|
5月前
|
SQL 网络协议 安全
【Azure API 管理】APIM集成内网虚拟网络后,启用自定义路由管理外出流量经过防火墙(Firewall),遇见APIs加载不出来问题
【Azure API 管理】APIM集成内网虚拟网络后,启用自定义路由管理外出流量经过防火墙(Firewall),遇见APIs加载不出来问题
|
7月前
|
安全 网络协议 Linux
【内网安全】 隧道技术&SMB&ICMP&正反向连接&防火墙出入规则上线
【内网安全】 隧道技术&SMB&ICMP&正反向连接&防火墙出入规则上线
|
8月前
|
网络协议 安全
ensp中nat server 公网访问内网服务器
ensp中nat server 公网访问内网服务器
157 1

热门文章

最新文章