Agenda: exercises-snmp-v1-v2c.txt

File exercises-snmp-v1-v2c.txt, 6.2 KB (added by jens, 8 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 on your pc like this:
7
8    $ sudo bash
9
101. Getting packages:
11--------------------
12
13    # apt-get install snmp snmpd       # adds both tools and agent
14
152. Testing SNMP
16---------------
17
18To control that your SNMP installation works, run the
19snmpstatus command on each of the following devices
20
21    $ snmpstatus -c 'NetManage' -v2c IP_ADDRESS
22
23Where IP_ADDRESS is the following list:
24
25    * The NOC server:       10.10.0.254
26    * Classroom routers:    10.10.1-8.254  --- these will not work yet
27    * The access points:    10.10.0.(244,245)
28
293. SNMP Walk and OIDs
30---------------------
31
32Now, you are going to use the 'snmpwalk' command, part of the
33SNMP toolkit, to list the tables associated with the OIDs listed
34below, on each piece of equipment you tried above:
35
36    .1.3.6.1.2.1.2.2.1.2
37    .1.3.6.1.2.1.31.1.1.1.18
38    .1.3.6.1.4.1.9.9.13.1
39    .1.3.6.1.2.1.25.2.3.1
40    .1.3.6.1.2.1.25.4.2.1
41
42You will try this with two forms of the 'snmpwalk' command:
43
44    $ snmpwalk     -c 'NetManage' -v2c IP_ADDRESS OID
45
46and
47
48    $ snmpwalk -On -c 'NetManage' -v2c IP_ADDRESS OID
49
50... where OID is one of the OIDs listed above: .1.3.6...
51
52Note: the "-On" option turns on numerical output, i.e.: no translation
53of the OID <-> MIB object takes place.
54
55For these OIDs:
56
57a) Do all the devices answer ?
58
59b) Do you notice anything important about the OID on the output ?
60
614. Configuration of snmp on your Cisco router
62---------------------------------------------
63
64Connect to your virtual Cisco router:
65
66    # ssh 10.10.X.254        # where X is 1-26
67
68Default login: "cisco", password "cisco", enable secret "cisco"
69
70Configure it to enable SNMP:
71
72    enable
73    conf t
74    snmp-server community NetManage ro 99
75    access-list 99 permit 10.10.0.0 0.0.255.255
76    access-list 99 permit 10.10.254.0 0.0.255.255
77    exit
78    wr mem
79    exit     # until you get back to your PC
80
81Now back on your PC, test using the OIDs from section 3 above.
82
83    $ snmpwalk -c 'NetManage' -v2c 10.10.X.254 <OID>
84
85What happens if you try using the wrong community string (i.e. change
86'NetManage' to something else?)
87
885. Configuration of snmpd on your PC
89-------------------------------------
90
91* Edit the following file:
92
93        # vi /etc/snmp/snmpd.conf
94
95    Comment this line (ADD '#' in front):
96
97        com2sec paranoid  default         public
98
99    ... so that it becomes:
100
101        #com2sec paranoid  default         public
102       
103    And UNcomment the line (REMOVE the '#' in front) and change community:
104
105        #com2sec readonly  default         public
106
107    ... so that it becomes:
108
109        com2sec readonly  default         NetManage
110
111* Edit the file /etc/default/snmpd, and find the line:
112   
113        SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid 127.0.0.1'
114
115    Remove 127.0.0.1 at the end, so you have:
116
117        SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid'
118
119* Restart snmpd
120
121        # /etc/init.d/snmpd stop
122        # /etc/init.d/snmpd start
123
1246. Check that snmpd is working:
125-------------------------------
126
127    $ snmpstatus -c NetManage -v2c localhost
128
129What do you observe ?
130
1317. Test your neighbors
132----------------------
133
134Check now that you can run snmpstatus against some of your neighbor's servers:
135
136    $ snmpstatus -c NetManage -v2c 10.10.X.Y           # X = group (1-6
137                                                       # Y = PC (1-39)
138Check the Diagram: https://nsrc.org/workshops/2011/afnog-nm/wiki/Diagram
139for the listing of all cps at the bottom
140
141
1428. Adding MIBs
143--------------
144
145Remember when you ran:
146
147    $ snmpwalk -c NetManage -v2c 10.10.x.254  .1.3.6.1.4.1.9.9.13.1
148
149If you noticed, the SNMP client (snmpwalk) couldn't interpret
150all the OIDs coming back from the Agent:
151
152    SNMPv2-SMI::enterprises.9.9.13.1.3.1.2.1 = STRING: "chassis"
153    SNMPv2-SMI::enterprises.9.9.13.1.3.1.6.1 = INTEGER: 1
154
155What is '9.9.13.1.3.1' ?
156
157To be able to interpret this information, we need to download extra MIBs:
158
159* You will download the following files to your machine:
160
161        CISCO MIBS: ftp://ftp.cisco.com/pub/mibs/v2/CISCO-SMI.my
162                    ftp://ftp.cisco.com/pub/mibs/v2/CISCO-ENVMON-MIB.my
163
164    However we have a local mirror on http://noc.ws.nsrc.org/mibs/
165    which will be much faster (especially for the large HP mib bundle)
166
167        # apt-get install wget
168        # cd /usr/share/snmp/mibs
169        # wget http://noc.ws.nsrc.org/mibs/CISCO-SMI.my
170        # wget http://noc.ws.nsrc.org/mibs/CISCO-ENVMON-MIB.my
171
172* Create the file /etc/snmp/snmp.conf with your favorite editor (vi),
173  and put into it:
174
175        mibdirs /usr/share/snmp/mibs
176        mibs ALL
177
178    This tells the snmp* commands that they should load ALL mibs in the
179    mibdirs /usr/share/snmp/mibs
180   
181* Save the file, quit.
182
183Now, try again:
184
185    $ snmpwalk -c 'NetManage' -v2c 10.10.x.254  .1.3.6.1.4.1.9.9.13.1
186
187What do you notice ?
188
189
1909. SNMPwalk - the rest of MIB-II
191--------------------------------
192
193Try and run snmpwalk on any hosts (routers, switches, machines) you
194have not tried yet, in the 10.10.0.X network
195
196Note the kind of information you can obtain.
197
198    $ snmpwalk -c NetManage -v2c 10.10.0.X ifDescr
199    $ snmpwalk -c NetManage -v2c 10.10.0.X ifTable
200    $ snmpwalk -c NetManage -v2c 10.10.0.X ifAlias
201    $ snmpwalk -c NetManage -v2c 10.10.0.X ifOperStatus
202    $ snmpwalk -c NetManage -v2c 10.10.0.X ifAdminStatus
203    $ snmpwalk -c NetManage -v2c 10.10.0.X if
204
205Can you explain the difference between ifOperStatus and ifAdminStatus ?
206
207Can you imagine a scenario where this could be useful ?
208
209
210
21110. More MIB-OID fun
212--------------------
213
214* Use the OIDs from the beginning of this exercise set, and examine:
215
216        a) the running processes on your neighbor's server (hrSWRun)
217        b) the amount of free diskspace on your neighbor's server (hrStorage)
218        c) the interfaces on your neighbor's server (ifIndex, ifDescr)
219
220    Can you use short names to walk these OID tables ?
221
222* Experiment with the "snmptranslate" command, example:
223
224        $ snmptranslate .1.3.6.1.4.1.9.9.13.1.5.1.2
225
226* Try with various OIDs