Setting up the FortiGate
Matrix talks to the FortiGate's REST API (/api/v2/cmdb/…) with the token
of a REST API administrator. This page is for the FortiGate's
administrator. The examples use FortiOS 7.4 CLI; menu names and
permission groups can differ between FortiOS versions, so verify the
result with the check below.
Room policies
Matrix manages policies that you create and name; it never creates or deletes policies.
- One IPv4 policy per room, all with the same direction: one source
interface or zone (for example the students' zone
Students) to one destination interface or zone (for example the SD-WAN zoneINTERNET). Exactly one entry insrcintfand one indstintf. - Each room policy is an ACCEPT policy (
set action accept: enabled, the room has internet; disabled, its traffic falls through) and negates neither its source nor its destination (srcaddr-negateanddstaddr-negatedisable, the default). A DENY policy, or one with negated addresses, would do the opposite of what Matrix shows: it is not a room, even when its name and direction match, and Check warnsroom_policy_not_managed:for it (from the next Matrix connector release). - Names that follow one pattern with the room code in it, for example
Internet Access for SB3-401,Internet Access for FB-102,Internet Access for HAC-202. The firewall's policy name pattern must match exactly these names and nothing else. - The source (
srcaddr) of each room policy names the room's address group; its members are /32 address objects, one per computer (ipmask, mask255.255.255.255). To let Matrix change them, a group must be used only by its room policy, without exclusions or nested groups, and each computer's object must be in that group only (Addresses and groups → What can be edited). - New room policies are picked up at the next report; there is nothing to
restart. The policy's real
policyidis used, whatever the room number.
If an enabled ACCEPT policy after the room policies, with the same
direction, also matches the rooms' computers (source all, or a
network or group containing them), traffic of a disabled room falls
through to it and still reaches the internet. Take the managed addresses
out of such general policies, or add a suitable blocking policy after the
rooms. Matrix reports such policies (later_accept_policy) but never
changes them.
Check firewall-session-dirty (globally, config system settings, or
per policy): with check-all, established sessions are re-evaluated after
a policy change, which does not guarantee that they are cut.
Allowed sites
Allowed sites are domains a room can still reach while its internet is off. Matrix never creates policies or groups: you create them once, and Matrix then only changes the groups' members. Settings → Firewalls, the firewall's page, FortiGate setup of the sites lists → Allowed sites (tenant admins) shows the CLI for whatever is missing, with this firewall's interfaces and room groups:
| What | Address group | ACCEPT policy |
|---|---|---|
| Shared list (every room) | Matrix allowed sites | srcaddr: every room's address groups; dstaddr: Matrix allowed sites |
| A room's own list (optional) | Matrix allowed sites <room> | srcaddr: that room's groups; dstaddr: its group |
Example (shared list and SB1-102's own list; the # lines are
comments that the FortiGate CLI ignores):
# Entrosity Matrix: allowed sites setup.
# Run as a super_admin in the FortiGate CLI, in VDOM "root". When VDOMs are enabled, enter it first:
# config vdom
# edit "root"
# New policies are appended at the end of the policy list: move each one above any DENY policy of
# "Students" -> "INTERNET" (config firewall policy / move <new id> before <deny id> / end).
# Check that "set nat" matches the room policies (change it when they do not use NAT).
# Wildcard domains (*.example.com) only work when the FortiGate sees the clients' DNS queries.
config firewall addrgrp
edit "Matrix allowed sites"
set member "none"
set comment "Entrosity Matrix: allowed sites of every room"
next
edit "Matrix allowed sites SB1-102"
set member "none"
set comment "Entrosity Matrix: allowed sites of SB1-102"
next
end
config firewall policy
edit 0
set name "Matrix allowed sites"
set srcintf "Students"
set dstintf "INTERNET"
set action accept
set srcaddr "SB1-102-Students address" "SB1-108-Students address"
set dstaddr "Matrix allowed sites"
set schedule "always"
set service "ALL"
set nat enable
set logtraffic all
set comments "Entrosity Matrix: allowed sites while a room's internet is off"
next
edit 0
set name "Matrix allowed sites SB1-102"
set srcintf "Students"
set dstintf "INTERNET"
set action accept
set srcaddr "SB1-102-Students address"
set dstaddr "Matrix allowed sites SB1-102"
set schedule "always"
set service "ALL"
set nat enable
set logtraffic all
set comments "Entrosity Matrix: allowed sites of SB1-102"
next
end
- An address group cannot be empty: an empty list holds FortiGate's
built-in address
none, which matches nothing. Matrix replaces it with the first domain and puts it back when the last one is removed. edit 0appends the policies at the end of the policy list. The order relative to the room policies does not matter (an enabled room policy matches first; a disabled one lets the traffic fall through to these), but they must be above any DENY policy of the same interfaces that would catch the traffic:move <id> before <id>.- Match
natto the room policies.servicemay be narrowed toHTTP HTTPS DNS; Matrix finds the policies by their destination group, not by name, so you may rename them. - The CLI covers only what is missing. Rooms without a known address group are skipped with a warning, and policy names are cut to 35 characters (the FortiOS limit).
- FortiGates set up with an earlier version also have the group
Matrix Entrosity servicesas a second destination of the shared policy. Matrix no longer uses it; an admin can remove it (Troubleshooting → Removing the old Entrosity services group). - A room added later must also be added to the shared policy's sources;
the check warns when a policy does not cover every room
(
sites_policy_not_covering). - Wildcard domains (
*.example.com) only work when the FortiGate sees the computers' DNS queries: the FortiGate is their DNS server, or DNS passes through it. - The API administrator's profile already covers it (Firewall → Address
read/write): Matrix creates
fqdnobjectsmatrix-site:<domain>, sets the groups' members, and deletes only its own objects that nothing uses any more.
Blocked sites
Blocked sites are domains a room cannot reach while its internet is on. They are set up like allowed sites, with a DENY policy, and the same card's Blocked sites button shows the CLI:
| What | Address group | DENY policy |
|---|---|---|
| Shared list (every room) | Matrix blocked sites | srcaddr: every room's address groups; dstaddr: Matrix blocked sites |
| A room's own list (optional) | Matrix blocked sites <room> | srcaddr: that room's groups; dstaddr: its group |
config firewall addrgrp
edit "Matrix blocked sites SB1-102"
set member "none"
set comment "Entrosity Matrix: blocked sites of SB1-102"
next
end
config firewall policy
edit 0
set name "Matrix blocked sites SB1-102"
set srcintf "Students"
set dstintf "INTERNET"
set action deny
set srcaddr "SB1-102-Students address"
set dstaddr "Matrix blocked sites SB1-102"
set schedule "always"
set service "ALL"
set logtraffic all
set comments "Entrosity Matrix: blocked sites of SB1-102"
next
end
-
Order matters. The FortiGate takes the first matching policy, so a DENY policy must come before the policy of every room it covers (the shared one before the first room policy).
edit 0appends it at the end, where it blocks nothing: find its id and move it up:config firewall policymove <new id> before <room policy id>endOnce the connector has reported the policy, the blocked-sites page and the check give the exact command (
blocked_sites_below_room:). -
Allowed sites come first. Every allowed-sites policy (the shared one and each room's) must come before the blocked-sites DENY policies of the same rooms. Otherwise an allowed site that shares a Cloudflare or CDN address with a blocked one is blocked for as long as they share it. The order is: allowed-sites policies, blocked-sites policies, room policies. The check warns with
blocked_sites_above_allowed:and the page gives themove <allowed id> before <deny id>commands. -
The DENY policies use the room groups as sources without making them read-only for address editing; only a policy whose every destination is a blocked-sites group counts.
-
Blocked sites are opt-in: a firewall without the groups has no warning. When a group exists, the check warns with
blocked_sites_policy_missing:,blocked_sites_policy_disabled:,blocked_sites_policy_not_covering:,blocked_sites_below_room:,blocked_sites_above_allowed:andblocked_sites_group_read_only:. -
The FortiGate blocks the addresses a domain resolves to: blocking a site on shared addresses (Cloudflare, large CDNs) can block other sites on the same addresses.
-
Matrix reuses the same
matrix-site:<domain>objects for allowed and blocked sites, and deletes one only when no group uses it any more.
Screen wall path
Switching a room off disables only its ACCEPT policy to the internet;
traffic inside the school's network is not affected. The Entrosity Axis
agents on the room's computers, however, connect only outbound to the
Axis server on the internet, so while a room is off they go offline and
the screen wall shows nothing. Their usual
address (hub.entrosity.com) is behind Cloudflare, whose addresses are
shared with many other sites and cannot be allowed by IP.
The screen wall path is one extra ACCEPT policy that lets every room's
computers reach only the Entrosity agent host over HTTPS (in
production agent.entrosity.com, a DNS-only name of the server's own IP
address). Agents from this release use that host first and fall back to
their usual address when it does not answer.
It is opt-in and separate from the allowed-sites lists: Matrix has no
built-in Entrosity exception, and never creates, changes or moves this
policy. It only reads it and shows what is missing (Firewalls → a
firewall → Screen wall path, Firewalls → Screen wall
path).
| What | Value |
|---|---|
| Address object | Matrix screen wall: the agent host's IP address as a /32 (ipmask, mask 255.255.255.255) |
| ACCEPT policy | Matrix screen wall: the firewall's direction (srcintf/dstintf as the room policies), srcaddr every room's address group, dstaddr only Matrix screen wall, service only HTTPS, schedule always |
| Position | Above the room policies |
The card's Show FortiGate CLI gives the commands with this firewall's
interfaces, room groups and the server's agent host. Example (the
pilot school; the # lines are comments):
# Entrosity Matrix: screen wall path for agent.entrosity.com (93.123.16.96).
# Lets every room's computers reach only the Entrosity agent host over
# HTTPS while a room's internet is off, so the screen wall keeps working.
# Run as a super_admin in the FortiGate CLI, in VDOM "root" (with VDOMs: config vdom / edit "root").
config firewall address
edit "Matrix screen wall"
set subnet 93.123.16.96 255.255.255.255
set comment "Entrosity agents (agent.entrosity.com)"
next
end
config firewall policy
edit 0
set name "Matrix screen wall"
set srcintf "Students"
set dstintf "INTERNET"
set action accept
set srcaddr "FB-102-Students address" "HAC-401-Students address" "SB1-102-Students address" "SB1-108-Students address" "SB1-208-Students address" "SB2-216-Students address" "SB2-315-Students address" "SB2-316-Students address"
set dstaddr "Matrix screen wall"
set schedule "always"
set service "HTTPS"
set nat enable
set logtraffic all
next
end
# Then move the new policy above the room policies: find its id with
# show firewall policy | grep -f "Matrix screen wall"
# and run
# config firewall policy
# move <id> before 102
# end
- Move it above the rooms.
edit 0appends the policy at the end of the list; themoveat the end puts it before the first room policy (102here). Above the rooms, it matches the agents' traffic whether a room is on or off; everything else of a room that is off falls through to the block as before. Matchnatto the room policies. - Verify with Check on the firewall's page
(Firewalls → Check): the card must say Set up,
and the check must show no
wall_path_…warnings. An existing policy that is wrong (disabled, missing room groups, below a room, too broad) gets a CLI that fixes it instead (edit <id>withset status enable,append srcaddr …,set dstaddrandset service HTTPS,set schedule always, thenmove <id> before <first room>). - A room added later must be added to the policy's sources too
(
wall_path_not_covering). - The teacher's own computer must not be in a room's address group: its browser reaches the screen wall through Cloudflare and would be blocked with the room.
While a room is off, its computers reach the agent host's IP address on
port 443 and nothing else; other rooms and the school's network are not
affected. But anything served on that IP address over HTTPS is
reachable, including other Entrosity websites on the same address.
Never widen the policy: a
destination other than the single /32 (for example all) or a service
other than HTTPS lets rooms that are off reach the internet
(wall_path_too_broad, wall_path_service).
REST API administrator
Access profile
Give the administrator only what Matrix uses:
| What Matrix does | FortiGate API | Permission |
|---|---|---|
| Check the direction | system/interface, system/zone, system/sdwan (GET) | Network configuration: read |
| Read and switch room policies | firewall/policy (GET, PUT of status only) | Firewall → Policy: read/write |
| Read computers, change IPs, add computers; allowed sites | firewall/address (GET, PUT, POST, DELETE of Matrix's own unused FQDN objects), firewall/addrgrp (GET, PUT of member) | Firewall → Address: read/write |
| Everything else | – | none |
Without address changes (Allow changing and adding computers off), Firewall → Address can be read only; Matrix still needs to read every address, group and policy to decide what is editable and to warn about later ACCEPT policies.
config system accprofile
edit "entrosity-matrix"
set netgrp read
set fwgrp custom
config fwgrp-permission
set policy read-write
set address read-write
end
next
end
With network monitoring on, add set sysgrp read
to this profile; it reads the rest with the rights above
(FortiGate access profile).
FortiGate cannot restrict an API token to single policy IDs: the token can
change any policy the profile allows. Matrix enforces its own strict
allowlist (pattern, exact direction, VDOM, a re-read before every write,
only the status field, the local guard). Keep the profile minimal and
the token on the connector computer only.
The administrator
- Trusted hosts: only the connector computer's IP address as the FortiGate sees it (after NAT, if any). Nothing else.
- VDOM: only the rooms' VDOM (for example
root). - PKI group / CORS: not needed.
config system api-user
edit "entrosity-matrix"
set comments "Entrosity Matrix connector"
set accprofile "entrosity-matrix"
set vdom "root"
config trusthost
edit 1
set ipv4-trusthost 192.0.2.50 255.255.255.255
next
end
next
end
execute api-user generate-key entrosity-matrix
192.0.2.50 is an example: use the connector computer's address. The last
command prints the token once: store it in Matrix
(Firewalls → API token) and do not keep other
copies. To rotate, run execute api-user generate-key again and store the
new token.
Management access
- The connector reaches the FortiGate's HTTPS management port from the administration network. Student VLANs must reach neither the FortiGate's management port nor the connector computer: check it from a real student network.
- Certificate: Matrix verifies the FortiGate's TLS certificate by default. Give Matrix the CA that issued it (CA certificate (PEM)), or install a certificate the connector computer trusts. Switch verification off only if you have no CA yet; the connection is still encrypted, but the FortiGate's identity is not checked.
Verify
Before switching changes on:
- Run Check on the firewall's page
(Firewalls → Check), or on the connector computer
matrix-connector check --config local.json, which only sends GET requests (Connectors → Offline check). It must show the version, Direction … confirmed, the expected rooms and groups, and no warnings you have not accounted for. auth_failedon the check means the token is wrong, the profile lacks a read permission, or the connector's IP is not a trusted host.- Whether the profile really allows the writes is only shown by a
write. Agree on a test room (and, for addresses, a test computer and
group), switch changes on, and switch that room off and on, then change
that computer. A write the profile refuses is sent and answered with
HTTP 403, so it shows as Unconfirmed (the connector does not assume
that nothing happened); after Refresh the room is unchanged and the
history's detail names
auth_failed. Widen the profile and try again.