SNMP Exercises 1
SNMP Exercises 1
SNMP Exercises 1
Introduction
Goals
Install and learn to use the SNMP commands
Explore and identify standard vs enterprise parts of the MIB tree
Install vendor specific MIBs and use those with the SNMP commands
Notes
Commands preceded with "$" imply that you should execute the command as a
general user - not as root.
Commands preceded with "#" imply that you should be working as root.
Commands with more specific command lines (e.g. "rtrX>" or "mysql>") imply
that you are executing commands on remote equipment, or within another
program.
The second of the two commands downloads the standard IETF and IANA SNMP
MIBs which are not included by default.
Note: to find snmp-mibs-downloader, you must enable the "multiverse" source in your
APT configuration. This has already been done for you in this workshop.
(You are "commenting out" the empty mibs statement, which was telling the snmp*
tools not to automatically load the mibs in the /usr/share/mibs/ directory).
Now, in your home directory make a .snmp directory with file snmp.conf inside it,
make it readable only by you, and add the credentials to it:
$ cd
$ mkdir .snmp
$ chmod 700 .snmp/
$ editor .snmp/snmp.conf
Creating this configuration file means you won't have to enter your credentials
everytime you use one of the SNMP utilities. Otherwise you would have to add all
these values on the command line like this:
The commands to enable ssh are the same on each box, so divide the work between
your group member:
username: nmmlab
password: <CLASS PASSWORD>
DEVICE.campusY> enable
Password: <CLASS PASSWORD>
DEVICE.campusY# configure terminal (conf t)
Now we need to add an Access Control List rule for SNMP access, turn on SNMP,
assign a read-only SNMP community string as well as a SNMPv3 group and user and
tell the router to maintain SNMP information across reboots. To do this we do:
Now let's exit and save this new configuration to the routers permanent config.
DEVICE.campusY(config)# exit
DEVICE.campusY# write memory (wr mem)
DEVICE.campusY# exit (until you return to your
pc)
If you have questions about what the access-list statement is restricting ask your
instructors.
Testing SNMP
To check that your SNMP installation works, run the snmpstatus command on each of
the following devices from your server:
$ snmpstatus <IP_ADDRESS>
Where is each of the following:
* Campus border router: 100.68.Y.1
* Campus core switch: 100.68.Y.2
* Building 1 distribution switch: 172.2Y.10.2
* Building 2 distribution switch: 172.2Y.20.2
Note that you just used SNMPv3. Not all devices that implement SNMP support v3.
Try again, adding "-v2c" as a parameter. Notice that the command automatically uses
the community string in the snmp.conf file instead of the v3 user credentials. Try "-
v1". That is try:
$ snmpstatus -v2c <IP_ADDRESS>
and
$ snmpstatus -v1 <IP_ADDRESS>
What happens if you try using the wrong community string (i.e. change NetManage to
something else) using the options "-v2c -c NetWrong"?
$ snmpstatus -v2c -c NetWrong <IP_ADDRESS>
You will try this with two forms of the snmpwalk command:
$ snmpwalk -v2c <IP_ADDRESS> <OID>
and
$ snmpwalk -v2c -On <IP_ADDRESS> <OID>
Configuration
We will make a backup of the distributed config, and then we will create our own (be
sure you mv "snmpd.conf" and not "snmp.conf"):
$ cd /etc/snmp
$ sudo mv snmpd.conf snmpd.conf.dist
$ sudo editor snmpd.conf
Then, copy/paste the following (change srvX.campusY to your own server and
campus number) and replace "Y" with your campus number:
# Listen for connections on all interfaces (both IPv4 *and* IPv6)
agentAddress udp:161,udp6:[::1]:161
# For SNMPv2: Configure Read-Only community and restrict who can connect
rocommunity NetManage 100.68.100.0/24
rocommunity NetManage 100.68.Y.128/28
rocommunity NetManage 127.0.0.1
Now we will add the same SNMPv3 user to your PC. We need to stop snmpd before
adding the user, and restart it to read the above changes as well as the new user:
$ sudo systemctl stop snmpd
$ sudo net-snmp-create-v3-user -X AES -a SHA -A NetManage admin
$ sudo systemctl start snmpd
and, so on.
If you noticed, the SNMP client (snmpwalk) couldn't interpret all the OIDs coming
back from the Agent:
SNMPv2-SMI::enterprises.9.9.13.1.3.1.2.1 = STRING: "chassis"
SNMPv2-SMI::enterprises.9.9.13.1.3.1.6.1 = INTEGER: 1
What is 9.9.13.1.3.1 ?
CISCO MIBS
ftp://ftp.cisco.com/pub/mibs/v2/CISCO-SMI.my
ftp://ftp.cisco.com/pub/mibs/v2/CISCO-ENVMON-MIB.my
Now we need to tell the snmp tools that we have the cisco MIBS it should load. So
edit the file /etc/snmp/snmp.conf, and add the following two lines:
mibdirs +/usr/share/mibs/cisco
mibs +CISCO-ENVMON-MIB:CISCO-SMI
Now, try again (the example uses bdr1.campusY.ws.nsrc.org below. You can do this
whichever network device you are configuring):
$ snmpwalk 100.68.Y.1 .1.3.6.1.4.1.9.9.13.1
(Remember that with less you press space for next page, b to go back to previous
page, and q to quit)
What do you think might be the difference between ifOperStatus and ifAdminStatus?
Can you imagine a scenario where this could be useful ?