FortiGate
FortiGate Next Generation Firewall utilizes purpose-built security processors and threat intelligence security services from FortiGuard labs to deliver top-rated protection and high performance, including encrypted traffic.
jlim11
Staff
Staff
Article Id 304552
Description

This article describes SNAT network behavior when the primary and secondary interface IP address are on the same subnet. 

Scope FortiGate.
Solution

When primary or secondary interface IP addresses have different subnets, FortiOS uses the address that has the same subnet as the gateway found on the route lookup for SNAT.


In the example below, The interface has a Primary IP of 10.47.1.37/20 and Secondary IP of 10.47.1.22/20:

 

network interface.JPG

 

Firewall Policy using 'Use Outgoing Interface Address' for SNAT (port1 is part of 'virtual-wan-link'):

 firewall policy.jpg

 

firewall policy.jpg

 

Checking the IP addresses using the CLI command 'diag ip address list', the Primary IP precedes the Secondary IP. 

ipaddlist4.JPG

 

FortiOS will use the IP address that is on top of the list for SNAT. 

 

Confirmation using debug flow:


debug flow1.JPG

 

Session table:

 

session list1.JPG
If there are changes on the Primary IP address on the interface (such as changing the IP address to another network subnet), this is the time when the secondary IP address will be on the top of the list.


ipaddlist5.JPG
Aside from being on top of the list, the secondary IP(10.47.1.22) will now be used for SNAT since it matches the gateway found on the route lookup.


In this example, even after changing back the IP address of the primary unit, the secondary IP is still on top of the list:


ip addlist6.JPG 

It will now be used for SNAT using the 'Outgoing Interface Address' on the Firewall Policy. FortiOS uses the list shown above.


debug flow5.JPG
Related article:

Technical Note: SNAT and primary versus secondary IP address.