Routelearn.net
Course menu

Course 12: IP Services on IOSLesson 2.1 (3 of 5 in this course)76 of 91 in the CCNA series

SNMP and Syslog configuration

SNMP versions and community strings vs. SNMPv3 users, traps, and sending Syslog messages to a server with the right severity.

Intermediate · 11 min read

SNMP (Simple Network Management Protocol) and Syslog are monitoring protocols. SNMP lets a management station read and change values held in a device's MIB and receive traps or informs from the device's agent; Syslog is the standard way devices send event messages, each with a severity level from 0 (emergency) to 7 (debugging), to a log server.

In simple terms: SNMP lets a central server check on every device, like reading its gauges. Syslog is each device's diary of events, sent to one place so you can read them all together.

A real-life situation

On Monday morning users say the link to the server site was slow all weekend. Nobody noticed, because nobody was logged in to R1. You want two things: a graph of the link's traffic and CPU over time, and an alert the moment an interface goes down. You also want every log message from R1, R2 and SW1 kept in one place, not lost when a router reloads. SNMP gives you the graphs and the alerts. Syslog gives you the central log. In the lab, SRV1 (192.168.20.10) runs both the monitoring software and the Syslog server.

The ideas behind both are in SNMP and Syslog. This lesson configures them on Cisco IOS.

What SNMP is

SNMP (Simple Network Management Protocol) has two sides. The manager (also called the NMS, network management station) is software on a server. The agent runs on each router and switch. The agent keeps values such as interface counters and CPU load in a MIB (Management Information Base). Each value has an OID (object identifier), a numbered path such as 1.3.6.1.2.1.1.5.0 for the device name.

MessageDirectionUsed for
Get / GetNext / GetBulkManager → agent, UDP 161Read values (GetBulk is v2c and later)
SetManager → agent, UDP 161Change a value
TrapAgent → manager, UDP 162Unrequested alert, not acknowledged
InformAgent → manager, UDP 162Unrequested alert, acknowledged (v2c and later)
Step 1 of 3 · Get
SRV1 (manager)
192.168.20.10
SNMP
polls on UDP 161, alerts on UDP 162
R1 (agent)
10.0.12.1
Polling gives the manager regular values; traps tell it about events at once.

SNMP versions

VersionWho may askSecurity
SNMPv1Anyone with the community stringClear-text community only
SNMPv2cAnyone with the community stringClear-text community; adds GetBulk and informs
SNMPv3Named users in groupsAuthentication (hash) and optional encryption

A community string is a shared password. A read-only (RO) community allows Get only; a read-write (RW) community also allows Set. SNMPv3 has three security levels:

  • noAuthNoPriv: username only (keyword noauth).
  • authNoPriv: messages are authenticated with a hash such as SHA (keyword auth).
  • authPriv: authenticated and encrypted, for example with AES (keyword priv). This is the one to use.

What Syslog is

Every Cisco device writes log messages: an interface went down, someone logged in, OSPF lost a neighbour. By default they go to the console and a memory buffer, and are lost on reload. Syslog sends a copy to a server over UDP 514. Each message looks like this:

Example output · based on Cisco documentation; exact format varies by platform and software version
*Oct  6 14:22:31.418: %LINK-3-UPDOWN: Interface GigabitEthernet0/1, changed state to down
*Oct  6 14:22:32.418: %LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/1, changed state to down
Timestamp, then %FACILITY-SEVERITY-MNEMONIC, then the text. LINK is the facility (the part of IOS that produced it), 3 is the severity, UPDOWN a short code. The leading * means the clock is not synchronised: configure NTP.

Severity runs from 0 (worst) to 7. When you choose a level, you get that level and every lower number.

LevelNameIOS keywordMeaning
0EmergencyemergenciesThe system is unusable
1AlertalertsAct immediately
2CriticalcriticalCritical condition, such as a hardware fault
3ErrorerrorsError condition, e.g. %LINK-3-UPDOWN
4WarningwarningsSomething may go wrong
5NoticenotificationsNormal but important, e.g. %LINEPROTO-5-UPDOWN
6InformationalinformationalNormal information, e.g. an ACL log entry
7DebugdebuggingOutput of debug commands

A memory aid for the order 0 to 7: "Every Awesome Cisco Engineer Will Need Ice cream Daily".

Why it works that way

SNMP polling and traps solve different problems. Polling every few minutes builds history (graphs, trends) but is slow to notice a failure. Traps are instant but say nothing about normal behaviour. Most networks use both. Syslog is plain text and easy for people to read and search, which is why it is used for events, while SNMP is better for numbers.

Both use UDP. A device that is losing a link can still fire off a message without setting up a connection. The price is that a message can be lost, which is why informs exist and why logs are also kept in the local buffer.

How it works step by step

Gi0/2 .2.1Gi0/0 .1192.168.10.0/24Gi0/1 .1.2 Gi0/010.0.12.0/30Gi0/1 .1192.168.20.0/24InternetNTP 198.51.100.10R1HQ edgeSW1mgmt 192.168.10.2PC1VLAN 10, DHCP clientR2server siteSRV1192.168.20.10
  1. 1. SRV1 polls R1 every 5 minutes. It reads interface counters and CPU with SNMPv3 and draws graphs.
  2. 2. R1 answers. R1 only answers SRV1, because an ACL limits who may use SNMP.
  3. 3. Log messages flow to SRV1. R1 and SW1 send every message at informational (6) or more serious to the Syslog server.
  4. 4. A trap when something breaks. When Gi0/2 to the internet goes down, R1 sends a linkDown trap at once.

How to configure SNMP on Cisco IOS

⚠️ Based on Cisco IOS / IOS XE documentation, not run on a lab device. Community strings and passwords here are examples; never use "public" or "private".

SNMPv2c

access-list 10 permit host 192.168.20.10 snmp-server community Lab-R0-Str1ng RO 10 snmp-server location HQ rack 2 snmp-server contact noc@example.com

A read-only community that only SRV1 may use (ACL 10). Add RW instead of RO only if the manager must change settings.

snmp-server enable traps snmp-server host 192.168.20.10 version 2c Lab-R0-Str1ng

Turn on traps and say where to send them. Add the informs keyword after the address to send acknowledged informs instead.

SNMPv3

snmp-server group NMS-GROUP v3 priv access 10 snmp-server user nmsadmin NMS-GROUP v3 auth sha Auth-Pass-123 priv aes 128 Priv-Pass-456 snmp-server host 192.168.20.10 version 3 priv nmsadmin snmp-server enable traps

A group at the authPriv level, a user in it with SHA authentication and AES-128 encryption, and SRV1 as the trap receiver using that user.

How to configure Syslog on Cisco IOS

service timestamps log datetime msec localtime show-timezone service sequence-numbers logging host 192.168.20.10 logging trap informational logging source-interface GigabitEthernet0/1

Send severity 0-6 to SRV1 from Gi0/1's address, with exact timestamps and numbered messages. informational is already the default trap level.

logging console warnings logging buffered 16384 debugging logging monitor informational

Other places logs go: the console (show only 0-4 there, so it stays readable), the memory buffer (16 KB, everything), and SSH/Telnet sessions.

terminal monitor

Privileged EXEC, per session. Without it, you won't see log messages while connected over SSH, even with logging monitor set.

Full example (R1)

service timestamps log datetime msec localtime show-timezone service sequence-numbers ! access-list 10 permit host 192.168.20.10 ! snmp-server group NMS-GROUP v3 priv access 10 snmp-server user nmsadmin NMS-GROUP v3 auth sha Auth-Pass-123 priv aes 128 Priv-Pass-456 snmp-server location HQ rack 2 snmp-server contact noc@example.com snmp-server enable traps snmp-server host 192.168.20.10 version 3 priv nmsadmin ! logging buffered 16384 debugging logging console warnings logging source-interface GigabitEthernet0/1 logging trap informational logging host 192.168.20.10

How to verify it

Example output · based on Cisco documentation; exact format varies by platform and software version
R1#show logging
Syslog logging: enabled (0 messages dropped, 0 messages rate-limited, 0 flushes, 0 overruns, xml disabled, filtering disabled)
...
    Console logging: level warnings, 14 messages logged, xml disabled,
                     filtering disabled
    Monitor logging: level informational, 0 messages logged, xml disabled,
                     filtering disabled
    Buffer logging:  level debugging, 52 messages logged, xml disabled,
                    filtering disabled
...
    Trap logging: level informational, 56 message lines logged
        Logging to 192.168.20.10  (udp port 514, audit disabled,
              link up),
              56 message lines logged,
...
Log Buffer (16384 bytes):

000049: Oct  6 14:22:31.418 CET: %LINK-3-UPDOWN: Interface GigabitEthernet0/1, changed state to down
Check each destination's level, that Logging to 192.168.20.10 is listed with udp port 514, and read recent messages in the buffer at the bottom. The number in front is the sequence number.
Example output · based on Cisco documentation; exact format varies by platform and software version
R1#show snmp user
User name: nmsadmin
Engine ID: 800000090300AABBCC000100
storage-type: nonvolatile        active
Authentication Protocol: SHA
Privacy Protocol: AES128
Group-name: NMS-GROUP
The v3 user exists with SHA and AES-128. This is the only way to see it, because v3 users are not shown in the running config.
Example output · based on Cisco documentation; exact format varies by platform and software version
R1#show snmp host
Notification host: 192.168.20.10	udp-port: 162	type: trap
user: nmsadmin	security model: v3 priv
Traps go to SRV1 on UDP 162 using the v3 user at the priv level.

show snmp shows packet counters, such as how many requests arrived with a bad community name, which is a quick way to spot a mismatch.

What goes wrong and how to troubleshoot it

  • The manager can't poll the device. The community or v3 password differs, the ACL on the community or group doesn't permit the manager's address, or a firewall blocks UDP 161. show snmp counters for "bad community names" point to the first.
  • No traps arrive. snmp-server enable traps or snmp-server host is missing, or UDP 162 is blocked on the way.
  • The Syslog server sees nothing. Check show logging for the host line, ping the server from the source interface, and look for ACLs blocking UDP 514.
  • Important messages are missing. The trap level is set too low a number. logging trap errors (3) drops the %LINEPROTO-5 messages.
  • Timestamps don't line up between devices. NTP is not configured or not synchronised.

Common mistakes

  • Thinking a higher severity number means more serious. 0 is the worst; 7 is debug.
  • Forgetting that a level includes every lower number: logging trap 4 sends 0 to 4.
  • Using an RW community without an ACL, or the defaults "public" and "private".
  • Wondering why logs don't appear over SSH: terminal monitor is needed in each session.
  • Mixing up the ports: SNMP polls on UDP 161, traps on UDP 162, Syslog on UDP 514.

💡 Exam tip: the CCNA asks you to explain SNMP and to describe the use of Syslog features including facilities and levels. Memorise the eight severity names in order, and that choosing a level includes all lower numbers. Know Get/Set/Trap/Inform, which versions use communities and which use users, and that only v3 encrypts. Ports 161, 162 and 514 come up often.

Key takeaways

  • SNMP: the manager polls the agent (UDP 161); the agent sends traps or informs (UDP 162).
  • v1 and v2c use clear-text community strings (RO/RW); v3 uses users with auth and priv.
  • Syslog sends log messages to a server on UDP 514; format %FACILITY-SEVERITY-MNEMONIC.
  • Severities 0 (emergencies) to 7 (debugging); a configured level includes all more serious ones.
  • Configure with logging host and logging trap; verify with show logging.

Check yourself

Predict · scenario 1

R1 has 'logging trap warnings'. A %LINEPROTO-5-UPDOWN message is generated. Does it reach the Syslog server?

Predict · scenario 2

Which SNMPv3 security level both authenticates and encrypts messages?

Predict · scenario 3

An interface fails and the agent should tell the manager, and keep resending until the manager confirms it got the message. What does the agent send?

Predict · scenario 4

You are connected to R1 over SSH and generate a debug, but see no output. logging monitor is set to debugging. What is missing?

Predict · scenario 5

Which port does an SNMP manager send Get requests to on the agent?

FAQ

What is the difference between an SNMP trap and an inform?
Both are messages the agent sends to the manager on its own when something happens. A trap is sent once and never acknowledged, so if it is lost nobody knows. An inform (SNMPv2c and v3) must be acknowledged by the manager; the agent resends it until it is. Informs are more reliable but use more memory on the device.
If I set logging trap warnings, which messages go to the Syslog server?
Severity 4 (warnings) and everything more serious: levels 0 to 4. The level you choose and all lower numbers are sent. Informational (6) and debugging (7) messages are not.
Why are SNMPv2c community strings considered insecure?
They are sent in clear text in every request, so anyone who captures a packet learns the password. A read-write community also lets that person change the configuration. SNMPv3 fixes this with usernames, authentication (a hash) and optional encryption.
Why don't I see my SNMPv3 user in the running configuration?
Cisco IOS stores SNMPv3 users separately and doesn't show them in show running-config, because the passwords are turned into keys. Use show snmp user to check them.