FortiADC
FortiADC enhances the scalability, performance, and security of your applications whether they are hosted on premises or in the cloud.
kmak
Staff
Staff
Article Id 391765
Description This article provides the FortiADC Server Load Balance Layer-7 UDP Virtual configuration to enable NAT Source Pool using Stream Scripting.
Scope FortiADC.
Solution

Configurations:

  1. Layer-7 TCP or UDP Virtual Server does not have the option to enable NAT Source Pool from the Virtual Server configuration. It is possible to perform NAT source routing using Stream Scripting. In the example of a Layer-7 UDP Virtual Server, which is being used for remote Syslog server routing.

 

kmak_0-1747191621867.jpeg

 

  1. The Virtual Server has no option to enable NAT Source Pool like the Layer-7 HTTP/HTTPS Virtual Server.

 

kmak_1-1747191621870.jpeg

 

  1. Navigate to the Stream Scripting page and create a new Stream Script. Insert the script sample below into the text box, whereby the script performs NAT source IP using the IP 10.10.0.101:

 

when STREAM_CLIENT_INIT {

    UDP:set_snat_ip("10.10.0.101")

}

 

kmak_2-1747191621872.jpeg

 

  1. Navigate back to the Virtual Server page and enable the Stream Scripting setting. Select the NAT Source Stream script from the list.

 

kmak_3-1747191621880.jpeg

 

  1. For FortiADC v7.6.1 or lower, the UDP NAT source pool script may not be working properly and may cause the Layer-7 UDP Virtual Server to fail. Running the sniffer in FortiADC resulted in the FortiADC Virtual Server IP receiving the incoming traffic, but the traffic was not being forwarded to the destination real server.

 

kmak_4-1747191621882.jpeg

 

  1. Run the debug command in FortiADC to debug the Layer-7 UDP Virtual Server Stream scripting process. The errors are pointing to the script command 'UDP':

 

diagnose debug module fnginx scripting set

diagnose debug enable

 

kmak_5-1747191621890.jpeg

 

  1. The Stream script command 'UDP' failed on FortiADC v7.6.1 and below, and it is fixed in v7.6.2. The workaround for the old version will be using the script command 'TCP' instead. The script will work for both Layer-7 TCP and UDP Virtual Servers:

 

when STREAM_CLIENT_INIT {

    TCP:set_snat_ip("10.10.0.101")

}

 

  1. Upgrade to FortiADC v7.6.2 to resolve the Stream script command 'UDP' issue. After completing the configurations, run a packet sniffer or the debug commands in FortiADC to verify.

 

kmak_6-1747191621895.jpeg

 

Related document:

https://docs.fortinet.com/document/fortiadc/7.6.1/script-reference-guide/9537/udp-set-snat-ip-str