Felix Cloud/Insights

FortiGate IKEv2 VPN with Microsoft Entra ID sign-in and MFA.

A complete admin setup guide for a remote-access VPN where staff sign in with their Microsoft account: public DNS, a free certificate, the Entra app, every FortiGate CLI block, FortiClient, testing and troubleshooting.

A fingerprint and key connected to devices and applications

This is the build we use for small offices that want remote access without another password. Staff open FortiClient, sign in with their Microsoft account and MFA, and reach the office network over an IKEv2 tunnel. Who may connect is decided by membership of one Entra security group.

  • Microsoft sign-in with MFA. The FortiGate hands authentication to Entra ID over SAML, then checks the user's group once, at connect.
  • One group controls access. Add or remove a member in Entra. Nothing changes on the firewall.
  • Free pieces. FortiGuard DDNS, a Let's Encrypt certificate that renews itself, and the free FortiClient VPN on Windows and Mac.
  • Split tunnel. Only office traffic uses the VPN. Internet traffic stays on the user's own connection.
About the examples. The company in this guide, Northwind Supply Co. (100 Example Street, Toronto, ON), is fictional. Every name, address, IP and ID below is a placeholder; replace them with your own. Tested on a FortiGate 50G with FortiOS 7.6.8, single WAN, and FortiClient VPN 7.4.4.

Example values

ItemValue
VPN name (users, Entra, FortiClient)vpn.northwind.example
Public DNSCNAME vpn → northwind-vpn.fortiddns.com. (FortiGuard DDNS) → WAN IP
WANwan — PPPoE, public IP (203.0.113.25 in this example), no NAT in front
LANlan — 192.168.50.0/24
VPN client pool10.210.1.1 – 10.210.1.254
DNS for VPN clients1.1.1.1, 8.8.8.8 (this example has no server or Active Directory on site)
SAML (sign-in) portTCP 24443
CertificateLE-VPN — Let's Encrypt, CN vpn.northwind.example, renews itself
Entra tenant ID11111111-2222-3333-4444-555555555555
Entra appNorthwind FortiGate VPN (gallery app "FortiGate SSL VPN")
Entra groupSG-VPN-Users · Object ID aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee
Entra signing cert on FortiGateREMOTE_Cert_1
FortiGate objectsSAML server Entra-VPN · group GRP-VPN-Entra · tunnel DU-VPN · policy IKEv2-SAML-VPN-to-LAN
Pre-shared keyStored in your password manager only, never in a document, email or chat

How it works

Sign-in flow
  FortiClient ──(1) TCP 24443──► FortiGate ──(2) redirect──► Microsoft Entra sign-in + MFA
       ▲                                                              │
       │                         (3) signed SAML answer: username + group ID
       │                                                              ▼
       └──(4) IKEv2 on UDP 500/4500, EAP with the sign-in token ──► FortiGate checks group
                                                                   aaaaaaaa-… = SG-VPN-Users
  Connected: client gets 10.210.1.x, routes only 192.168.50.0/24 through the tunnel.
  • Who may connect is decided only by membership of SG-VPN-Users, checked once at connect (phase 1 authusrgrp).
  • The firewall policy has no user groups. Once connected, traffic to the LAN is allowed. Group matching on the policy blocks all traffic after connect.
  • Split tunnel: only office traffic uses the VPN; internet traffic stays on the user's own connection.

Public DNS: FortiGuard DDNS and CNAME

The WAN IP is dynamic (PPPoE). FortiGuard DDNS keeps northwind-vpn.fortiddns.com pointing to the current IP. The company's own name vpn.northwind.example is a CNAME to it, so users, Entra and the certificate all use the company domain.

3.1 FortiGuard DDNS on the FortiGate

GUI: Network → DNS → FortiGuard DDNS → on, interface wan, name northwind-vpn, domain fortiddns.com. CLI equivalent:

FortiGate CLI
config system ddns
    edit 1
        set ddns-server FortiGuardDDNS
        set server-type ipv4
        set ddns-domain "northwind-vpn.fortiddns.com"
        set monitor-interface "wan"
    next
end

Requires the FortiGate to be registered (FortiCare). Check: show system ddns, and from any PC nslookup northwind-vpn.fortiddns.com 8.8.8.8 → current WAN IP.

The WAN must hold the public IP itself. Check with get system interface physical: wan shows 203.0.113.25 in PPPoE mode. If an ISP modem ever does NAT in front (WAN shows 192.168.x / 10.x), put the modem in bridge mode, or forward UDP 500, UDP 4500, TCP 24443 and TCP 443, and set set use-public-ip enable in the DDNS entry.

3.2 CNAME in the company's DNS

TypeHost / NameTarget / AddressTTL
CNAMEvpnnorthwind-vpn.fortiddns.com. ← with the trailing dot5 minutes
Trailing dot. In this DNS panel a target without a final dot is treated as a name inside the zone, so the CNAME pointed to northwind-vpn.fortiddns.com.northwind.example and lookups returned "Non-existent domain". The panel warns "No trailing dot! Click to add dot" — always add it. In the Host field enter only vpn.

Check from any PC:

From any PC
nslookup vpn.northwind.example 8.8.8.8
  Name:    northwind-vpn.fortiddns.com
  Address: 203.0.113.25
  Aliases: vpn.northwind.example

If Google still answers "Non-existent domain" right after a fix, it is caching the earlier answer; test with 1.1.1.1 or wait up to an hour.

3.3 Why CNAME rather than the DDNS name alone

DDNS name onlyCNAME (used here)
Name users seefortiddns.com (Fortinet's domain)the company's own domain
Certificate optionsLet's Encrypt onlyLet's Encrypt or the company's wildcard
FortiGate replaced / DDNS name lostNew name: redo Entra, SAML, certificate and every FortiClientPoint the CNAME at the new target; nothing else changes
Static IP laterSame reworkChange the CNAME to an A record

The DDNS-only variant is described in Appendix A.

Certificate: Let's Encrypt (or wildcard)

The Microsoft sign-in starts on the FortiGate at https://vpn.northwind.example:24443, in the user's browser, so it needs a trusted certificate for exactly that name. There are two free options; this guide uses Let's Encrypt.

4.1 Let's Encrypt on the FortiGate

Before requesting:

  • The name must already resolve publicly to the WAN IP (section 3.2). A request for a name that does not resolve fails.
  • Let's Encrypt must reach the FortiGate on the WAN to validate it (TCP 443 per Fortinet's ACME documentation): no VIP/port forward on 443 to an internal server and no admin HTTPS on 443 on wan.

GUI: System → Certificates → Create/Import → Certificate → Use Let's Encrypt, domain vpn.northwind.example, email = admin mailbox, ACME interface wan. CLI:

FortiGate CLI
config system acme
    set interface "wan"
end
config vpn certificate local
    edit "LE-VPN"
        set enroll-protocol acme2
        set acme-domain "vpn.northwind.example"
        set acme-email "[email protected]"
        next

At "Do you want to continue? (y/n)" (Let's Encrypt terms) type y by hand, then type end.

Paste in two parts. If end is pasted together with the block, its first letter answers the y/n prompt, the request is cancelled ("Command cancelled by user") and nothing is saved. The email must be a real address — a placeholder gives "is not a valid email address".

Check after about a minute:

FortiGate CLI
get vpn certificate local details LE-VPN
        Subject:     CN = vpn.northwind.example
        Issuer:      C = US, O = Let's Encrypt, CN = YR1
        Valid to:    2027-02-21
ACME details:
        Status: finished, notified
Check the CN, not the label. A certificate can carry the company name as its label and still be issued for CN = northwind-vpn.fortiddns.com, which is wrong for the CNAME design (browsers warn). The name column in the GUI is only a label; the CN/SAN is what counts. Delete any such certificate when its Ref. count is 0.

Renewal: automatic, about every 60 days, same certificate name, so nothing needs re-pointing. It keeps working as long as the name resolves and TCP 443 on the WAN stays free.

4.2 Alternative: the company's existing wildcard

If the company already owns *.northwind.example and the private key is available:

  1. Export a PFX: on the Windows server where it is installed, certlm.msc → Personal → Certificates → the wildcard → All Tasks → Export → Yes, export the private key → include all certificates in the path → set a password. (Or download certificate, key and CA bundle from the provider.)
  2. FortiGate: System → Certificates → Create/Import → Certificate → Import Certificate → PKCS#12 → name e.g. WILDCARD-VPN. Import the intermediate under CA Certificate if it was not included.
  3. Use that name wherever this guide uses LE-VPN.

No automatic renewal: import the renewed wildcard each year and re-point the two settings (6.1 and 6.2). A wildcard does not cover the fortiddns.com name, so it only works with the CNAME design.

Microsoft Entra ID

5.1 Security group

Entra admin center → Groups → New group: Group type Security · name SG-VPN-Users · Membership type Assigned · Entra roles can be assigned: No. Object ID: aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee.

Not mail-enabled: a mail-enabled security group is managed in Exchange, so members cannot be added in Entra, and it would appear in the address book. A Microsoft 365 group would work but creates a mailbox and site that are not needed.

5.2 Enterprise app

Enterprise applications → New application → gallery FortiGate SSL VPN → name Northwind FortiGate VPN → Create → Single sign-on → SAML → Basic SAML Configuration:

FieldValue
Identifier (Entity ID)https://vpn.northwind.example:24443/remote/saml/metadata/ (keep the final /)
Reply URL (ACS)https://vpn.northwind.example:24443/remote/saml/login
Sign on URLhttps://vpn.northwind.example:24443/remote/saml/login
Logout URLhttps://vpn.northwind.example:24443/remote/saml/logout

5.3 Attributes & Claims — must end up exactly like this

Claim nameValue shownHow
usernameuser.userprincipalname (no quotes)Source Attribute; pick the attribute from the dropdown
groupuser.groupsGroup claim: Groups assigned to the application · source Group ID · Advanced → Customize the name → group, namespace empty
Two common mistakes:
  • "user.userprincipalname" in quotes = Source "Constant": every user sends that literal text. Fix: Source Attribute + choose from the list.
  • Group claim left as "Security groups" with the default long name http://schemas.microsoft.com/ws/2008/06/identity/claims/groups: the FortiGate looks for group and finds nothing. "Add a group claim" is greyed out once one exists — edit the existing one.
The other default claims (givenname, surname, emailaddress, name) can stay or be removed; the FortiGate uses only these two.

5.4 Certificate, assignment, access

  1. SAML Certificates → Certificate (Base64) → Download. On the FortiGate: System → Certificates → Create/Import → Remote Certificate → upload → it becomes REMOTE_Cert_1 (CN = Microsoft Azure Federated SSO Certificate).
  2. Users and groups → + Add user/group → SG-VPN-Users → Assign.
  3. Properties → Assignment required? = Yes (only after step 2). Non-members then get a clear Microsoft error instead of a silent hang.
  4. Conditional Access: require MFA for Northwind FortiGate VPN.
  5. Give users access by adding them as direct members of SG-VPN-Users.
Never assign users to the app one by one or through a nested group. They pass the Microsoft sign-in, but their token carries no group ID; the FortiGate denies them (FNBAM_DENIED) and FortiClient keeps "connecting" with no error.

FortiGate configuration (CLI)

6.0 Pre-checks

FortiGate CLI
show firewall vip                       (nothing may use 24443 or 443 on the WAN IP)
get system global | grep -i port        (admin ports must not be 24443)

6.1 SAML port and certificate

FortiGate CLI
config system global
    set auth-ike-saml-port 24443
end
config user setting
    set auth-cert "LE-VPN"
end

6.2 SAML server

FortiGate CLI
config user saml
    edit "Entra-VPN"
        set cert "LE-VPN"
        set entity-id "https://vpn.northwind.example:24443/remote/saml/metadata/"
        set single-sign-on-url "https://vpn.northwind.example:24443/remote/saml/login"
        set single-logout-url "https://vpn.northwind.example:24443/remote/saml/logout"
        set idp-entity-id "https://sts.windows.net/11111111-2222-3333-4444-555555555555/"
        set idp-single-sign-on-url "https://login.microsoftonline.com/11111111-2222-3333-4444-555555555555/saml2"
        set idp-single-logout-url "https://login.microsoftonline.com/11111111-2222-3333-4444-555555555555/saml2"
        set idp-cert "REMOTE_Cert_1"
        set user-name "username"
        set group-name "group"
        set digest-method sha256
    next
end

6.3 User group (checked at connect only)

FortiGate CLI
config user group
    edit "GRP-VPN-Entra"
        set member "Entra-VPN"
        config match
            edit 1
                set server-name "Entra-VPN"
                set group-name "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"
            next
        end
    next
end

6.4 SAML on the WAN · 6.5 Address objects

FortiGate CLI
config system interface
    edit "wan"
        set ike-saml-server "Entra-VPN"
    next
end
config firewall address
    edit "VPN-Pool"
        set subnet 10.210.1.0 255.255.255.0
    next
    edit "Office-LAN"
        set subnet 192.168.50.0 255.255.255.0
    next
end

6.6 Phase 1

FortiGate CLI
config vpn ipsec phase1-interface
    edit "DU-VPN"
        set type dynamic
        set interface "wan"
        set ike-version 2
        set peertype any
        set net-device disable
        set mode-cfg enable
        set proposal aes256gcm-prfsha384 aes256-sha256
        set dhgrp 20 14
        set eap enable
        set eap-identity send-request
        set authusrgrp "GRP-VPN-Entra"
        set ipv4-start-ip 10.210.1.1
        set ipv4-end-ip 10.210.1.254
        set ipv4-netmask 255.255.255.0
        set dns-mode manual
        set ipv4-dns-server1 1.1.1.1
        set ipv4-dns-server2 8.8.8.8
        set ipv4-split-include "Office-LAN"
        set client-auto-negotiate enable
        set client-keep-alive enable
        set transport udp
        set dpd on-idle
        set dpd-retryinterval 30
        set dpd-retrycount 5
        set keepalive 10
        set psksecret <PSK from your password manager>
    next
end

PSK: long random string without spaces or ?. transport exists from FortiOS 7.4.2. set domain is IKEv1-only; it is not used here (no internal domain).

6.7 Phase 2 · 6.8 Firewall policy (no user groups)

FortiGate CLI
config vpn ipsec phase2-interface
    edit "DU-VPN"
        set phase1name "DU-VPN"
        set proposal aes256gcm aes256-sha256
        set dhgrp 20 14
    next
end
config firewall policy
    edit 0
        set name "IKEv2-SAML-VPN-to-LAN"
        set srcintf "DU-VPN"
        set dstintf "lan"
        set srcaddr "VPN-Pool"
        set dstaddr "Office-LAN"
        set action accept
        set schedule "always"
        set service "ALL"
        set logtraffic all
        set nat enable
    next
end
  • edit 0 takes the next free policy ID; move the policy above any deny rules.
  • nat enable: LAN devices see VPN users as the FortiGate's LAN IP, so printers/PCs need no return route and "local subnet" firewall rules apply.
  • No security profiles are set here. Add antivirus and IPS profiles if the unit has a UTM licence.
  • To limit access, narrow dstaddr/service — never add user groups to this policy.

Testing and debugging

7.1 From a PC outside the office

From any PC
nslookup vpn.northwind.example                              → 203.0.113.25
Test-NetConnection vpn.northwind.example -Port 24443        → TcpTestSucceeded : True
Browser: https://vpn.northwind.example:24443                → valid padlock (Let's Encrypt)

7.2 On the FortiGate after connecting

FortiGate CLI
diagnose vpn tunnel list | grep -v key        (never paste tunnel output with keys anywhere)
diagnose firewall auth list

7.3 Debug — start BEFORE the user clicks Connect

FortiGate CLI
diagnose debug reset
diagnose vpn ike log filter clear
diagnose vpn ike log filter rem-addr4 <user's public IP>
diagnose debug console timestamp enable
diagnose debug application samld -1
diagnose debug application ike -1
diagnose debug enable
   ... user connects, signs in, waits 30 s ...
diagnose debug disable
diagnose debug reset
In the outputMeaning
samld lines contain aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeeeEntra sends the group correctly
No group attribute in the samld outputUser not a direct member of SG-VPN-Users, or the group claim is wrong (5.3)
FNBAM_DENIED / EAP failedGroup check failed (same as above)
No lines from the user's IP at allPackets don't reach the FortiGate: wrong address/port in FortiClient, or the user's network blocks UDP 500/4500 (test on a phone hotspot)
INVALID_KE then a second SA_INITNormal: client offered DH 14 first, FortiGate asked for 20

Replace <user's public IP> with the real address — the literal text gives "command parse error". The IKE debug prints session keys (SK_ei etc.); they are useless after the session ends, but do not post captures publicly.

FortiClient

Free FortiClient VPN — Windows https://links.fortinet.com/forticlient/win/vpnagent, Mac https://links.fortinet.com/forticlient/mac/vpnagent (7.4.3 or newer on Mac; tested 7.4.4).

FieldValue
VPN / Connection NameIPsec VPN · Northwind VPN
Remote Gatewayvpn.northwind.example
AuthenticationPre-shared key (from your password manager)
SSO for VPN Tunnel · Customize port · external browser✔ · ✔ 24443 · ✔
Advanced: VPN settingsIKE Version 2, Mode Config
Phase 1AES256GCM+PRFSHA384 and AES256+SHA256 · DH 14 and 20 · DPD ✔ · NAT-T ✔ · Local ID empty
EAP✔ · Prompt on login
Phase 2AES256+SHA256 · Replay ✔ · PFS ✔ · DH 14 · key life 43200

Roll-out: configure one PC, export a password-protected .conf (Settings → padlock → Backup), give users the file and its password separately, plus a short user guide.

RDP to office PCs over the VPN

  • Connect to PCs by IP (e.g. 192.168.50.205). The VPN gives public DNS, so office PC names do not resolve.
  • Entra accounts sign in with email + password in the normal RDP prompt only from a PC joined to the company's Entra tenant. From a PC in another tenant (e.g. the MSP's own laptop) the same credentials fail with "The logon attempt failed".
  • From a PC outside the tenant: mstsc → Show Options → Advanced → Use a web account to sign in to the remote computer, connect by the PC's name (hosts-file entry needed), and run it from a Windows profile that is not signed in to another Entra tenant (otherwise the sign-in picks that account).
  • Local accounts work from anywhere.

Allow an Entra user to RDP into a workstation

On the workstation
On the workstation, signed in as that Entra user:
    whoami                                         → e.g. AzureAD\JohnSmith
In an elevated Command Prompt:
    net localgroup "Remote Desktop Users" /add "AzureAD\JohnSmith"
    net localgroup "Remote Desktop Users"          (verify)
Connect: mstsc → 192.168.50.x → user's Entra email + password

The whoami name can differ from the email address — add the whoami value, sign in with the email. If the IP of a target PC changes (new DHCP lease), check its current IP first; reserve the IP in the FortiGate DHCP server if it becomes a nuisance.

Troubleshooting

SymptomCauseFix
nslookup: Non-existent domainCNAME target without trailing dot, or record not saved / wrong DNS providerTarget northwind-vpn.fortiddns.com.; host vpn; check nslookup -type=ns northwind.example
Browser warns on the certificateCertificate issued for another name (fortiddns)Use LE-VPN (CN vpn.northwind.example) in 6.1 and 6.2
Let's Encrypt request cancelledend pasted with the block answered the y/n promptType y by hand, then end
Let's Encrypt fails / stops renewingName doesn't resolve, or 443 on the WAN used by a VIP/adminFix DNS; free TCP 443 on wan
Entra error AADSTS50011Reply URL / Identifier mismatchURLs exactly as 5.2 (final / on the Identifier)
Microsoft sign-in OK, FortiClient keeps connecting, no errorUser not a direct member of SG-VPN-Users (assigned directly/nested), or group claim wrongAdd to SG-VPN-Users; check 5.3; shut down and reopen FortiClient; debug 7.3
Microsoft error AADSTS50105User not in SG-VPN-Users (Assignment required = Yes)Add the user to the group
Negotiation Failed / IkeSa_FailedWrong gateway/port, or UDP 500/4500 blocked on the user's networkCheck profile; test on a hotspot; capture on wan
Connected but LAN unreachable, drops after ~1 min (Dpd_RetryMaximum)User group added to the firewall policyunset groups on the policy
Choppy / dropping connectionSome ISPs drop inbound UDP 4500 in burstsdiagnose sniffer packet wan 'host <user IP> and udp port 4500' 4 on both ends; ISP ticket if packets are missing
Mac: fails at once / IKEv2 greyed outFortiClient older than 7.4.3Install the current free version
RDP with Entra account: "logon attempt failed"Connecting PC not in the company's tenantSection 9

Maintenance

TaskWhenAction
User accessOngoingAdd/remove members of SG-VPN-Users only — no FortiGate change
CertificateAutomaticCheck get vpn certificate local details LE-VPN after FortiOS upgrades and if users see a warning
Entra signing certificateBefore its expiry (shown in the app)Download the new one, import as Remote Certificate, update idp-cert in Entra-VPN
PSKStaff change / leakNew PSK in phase 1 + re-issue the FortiClient .conf
Config backupAfter changesBackup the FortiGate config; keep the PSK and backups in your password manager
FortiClientYearlyKeep users on the current free 7.4.x

DDNS-only option (no CNAME)

Use this only when the company's DNS cannot be edited. Everything in this guide stays the same except the name and the certificate:

WhereUse instead
DNSNo CNAME. FortiGuard DDNS as in 3.1
CertificateLet's Encrypt for northwind-vpn.fortiddns.com: set acme-domain "northwind-vpn.fortiddns.com", e.g. name LE-VPN-DDNS. The company wildcard cannot be used.
6.1 / 6.2auth-cert and cert = LE-VPN-DDNS
Entra 5.2 and SAML server 6.2Every vpn.northwind.example → northwind-vpn.fortiddns.com
FortiClient Remote Gatewaynorthwind-vpn.fortiddns.com
If the FortiGate is replaced or the DDNS name changes, the Entra app, SAML server, certificate and every user's FortiClient must be redone. Switching later to the CNAME design means the same rework, so prefer the CNAME from the start.

Before you call it done

Back up the FortiGate configuration, store the pre-shared key and the backup in your password manager, and add a calendar reminder for the Entra signing certificate's expiry date. Everything else in this design looks after itself.

Rather not spend a day in the CLI?

Felix Cloud deploys and manages FortiGate VPNs with Entra ID sign-in, including the user roll-out.

Talk to Felix

Want this set up for you?

We design, deploy and manage FortiGate VPNs with Microsoft Entra ID sign-in. You get a plain-language plan and a quote, with no obligation.

  • +1 (866) FELIX-1TToll-free
  • +1 (647) 494-9872Toronto
  • [email protected]We reply within one business day
  • 1070 Sheppard Ave West, North York, ON M3J 0G8Felix IT Solutions Inc.