This scenario illustrates Policy Based VPN between 2 sites and explains how to Source NAT a specific IP in Site A before reaching Site B. The same logic can be used to Source NAT a whole subnet.
This scenario illustrates how to use Destination NAT in a policy based VPN.
config vpn ipsec phase1
edit "VPN_To_Atl36"
set interface "port1"
set proposal des-md5 des-sha1
set remote-gw 10.0.18.45
next
end
config vpn ipsec phase2
edit "Phase2"
set phase1name "VPN_To_Atl36"
set proposal des-md5 des-sha1
set use-natip disable
end
config firewall policySite B Setup:
edit 2
set srcintf "port2"
set dstintf "port1"
set srcaddr "10.129.0.24"
set dstaddr "Remote_LAN_10.130"
set action ipsec
set schedule "always"
set service "ANY"
set natip 20.20.20.20 255.255.255.255
set inbound enable
set outbound enable
set natoutbound enable
set vpntunnel "VPN_To_Atl36"
next
edit 3
set srcintf "port2"
set dstintf "port1"
set srcaddr "LAN_10.129.0.0"
set dstaddr "Remote_LAN_10.130"
set action ipsec
set schedule "always"
set service "ANY"
set inbound enable
set outbound enable
set vpntunnel "VPN_To_Atl36"
next
end
config vpn ipsec phase1Address Objects
edit "VPN_To_Atl_16"
set interface "port1"
set remote-gw 10.0.18.25
end
config vpn ipsec phase2
edit "Phase2"
set phase1name "VPN_To_Atl_16"
next
end
config firewall policy
edit 3
set srcintf "port2"
set dstintf "port1"
set srcaddr "Local_10.130"
set dstaddr "20.20.20.20"
set action ipsec
set schedule "always"
set service "ALL"
set inbound enable
set outbound enable
set vpntunnel "VPN_To_Atl_16"
next
edit 4
set srcintf "port2"
set dstintf "port1"
set srcaddr "Local_10.130"
set dstaddr "Remote_10.129"
set action ipsec
set schedule "always"
set service "ALL"
set inbound enable
set outbound enable
set vpntunnel "VPN_To_Atl_16"
next
end
config vpn ipsec phase1
edit "VPN_to_Atl_36"
set interface "port1"
set remote-gw 10.0.18.45
next
end
config vpn ipsec phase2
edit "VPN_to_Atl_36"
set phase1name "VPN_to_Atl_36"
set use-natip disable
set pfs disable
set replay disable
next
end
config firewall vip
edit "VIP"
set extip 10.0.18.11
set extintf "port1"
set portforward enable
set mappedip "10.130.0.44"
set extport 8080
set mappedport 8080
next
end
config firewall policy
edit 2
set srcintf "port2"
set dstintf "port1"
set srcaddr "Internal_10.129"
set dstaddr "Remote_10.130"
set action ipsec
set schedule "always"
set service "ALL"
set inbound enable
set outbound enable
set vpntunnel "VPN_to_Atl_36"
next
edit 3
set srcintf "port1"
set dstintf "port1"
set srcaddr "all"
set dstaddr "VIP"
set action ipsec
set schedule "always"
set service "ALL"
set natip 10.0.18.11 255.255.255.255
set inbound enable
set outbound enable
set natoutbound enable
set vpntunnel "VPN_to_Atl_36"
next
end
SiteA # diagnose vpn tunnel list
list all ipsec tunnel in vd 0
------------------------------------------------------
name=VPN_to_Atl_36 ver=1 serial=1 10.0.18.25:0->10.0.18.45:0 lgwy=static tun=tunnel mode=auto bound_if=2
proxyid_num=1 child_num=0 refcnt=9 ilast=0 olast=0
stat: rxp=42 txp=90 rxb=4928 txb=4904
dpd: mode=active on=1 idle=5000ms retry=3 count=0 seqno=1487
natt: mode=none draft=0 interval=0 remote_port=0
proxyid=VPN_to_Atl_36 proto=0 sa=1 ref=2 serial=2
src: 0:0.0.0.0/0.0.0.0:0
dst: 0:0.0.0.0/0.0.0.0:0
SA: ref=3 options=0000004c type=00 soft=0 mtu=1438 expire=40758/0B replaywin=0 seqno=29
life: type=01 bytes=0/0 timeout=43151/43200
dec: spi=9af30383 esp=aes key=16 9699fa30efc110c9cc335b23806a731d
ah=sha1 key=20 6cf7508c489d4d8fe71a514dd2136945375771f0
enc: spi=103b3c89 esp=aes key=16 cbf7c9c4d2516b12a73b88918f4eb153
ah=sha1 key=20 ad171e92b5d5b75a831861ebe401f40991cf2185
dec:pkts/bytes=23/1200, enc:pkts/bytes=40/4928
id=20085 trace_id=65 func=print_pkt_detail line=4420 msg="vd-root received a packet(proto=6, 172.26.73.11:50798->10.0.18.11:8080) from port1. flag [S], seq 1398181761, ack 0, win 8192"
id=20085 trace_id=65 func=init_ip_session_common line=4569 msg="allocate a new session-0000151a"
id=20085 trace_id=65 func=fw_pre_route_handler line=176 msg="VIP-10.130.0.44:8080, outdev-port1"
id=20085 trace_id=65 func=__ip_session_run_tuple line=2564 msg="DNAT 10.0.18.11:8080->10.130.0.44:8080"
id=20085 trace_id=65 func=vf_ip4_route_input line=1596 msg="find a route: flags=00000000 gw-10.0.19.254 via port1"
id=20085 trace_id=65 func=fw_forward_handler line=671 msg="Allowed by Policy-3: encrypt SNAT"
id=20085 trace_id=65 func=__ip_session_run_tuple line=2550 msg="SNAT 172.26.73.11->10.0.18.11:50798"
id=20085 trace_id=65 func=ipsec_tunnel_output4 line=868 msg="enter IPsec tunnel-VPN_to_Atl_36"
id=20085 trace_id=65 func=ipsec_output_finish line=232 msg="send to 10.0.18.45 via intf-port1"
id=20085 trace_id=65 func=esp_output4 line=897 msg="encrypting, and send to 10.0.18.45 with source 10.0.18.25"
config vpn ipsec phase1Firewall policy
edit "VPN_To_Atl_16"
set interface "port1"
set remote-gw 10.0.18.25
next
end
config vpn ipsec phase2
edit "VPN_To_Atl_16"
set phase1name "VPN_To_Atl_16"
set pfs disable
set replay disable
next
end
config firewall policy
edit 6
set srcintf "port2"
set dstintf "port1"
set srcaddr "Local_10.130"
set dstaddr "Remote_10.129" "10.0.18.11"
set action ipsec
set schedule "always"
set service "ALL"
set inbound enable
set outbound enable
set vpntunnel "VPN_To_Atl_16"
next
atlantis-svb36 # diagnose vpn tunnel list
list all ipsec tunnel in vd 0
------------------------------------------------------
name=VPN_To_Atl_16 ver=1 serial=2 10.0.18.45:0->10.0.18.25:0 lgwy=static tun=tunnel mode=auto bound_if=2proxyid_num=1 child_num=0 refcnt=7 ilast=1 olast=1
stat: rxp=90 txp=42 rxb=10992 txb=2332
dpd: mode=active on=1 idle=5000ms retry=3 count=0 seqno=1551
natt: mode=none draft=0 interval=0 remote_port=0
proxyid=VPN_To_Atl_16 proto=0 sa=1 ref=2 serial=2
src: 0:0.0.0.0/0.0.0.0:0
dst: 0:0.0.0.0/0.0.0.0:0
SA: ref=3 options=0000000c type=00 soft=0 mtu=1438 expire=40739/0B replaywin=0 seqno=18
life: type=01 bytes=0/0 timeout=43174/43200
dec: spi=103b3c89 esp=aes key=16 cbf7c9c4d2516b12a73b88918f4eb153
ah=sha1 key=20 ad171e92b5d5b75a831861ebe401f40991cf2185
enc: spi=9af30383 esp=aes key=16 9699fa30efc110c9cc335b23806a731d
ah=sha1 key=20 6cf7508c489d4d8fe71a514dd2136945375771f0
dec:pkts/bytes=40/2212, enc:pkts/bytes=23/2616
2015-09-30 02:29:50 id=20085 trace_id=406 func=print_pkt_detail line=4420 msg="vd-root received a packet(proto=6, 10.0.18.11:51279->10.130.0.44:8080) from port1. flag [S], seq 1577468677, ack 0, win 8192"
2015-09-30 02:29:50 id=20085 trace_id=406 func=init_ip_session_common line=4569 msg="allocate a new session-000003cc"
2015-09-30 02:29:50 id=20085 trace_id=406 func=vf_ip4_route_input line=1596 msg="find a route: flags=00000000 gw-10.130.0.44 via port2"
2015-09-30 02:
The Fortinet Security Fabric brings together the concepts of convergence and consolidation to provide comprehensive cybersecurity protection for all users, devices, and applications and across all network edges.
Copyright 2025 Fortinet, Inc. All Rights Reserved.