Fortinet white logo
Fortinet white logo

Script Reference Guide

TCP:set_snat_ip(str)

TCP:set_snat_ip(str)

Allows the user to set the backend TCP connection’s source address and port.

Syntax

TCP:set_snat_ip(str);

Note: To use the set_snat_ip() command, you must ensure the SOURCE ADDRESS flag is selected in the HTTP or HTTPS profile type.

Arguments

Name Description

str

A string which specifies the ip address.

Events

Applicable in the following events:

  • TCP_ACCEPTED

  • HTTP_REQUEST

  • HTTP_DATA_REQUEST

  • CLIENTSSL_HANDSHAKE

Example

when TCP_ACCEPTED{
addr_group = “172.24.172.60/24”
client_ip = IP:client_addr()
matched = cmp_addr(client_ip, addr_group)
if matched then
if TCP:set_snat_ip(“10.106.3.124”) then
debug(“set SNAT ip to 10.106.3.124\n”)
end
end
}

Note: The VS must have the client address enabled in the profile, as shown in the example below.

config load-balance profile

edit "http"

set type http

set client-address enable

next

end

Supported Version

FortiADC version 5.2.x and later.

TCP:set_snat_ip(str)

TCP:set_snat_ip(str)

Allows the user to set the backend TCP connection’s source address and port.

Syntax

TCP:set_snat_ip(str);

Note: To use the set_snat_ip() command, you must ensure the SOURCE ADDRESS flag is selected in the HTTP or HTTPS profile type.

Arguments

Name Description

str

A string which specifies the ip address.

Events

Applicable in the following events:

  • TCP_ACCEPTED

  • HTTP_REQUEST

  • HTTP_DATA_REQUEST

  • CLIENTSSL_HANDSHAKE

Example

when TCP_ACCEPTED{
addr_group = “172.24.172.60/24”
client_ip = IP:client_addr()
matched = cmp_addr(client_ip, addr_group)
if matched then
if TCP:set_snat_ip(“10.106.3.124”) then
debug(“set SNAT ip to 10.106.3.124\n”)
end
end
}

Note: The VS must have the client address enabled in the profile, as shown in the example below.

config load-balance profile

edit "http"

set type http

set client-address enable

next

end

Supported Version

FortiADC version 5.2.x and later.