Agenda: exercises-snmp-v1-v2c.txt

File exercises-snmp-v1-v2c.txt, 7.4 KB (added by sysadmin, 6 years ago)
Line 
1SNMP exercises, part I
2======================
3
4Note: many of the commands in this exercise do not have to be run as root,
5but it is safe to run them all as root. So it's simpler if you start a
6root shell and enter them all there. You can start a root shell like this:
7
8    $ sudo bash
9
100. Installing client tools
11--------------------------
12
13    # apt-get install snmp
14    # apt-get install snmp-mibs-downloader
15
16The second of the two commands downloads the standard IETF and IANA
17SNMP MIBs which are not included by default.
18
19Note: for this to work, you must enable the "multiverse" source in your
20APT configuration, if you are using Ubuntu 12.04. This has already been
21done for you here.
22
23
24Now, edit the file /etc/snmp/snmp.conf
25
26    Change this line:
27       
28        mibs :
29       
30    ... so that it looks like:
31
32        # mibs :
33
34        (You are "commenting out" the mibs statement, which is telling the
35        snmp* tools to automatically load the mibs downloaded into the
36        /usr/share/mibs/ directory).
37
38
391. Configure SNMP on Your Router
40--------------------------------
41
42For this exercise you need to work in groups. Assign one person to type on
43the keyboard.
44
45If you are unsure of what group you are in refer to the Network Diagram on the
46classroom wiki by going to http://noc.ws.nsrc.org/ and clicking on the Network
47Diagram link.
48
49Now connect to your router:
50
51        $ ssh cisco@rtrN.ws.nsrc.org    (or "ssh cisco@10.10.N.254")
52       
53        username: cisco
54        password: <CLASS PASSWORD>
55
56        rtrN> enable
57        Password: <CLASS PASSWORD>
58        rtrN# configure terminal                        (conf t)
59       
60Now we need to add an Access Control List rule for SNMP access, turn on SNMP, assign
61a read-only SNMP community string and tell the router to maintain SNMP information
62across reboots. To do this we do:
63
64        rtrN(config)# access-list 99 permit 10.10.0.0 0.0.255.255
65        rtrN(config)# snmp-server community NetManage ro 99
66        rtrN(config)# snmp-server ifindex persist
67       
68Now let's exit and save this new configuration to the routers permanent config.
69
70        rtrN(config)# exit
71        rtrN# write memory                                      (wr mem)
72        rtrN# exit                                              (until you return to your pc)
73       
74Now to see if your changes are working.
75
76
772. Testing SNMP
78---------------
79
80To control that your SNMP installation works, run the
81snmpstatus command on each of the following devices
82
83    $ snmpstatus -c 'NetManage' -v2c <IP_ADDRESS>
84
85Where <IP_ADDRESS> is each of the following:
86
87    * The NOC server:       10.10.0.254
88    * Your group's router:  10.10.N.254
89    * The access point:    10.10.0.251
90   
91What happens if you try using the wrong community string (i.e. change
92'NetManage' to something else?)
93
94
953. SNMP Walk and OIDs
96---------------------
97
98Now, you are going to use the 'snmpwalk' command, part of the
99SNMP toolkit, to list the tables associated with the OIDs listed
100below, on each piece of equipment you tried above:
101
102    .1.3.6.1.2.1.2.2.1.2
103    .1.3.6.1.2.1.31.1.1.1.18
104    .1.3.6.1.4.1.9.9.13.1
105    .1.3.6.1.2.1.25.2.3.1
106    .1.3.6.1.2.1.25.4.2.1
107
108You will try this with two forms of the 'snmpwalk' command:
109
110    $ snmpwalk -c 'NetManage' -v2c <IP_ADDRESS> <OID>
111
112and
113
114    $ snmpwalk -On -c 'NetManage' -v2c <IP_ADDRESS> <OID>
115
116... where OID is one of the OIDs listed above: .1.3.6...
117
118...where IP_ADDRESS can be your group's router...
119
120Note: the "-On" option turns on numerical output, i.e.: no translation
121of the OID <-> MIB object takes place.
122
123For these OIDs:
124
125a) Do all the devices answer ?
126b) Do you notice anything important about the OID on the output ?
127
1284. Configuration of snmpd on your PC
129-------------------------------------
130
131For this exercise your group needs to verify that the snmpd service is running and
132responding to queries for all machines in your group. First enable snmpd on your machine,
133then test if your machine is responding, then check each machine of your other group
134members.
135
136* Install the SNMP agent (daemon)
137
138        # apt-get install snmpd
139
140* Configuration.
141
142We will make a backup of the distributed config, and then we will
143create our own:
144
145        # cd /etc/snmp
146        # mv snmpd.conf snmpd.conf.dist
147        # editor snmpd.conf
148
149Then, copy/paste the following (do not include the -- cut here -- lines)
150
151-- cut here -------------------------
152
153#  Listen for connections on all interfaces (both IPv4 *and* IPv6)
154agentAddress udp:161,udp6:[::1]:161
155
156# Configure Read-Only community and restrict who can connect
157rocommunity NetManage  10.10.0.0/16
158rocommunity NetManage  127.0.0.1
159
160# Information about this host
161sysLocation    NSRC Network Management Workshop
162sysContact     sysadm@pcX.ws.nsrc.org
163
164# Which OSI layers are active in this host
165# (Application + End-to-End layers)
166sysServices    72
167
168-- cut here -------------------------
169
170Now save and exit from the editor.
171
172* Restart snmpd
173
174        # service snmpd restart
175
1765. Check that snmpd is working:
177-------------------------------
178
179    $ snmpstatus -c 'NetManage' -v2c localhost
180
181What do you observe ?
182
1836. Test your neighbors
184----------------------
185
186Check now that you can run snmpstatus against your other group members servers:
187
188    $ snmpstatus -c 'NetManage' -v2c pcN.ws.nsrc.org
189   
190For instance, in group 4, you should verify against:
191
192        pc17.ws.nsrc.org
193        pc18.ws.nsrc.org
194        pc19.ws.nsrc.org
195        pc20.ws.nsrc.org
196
197
1987. Adding MIBs
199--------------
200
201Remember when you ran:
202
203    $ snmpwalk -c 'NetManage' -v2c 10.10.X.254  .1.3.6.1.4.1.9.9.13.1
204
205If you noticed, the SNMP client (snmpwalk) couldn't interpret
206all the OIDs coming back from the Agent:
207
208    SNMPv2-SMI::enterprises.9.9.13.1.3.1.2.1 = STRING: "chassis"
209    SNMPv2-SMI::enterprises.9.9.13.1.3.1.6.1 = INTEGER: 1
210
211What is '9.9.13.1.3.1' ?
212
213To be able to interpret this information, we need to download extra MIBs:
214
215* We will use the following MIBs (Don't download them yet!):
216
217    CISCO MIBS:
218
219        ftp://ftp.cisco.com/pub/mibs/v2/CISCO-SMI.my
220        ftp://ftp.cisco.com/pub/mibs/v2/CISCO-ENVMON-MIB.my
221
222To make it easier, we have a local mirror on http://noc.ws.nsrc.org/mibs/
223
224        # apt-get install wget
225        # cd /usr/share/mibs
226        # mkdir cisco && cd cisco
227
228        # wget http://noc.ws.nsrc.org/mibs/CISCO-ENVMON-MIB.my
229        # wget http://noc.ws.nsrc.org/mibs/CISCO-SMI.my
230
231Now we need to tell the snmp tools that we have the cisco MIBS it
232should load. So edit the file /etc/snmp/snmp.conf, and add the
233following two lines:
234
235mibdirs +/usr/share/mibs/cisco
236mibs +CISCO-ENVMON-MIB:CISCO-SMI
237
238* Save the file, quit.
239
240Now, try again:
241
242    $ snmpwalk -c 'NetManage' -v2c 10.10.X.254  .1.3.6.1.4.1.9.9.13.1
243
244What do you notice ?
245
246
2478. SNMPwalk - the rest of MIB-II
248--------------------------------
249
250Try and run snmpwalk on any hosts (routers, switches, machines) you
251have not tried yet, in the 10.10.0.X network
252
253Note the kind of information you can obtain.
254
255    $ snmpwalk -c 'NetManage' -v2c 10.10.0.X ifDescr
256    $ snmpwalk -c 'NetManage' -v2c 10.10.0.X ifTable
257    $ snmpwalk -c 'NetManage' -v2c 10.10.0.X ifAlias
258    $ snmpwalk -c 'NetManage' -v2c 10.10.0.X ifOperStatus
259    $ snmpwalk -c 'NetManage' -v2c 10.10.0.X ifAdminStatus
260    $ snmpwalk -c 'NetManage' -v2c 10.10.0.X if
261
262What do you think might be the difference between ifOperStatus and
263ifAdminStatus?
264
265Can you imagine a scenario where this could be useful ?
266
267
2689. More MIB-OID fun
269--------------------
270
271* Use SNMP to examine:
272
273    a) the running processes on your neighbor's server (hrSWRun)
274    b) the amount of free diskspace on your neighbor's server (hrStorage)
275    c) the interfaces on your neighbor's server (ifIndex, ifDescr)
276
277    Can you use short names to walk these OID tables ?
278
279* Experiment with the "snmptranslate" command, example:
280
281        $ snmptranslate .1.3.6.1.4.1.9.9.13.1
282
283* Try with various OIDs