Technical Tip: Using the same TCP port for IPsec SAML authentication and IKE TCP encapsulation in FortiOS v7.6.1
| Description | This article provides an example of configuring IKE and SAML to both listen the same custom TCP port 20443, as well as an example of configuring IKE and SAML to both listen on the default IKE TCP port 443. |
| Scope | FortiOS v7.6.1 and above, FortiClient v7.4.1 and above. |
| Solution | In FortiOS v7.6.1 and later, it is possible to host a SAML SP server for IPsec user authentication on the same port as the one used for IKE TCP encapsulation. This can be necessary to support locked-down environments where the only certain outgoing ports are allowed for clients.
IPsec dial-up VPN over TCP also requires FortiClient v7.4.1 or later; see the FortiClient 7.4.0 New Features Guide for details on IPsec VPN over TCP support on Windows, macOS, and Linux.
Multiple resources exist demonstrating how to configure a SAML server for IKE. It is recommended to review the following documents and configure a test deployment using UDP transport for IPsec before integrating TCP transport.
Example 1: FortiOS configuration using TCP port 20443. This example demonstrates some important settings for transitioning an existing working dial-up tunnel to IKE TCP transport, but is not comprehensive.
config system setting set ike-tcp-port 20443 <----- Changing ike-tcp-port flushes all existing IPsec tunnels on the VDOM. end
config system global set auth-ike-saml-port 1001 <----- Any port except ike-tcp-port. end
Warning: Changing the ike-tcp-port flushes all existing IPsec tunnels, including site-to-site tunnels and those using UDP transport mode. This will cause some disruption for existing traffic traversing IPsec VPN tunnels.
When IPsec SAML authentication and IKE TCP encapsulation use the same port, the 'auth-ike-saml-port' setting is not used. The 'ike-tcp-port' should be configured to match the single TCP port that will handle both SAML authentication and IPsec traffic.
config user setting set auth-cert <certificate for FortiGate FQDN> <----- Certificate used for client connection to FortiGate as SAML SP. end
Ensure the SAML SP information includes the intended TCP port in the URL.
config user saml edit "IKE_SAML" set entity-id "http://<FortiGate FQDN>:20443/remote/saml/metadata/" set single-sign-on-url "https://<FortiGate FQDN>:20443/remote/saml/login" set single-logout-url "https://<FortiGate FQDN>:20443/remote/saml/logout" set idp-entity-id <IDP identifier URL> next end
Note: entity-id, single-sign-on-url, and single-logout-url including port must mirror the Enterprise Application or SAML Service Provider settings configured on the SAML IDP (Entra ID, Google Workspaces, FortiIdentity Cloud etc.)
config system interface edit "port1" set ike-saml-server "IKE_SAML" next end
config vpn ipsec phase1-interface edit "dialup_psk" set type dynamic set interface "port1" set ike-version 2 set transport auto set fortinet-esp disable <----- Default setting. fortinet-esp is a legacy protocol used only for FortiGate-FortiGate tunnels. set ipv4-start-ip 10.253.0.100 set psksecret <psk> set dpd-retryinterval 60 next end
config user group edit "IKE SAML user group" set member "IKE_SAML" next end
config firewall policy edit <index> set name "RA VPN test" set srcintf "dialup_psk" set dstintf "port2" set action accept set srcaddr "IPsec VPN Admin Clients" set dstaddr "Test Address" set schedule "always" set service "PING" <-- test policy only allowing ICMP ECHO Request. Can be expanded to include additional services. set groups "IKE SAML user group" next end
On FortiClient, enable single-sign-on and configure the single-sign-on port as 20443. Enable IPsec over TCP and configure TCP port as 20443.
FortiClient v7.4.3 configuration using TCP port 20443:
Example 2: FortiOS configuration using TCP port 443.
This is a repeat of example 1, but with the following differences:
config system setting set ike-tcp-port 443 <----- Default value on FortiOS v7.6.1 and later. If the firewall was upgraded from a previous version, the ike-tcp-port may still be configured as the old default value 4500. end
config user saml edit "IKE_SAML" set entity-id "http://<FortiGate FQDN>/remote/saml/metadata/" set single-sign-on-url "https://<FortiGate FQDN>/remote/saml/login" set single-logout-url "https://<FortiGate FQDN>/remote/saml/logout" set idp-entity-id <IDP identifier URL> next end
Notes:
FortiClient v7.4.3 configuration using TCP port 443:
Potential port conflicts:
Verification:
Note: In most environments, it is recommended to configure FortiClient IPsec Encapsulation as 'Auto(UDP fallback TCP)'.
diagnose debug application ike -1 diagnose debug application authd 7 diagnose debug enable ike V=root:accepts ike tcp-transport(vd=0, vrf=0, intf=0:3, 10.250.255.27:20443->10.250.101.89:55059 sock=44 refcnt=2 ph1=(nil)) (2). ike V=root:NOT IKETCP(), assign to AUTH authd_http: change state from 0 to 1 authd_http: change state from 1 to 2 To stop the debug processes, run the following: diagnose debug reset diagnose debug disable
If 'NOT IKETCP(), assign to AUTH' messages are seen and CPU usage is normal for the iked and authd processes, it is unlikely to be an issue specific to IPsec over TCP. In this case, see Troubleshooting IPsec VPN IKEv2 with SAML authentication for further troubleshooting steps.
Notes:
Related documents: |



