Agenda: exercises-snmp-v1-v2c.txt

File exercises-snmp-v1-v2c.txt, 8.0 KB (added by kiwibrew, 5 years ago)

SNMP v1 and v2c Exercises

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