| 120 | Install the net-snmp tools: |
| 121 | {{{ |
| 122 | $ sudo apt-get install snmp |
| 123 | $ sudo apt-get install snmp-mibs-downloader |
| 124 | }}} |
| 125 | The second of the two commands downloads the standard IETF and IANA SNMP MIBs which are not included by default. |
| 126 | |
| 127 | Now, edit the file /etc/snmp/snmp.conf: |
| 128 | {{{ |
| 129 | $ sudo vi /etc/snmp/snmp.conf |
| 130 | }}} |
| 131 | Note: Here we are using '''vi''' editor. You can use any text editor you are familiar with |
| 132 | |
| 133 | Change this line: |
| 134 | {{{ |
| 135 | mibs : |
| 136 | }}} |
| 137 | |
| 138 | so that it looks like: |
| 139 | {{{ |
| 140 | # mibs : |
| 141 | }}} |
| 142 | |
| 143 | (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) |
| 144 | |
| 145 | Now, in your home directory make a .snmp directory with file snmp.conf inside it, make it readable only be you, and add the credentials to it: |
| 146 | {{{ |
| 147 | $ cd |
| 148 | $ mkdir .snmp |
| 149 | $ chmod 700 .snmp/ |
| 150 | $ editor .snmp/snmp.conf |
| 151 | }}} |
| 152 | |
| 153 | Put the following contents in the file: |
| 154 | {{{ |
| 155 | defVersion 3 |
| 156 | defSecurityLevel authNoPriv |
| 157 | defSecurityName admin |
| 158 | defAuthPassphrase <class passowrd> |
| 159 | defAuthType SHA |
| 160 | |
| 161 | # Default community when using SNMP v2c |
| 162 | defCommunity NetManage |
| 163 | }}} |
| 164 | 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: |
| 165 | {{{ |
| 166 | snmpstatus -v3 -l authNoPriv -a SHA -u admin -A NetManage pcX |
| 167 | }}} |
| 168 | |
| 169 | === Configure SNMP on Your Router/Switch (Already Done) === |
| 170 | |
| 171 | connect to your router and go to configure mode. |
| 172 | {{{ |
| 173 | Router> enable |
| 174 | |
| 175 | Router# configure terminal |
| 176 | }}} |
| 177 | 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: |
| 178 | {{{ |
| 179 | Router(config)# access-list 99 permit 192.248.6.0 255.255.255.0 |
| 180 | Router(config)# snmp-server community NetManage ro 99 |
| 181 | Router(config)# snmp-server group ReadGroup v3 auth access 99 |
| 182 | Router(config)# snmp-server user admin ReadGroup v3 auth sha <Class Password> |
| 183 | Router(config)# snmp-server ifindex persist |
| 184 | Now let's exit and save this new configuration to the routers permanent config. |
| 185 | |
| 186 | Router(config)# exit |
| 187 | Router# write memory |
| 188 | Router# exit |
| 189 | }}} |
| 190 | Now to see if your changes are working. |
| 191 | |
| 192 | === Testing SNMP === |
| 193 | |
| 194 | To check that your SNMP installation works, run the snmpstatus command on each of the following devices |
| 195 | {{{ |
| 196 | $ snmpstatus <IP_ADDRESS> |
| 197 | }}} |
| 198 | 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". |
| 199 | |
| 200 | === SNMP Walk and OIDs === |
| 201 | |
| 202 | Now, you are going to use the snmpwalk command, part of the SNMP toolkit, to list the tables associated with the OIDs listed below, on each piece of equipment you tried above: |
| 203 | |
| 204 | OID |
| 205 | {{{ |
| 206 | |
| 207 | }}} |
| 208 | You will try this with two forms of the snmpwalk command: |
| 209 | {{{ |
| 210 | $ snmpwalk <IP_ADDRESS> <OID> |
| 211 | }}} |
| 212 | |
| 213 | and |
| 214 | {{{ |
| 215 | $ snmpwalk -On <IP_ADDRESS> <OID> |
| 216 | }}} |
| 217 | |
| 218 | example : |