1 | SNMP exercises, part I |
---|
2 | ====================== |
---|
3 | |
---|
4 | Note: many of the commands in this exercise do not have to be run as root, |
---|
5 | but it is safe to run them all as root. So it's simpler if you start a |
---|
6 | root shell and enter them all there. You can start a root shell on your pc like this: |
---|
7 | |
---|
8 | $ sudo bash |
---|
9 | |
---|
10 | 1. Getting packages: |
---|
11 | -------------------- |
---|
12 | |
---|
13 | # apt-get install snmp snmpd # adds both tools and agent |
---|
14 | |
---|
15 | 2. Testing SNMP |
---|
16 | --------------- |
---|
17 | |
---|
18 | To control that your SNMP installation works, run the |
---|
19 | snmpstatus command on each of the following devices |
---|
20 | |
---|
21 | $ snmpstatus -c 'NetManage' -v2c IP_ADDRESS |
---|
22 | |
---|
23 | Where 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 | |
---|
29 | 3. SNMP Walk and OIDs |
---|
30 | --------------------- |
---|
31 | |
---|
32 | Now, you are going to use the 'snmpwalk' command, part of the |
---|
33 | SNMP toolkit, to list the tables associated with the OIDs listed |
---|
34 | below, 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 | |
---|
42 | You will try this with two forms of the 'snmpwalk' command: |
---|
43 | |
---|
44 | $ snmpwalk -c 'NetManage' -v2c IP_ADDRESS OID |
---|
45 | |
---|
46 | and |
---|
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 | |
---|
52 | Note: the "-On" option turns on numerical output, i.e.: no translation |
---|
53 | of the OID <-> MIB object takes place. |
---|
54 | |
---|
55 | For these OIDs: |
---|
56 | |
---|
57 | a) Do all the devices answer ? |
---|
58 | |
---|
59 | b) Do you notice anything important about the OID on the output ? |
---|
60 | |
---|
61 | 4. Configuration of snmp on your Cisco router |
---|
62 | --------------------------------------------- |
---|
63 | |
---|
64 | Connect to your virtual Cisco router: |
---|
65 | |
---|
66 | # ssh 10.10.X.254 # where X is 1-26 |
---|
67 | |
---|
68 | Default login: "cisco", password "cisco", enable secret "cisco" |
---|
69 | |
---|
70 | Configure 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 | |
---|
81 | Now back on your PC, test using the OIDs from section 3 above. |
---|
82 | |
---|
83 | $ snmpwalk -c 'NetManage' -v2c 10.10.X.254 <OID> |
---|
84 | |
---|
85 | What happens if you try using the wrong community string (i.e. change |
---|
86 | 'NetManage' to something else?) |
---|
87 | |
---|
88 | 5. 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 | |
---|
124 | 6. Check that snmpd is working: |
---|
125 | ------------------------------- |
---|
126 | |
---|
127 | $ snmpstatus -c NetManage -v2c localhost |
---|
128 | |
---|
129 | What do you observe ? |
---|
130 | |
---|
131 | 7. Test your neighbors |
---|
132 | ---------------------- |
---|
133 | |
---|
134 | Check 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) |
---|
138 | Check the Diagram: https://nsrc.org/workshops/2011/afnog-nm/wiki/Diagram |
---|
139 | for the listing of all cps at the bottom |
---|
140 | |
---|
141 | |
---|
142 | 8. Adding MIBs |
---|
143 | -------------- |
---|
144 | |
---|
145 | Remember when you ran: |
---|
146 | |
---|
147 | $ snmpwalk -c NetManage -v2c 10.10.x.254 .1.3.6.1.4.1.9.9.13.1 |
---|
148 | |
---|
149 | If you noticed, the SNMP client (snmpwalk) couldn't interpret |
---|
150 | all 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 | |
---|
155 | What is '9.9.13.1.3.1' ? |
---|
156 | |
---|
157 | To 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 | |
---|
183 | Now, try again: |
---|
184 | |
---|
185 | $ snmpwalk -c 'NetManage' -v2c 10.10.x.254 .1.3.6.1.4.1.9.9.13.1 |
---|
186 | |
---|
187 | What do you notice ? |
---|
188 | |
---|
189 | |
---|
190 | 9. SNMPwalk - the rest of MIB-II |
---|
191 | -------------------------------- |
---|
192 | |
---|
193 | Try and run snmpwalk on any hosts (routers, switches, machines) you |
---|
194 | have not tried yet, in the 10.10.0.X network |
---|
195 | |
---|
196 | Note 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 | |
---|
205 | Can you explain the difference between ifOperStatus and ifAdminStatus ? |
---|
206 | |
---|
207 | Can you imagine a scenario where this could be useful ? |
---|
208 | |
---|
209 | |
---|
210 | |
---|
211 | 10. 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 |
---|