Skip to content
Guides & References

Junos logging

Worked examples for Juniper Junos logging: a remote syslog host for all and authorisation messages, millisecond timestamps, no console logging and UTC time.

Policy LibraryUpdated
Platform
juniper-junos
Minimum version
rConfig 8.0.2
Editions
Pro, Vector, Enterprise
On this page

Junos logging

Rules for where logs go and how useful they are. Logs that stay on the device can be lost or deleted, and logs without exact times are hard to match up. They come from the junos-logging policy template.

Every example on this page was checked with rConfig Pro's policy engine on

Each of the 10 configs below was run through rConfig Pro’s evaluator with the rule above it, and gave the result shown. The configs are sanitised excerpts of the sample configs that come with the template.

All the rules come from junos-logging.policy in the policy templates (v1.5.0). Import the whole file with Import Templates (see importing a policy template), or copy one rule into your own definition. The Juniper Junos templates page lists the file’s known limitations. Run the rules against show configuration | display set.

Rule Method Since
Remote syslog for all messages must_match_regex 8.0.0
Remote syslog for login messages must_match_regex 8.0.0
Millisecond timestamps must_match_regex 8.0.0
No console logging must_not_match_regex 8.0.2
Time zone is UTC must_not_match_regex 8.0.2

Remote syslog for all messages

A copy of the logs off the device survives a reboot, and an attacker on the device cannot delete it. This rule needs a set system syslog host line that sends any facility at info or notice.

Definition
// A remote syslog host receives any facility at info or notice (set system syslog host ... any info or any notice)
#[must_match_regex]
/^set system syslog host \S+ any (info|notice)$/m
passPassing config: Hardened EX2300 sample (Junos 23.2, synthetic)
set system syslog host 192.0.2.50 any notice
set system syslog host 192.0.2.50 authorization info
set system syslog file messages any notice
set system syslog time-format millisecond

Why: All messages at notice and above go to 192.0.2.50.

failFailing config: Unhardened EX2300 sample (Junos 15.1, synthetic)
set system syslog console any notice
set system syslog file messages any notice
set system syslog file messages authorization info

Why: Logs go to the console and a local file, but not to a remote host.

Expected result in rConfig, with this rule as the only rule in a definition:

ConfigRule resultOverall result
Passing configpassPASS
Failing configfailFAIL

Framework mapping. The rule provides evidence towards these controls. It does not certify anything.

Framework Reference
NIST SP 800-53 AU-2, AU-12
NIST CSF 1.1 DE.CM-1
HIPAA (45 CFR) 164.312(b)
ISO/IEC 27001:2022 Annex A A.8.15

Tested with: sample excerpts from Junos 15.1 (synthetic) and Junos 23.2 (synthetic). Minimum rConfig 8.0.0 (must_match_regex). Editions: Pro, Vector, Enterprise.


Remote syslog for login messages

Authorisation messages record who logged in and what they were allowed to do. This rule needs a remote host that gets the authorization facility at info or any.

Definition
// A remote syslog host receives authorization messages at info or any (set system syslog host ... authorization info)
#[must_match_regex]
/^set system syslog host \S+ authorization (info|any)$/m
passPassing config: Hardened EX2300 sample (Junos 23.2, synthetic)
set system syslog host 192.0.2.50 any notice
set system syslog host 192.0.2.50 authorization info
set system syslog file messages any notice

Why: Authorisation messages go to 192.0.2.50.

failFailing config: Unhardened EX2300 sample (Junos 15.1, synthetic)
set system syslog console any notice
set system syslog file messages any notice
set system syslog file messages authorization info

Why: Authorisation messages only go to a local file.

Expected result in rConfig, with this rule as the only rule in a definition:

ConfigRule resultOverall result
Passing configpassPASS
Failing configfailFAIL

Framework mapping. The rule provides evidence towards these controls. It does not certify anything.

Framework Reference
NIST SP 800-53 AU-2, AU-12
HIPAA (45 CFR) 164.312(b)
ISO/IEC 27001:2022 Annex A A.8.15

Tested with: sample excerpts from Junos 15.1 (synthetic) and Junos 23.2 (synthetic). Minimum rConfig 8.0.0 (must_match_regex). Editions: Pro, Vector, Enterprise.


Millisecond timestamps

Timestamps with milliseconds let you put events from many devices in the right order. This rule needs set system syslog time-format millisecond, with or without year.

Definition
// Syslog timestamps include milliseconds (set system syslog time-format millisecond)
#[must_match_regex]
/^set system syslog time-format (year )?millisecond$/m
passPassing config: Hardened EX2300 sample (Junos 23.2, synthetic)
set system syslog file messages any notice
set system syslog time-format millisecond

Why: Timestamps include milliseconds.

failFailing config: Unhardened EX2300 sample (Junos 15.1, synthetic)
set system syslog console any notice
set system syslog file messages any notice

Why: There is no time-format line.

Expected result in rConfig, with this rule as the only rule in a definition:

ConfigRule resultOverall result
Passing configpassPASS
Failing configfailFAIL

Framework mapping. The rule provides evidence towards these controls. It does not certify anything.

Framework Reference
NIST SP 800-53 AU-2, AU-12
HIPAA (45 CFR) 164.312(b)
ISO/IEC 27001:2022 Annex A A.8.15

Tested with: sample excerpts from Junos 15.1 (synthetic) and Junos 23.2 (synthetic). Minimum rConfig 8.0.0 (must_match_regex). Editions: Pro, Vector, Enterprise.


No console logging

Log messages on the console slow the device down when there are many, and nobody is usually watching. This rule fails on any set system syslog console line.

Definition
// Console logging is off (fails on set system syslog console)
#[must_not_match_regex]
/^set system syslog console /m
passPassing config: Hardened EX2300 sample (Junos 23.2, synthetic)
set system syslog host 192.0.2.50 any notice
set system syslog file messages any notice

Why: There is no syslog console line.

failFailing config: Unhardened EX2300 sample (Junos 15.1, synthetic)
set system syslog console any notice
set system syslog file messages any notice

Why: Messages are sent to the console.

Expected result in rConfig, with this rule as the only rule in a definition:

ConfigRule resultOverall result
Passing configpassPASS
Failing configfailFAIL

Framework mapping. The rule provides evidence towards these controls. It does not certify anything.

Framework Reference
HIPAA (45 CFR) 164.312(b)

Tested with: sample excerpts from Junos 15.1 (synthetic) and Junos 23.2 (synthetic). Minimum rConfig 8.0.2 (must_not_match_regex). Editions: Pro, Vector, Enterprise.


Time zone is UTC

If every device uses UTC, log times line up wherever the devices are. UTC is the default, so a config with no time-zone line passes. Any other time zone fails.

Definition
// The system time zone is UTC (fails on a set system time-zone line other than UTC, the default)
#[must_not_match_regex]
/^set system time-zone (?!UTC$)/m
passPassing config: Hardened EX2300 sample (Junos 23.2, synthetic)
set system host-name br-gwy-sw01
set system time-zone UTC

Why: The time zone is UTC.

failFailing config: Unhardened EX2300 sample (Junos 15.1, synthetic)
set system host-name br-gwy-sw02
set system time-zone Europe/Dublin

Why: Europe/Dublin is not UTC.

Expected result in rConfig, with this rule as the only rule in a definition:

ConfigRule resultOverall result
Passing configpassPASS
Failing configfailFAIL

Framework mapping. The rule provides evidence towards these controls. It does not certify anything.

Framework Reference
None recorded See Compliance frameworks

Tested with: sample excerpts from Junos 15.1 (synthetic) and Junos 23.2 (synthetic). Minimum rConfig 8.0.2 (must_not_match_regex). Editions: Pro, Vector, Enterprise.


Type to search.