Technical Tip: FortiOS session filter and clear commands affect expectation sessions
| Description | This article describes the expected behavior that firewall 'diagnose sys session ____' commands affect the expectation session list as well as the active session list. |
| Scope | FortiOS. |
| Solution | Session filter and clear commands apply to both 'active' and expectation sessions.
The active session list is more commonly referred to as simply the 'session table' and can be viewed with the command 'diagnose sys session list'. Note: In larger environments with many active sessions, this can display a large amount of output and it is recommended to only run this command after applying a relevant session filter. See the article Technical Tip: Using filters to clear sessions on a FortiGate in the CLI for more detail on available filters.
The expectation session list can be viewed with the command 'diagnose sys session list expectation'.
Example:
diagnose sys session filter dport 61533 <----- Filters session lists for TCP or UDP destination port 61533 diagnose sys session list diagnose sys session list expectation session info: proto=17 proto_state=00 duration=137 expire=-107 timeout=0 refresh_dir=both flags=00000000 socktype=0 sockport=0 av_idx=0 use=2
Clearing long-lived expectation sessions:
Negative expire timer values on expectation sessions are common and expected, since depending on the session helper which installed it, the expectation sessions may only removed when its parent active session closes. See the article Technical Tip : Session helpers and expectation sessions for more information.
Since the filter above only matches sessions that are about to expire or have a negative expire timer, the production impact of clearing matching sessions should be limited in most environments. To minimize disruption to users, it is still considered a best practice to list matched active sessions using 'diagnose system session list' to verify unintended session matches are not occurring. If sessions that must not be cleared are matched by the filter, it is recommended to further customize the session filter to match the intended expectation sessions.
diagnose system session list expectation session info: proto=17 proto_state=00 duration=61 expire=-31 timeout=0 refresh_dir=both flags=00000000 socktype=0 sockport=0 av_idx=0 use=2
diagnose system session list <----- The provided filter also matches any stale active sessions which would otherwise expire in one second or less. session info: proto=17 proto_state=00 duration=180 expire=1 timeout=0 refresh_dir=both flags=00000000 ...
diagnose system session clear diagnose system session list expectation <----- No output any longer: the expectation session was cleared. FGT-A (root) #
Related articles: Technical Tip: Using filters to clear sessions on a FortiGate in the CLI Troubleshooting Tip: FortiGate session table information |
