Ejercicios SNMP ================================= 1.
Configurar SNMP en el router/switch ------------------------------------------En la mquina virtual instalar telnet: $ sudo apt-get update $ sudo apt-get install telnet En el equipo CISCO usando el puerto de consola proceder a configurar: Nombre de equipo: hostname equipoX Configurar usuarios y acceso mediante TELNET: enable secret 0 aDm1n56$21 user admin secret 0 ElaDm1n!231 line vty 0 4 login local Configurar direccin IP: int<tab> interface XXX ip address X.X.X.X 255.255.255.0 no shutdown Acceder mediante TELNET al equipo desde la mquina virutal $ telnet X.X.X.X username: admin password: XXXXX Configurar ACL: access-list 99 permit host X.X.X.X snmp-server community GestionRedes RO 99 snmp-server ifindex persist Valor unico que se mantiene por cada interfaz del dispositivo en los reinicios. 2. Instalar cliente y servidor SNMP -----------------------------------usuario 'root' $ sudo bash # apt-get install snmp snmpd 3. Probar las herramientas SNMP -------------------------------Para verificar que la instalacin de SNMP es correcta ejecute el comando: snmpstatus. $ snmpstatus -c 'GestionRedes' -v2c <direccion_IP> 4. SNMP: snmpwalk, snmptable, y OIDs ------------------------------------a) snmpwalk y OID: $ snmpwalk -c 'GestionRedes' -v2c <direccion_IP> .1.3.6.1.2.1.2.2.1.2 $ snmpwalk -c 'GestionRedes' -v2c <direccion_IP> ifDescr Hay alguna diferencia entre ambos resultados? Por qu? Revisar los siguientes OIDs? Qu son? .1.3.6.1.2.1.31.1.1.1.18 .1.3.6.1.4.1.9.9.13.1.3 .1.3.6.1.4.1.11.2.14.11.1.2 .1.3.6.1.2.1.25.2.3.1 .1.3.6.1.2.1.25.4.2.1 Revisar los siguientes: ifDescr ifTable ifAlias ifOperStatus ifAdminStatus if
b) Veamos la tabla de interfaces completa: $ snmpwalk -c 'GestionRedes' -v2c <direccion_IP> .1.3.6.1.2.1.2 Mejor aun, veamos la tabla de interfaces en forma de tabla: $ snmptable -c 'GestionRedes' -v2c <direccion_IP> ifTable c) Que informacion provee el siguiente comando?: $ snmptable -c 'GestionRedes' -v2c <direccion_IP> ipAddrTable Y este? $ snmptable -c 'GestionRedes' -v2c <direccion_IP> NetToMedia 5. MIBs adicionales -----------------------------------Es posible que ciertos elementos se presentaron as: SNMPv2-SMI::enterprises.9.9.13.1.3.1.2.1 = STRING: "chassis" SNMPv2-SMI::enterprises.9.9.13.1.3.1.6.1 = INTEGER: 1 o ... RFC1155-SMI::enterprises.11.2.14.11.1.2.6.1.4.1 RFC1155-SMI::enterprises.11.2.14.11.1.2.6.1.4.2 RFC1155-SMI::enterprises.11.2.14.11.1.2.6.1.4.3 RFC1155-SMI::enterprises.11.2.14.11.1.2.6.1.4.4 ... qu es o '9.9.13.1.3.1.3' ? '.11.2.14.11.1.2.6.1.4' ? = = = = INTEGER: INTEGER: INTEGER: INTEGER: 4 4 5 4
Para poder interpretar la informacin, necesitamos MIBs adicionales que provean la descripcin del fabricante o proveedor. Esto es un problema muy comn Bajar las siguientes MIBs: CISCO MIBS: ftp://ftp.cisco.com/pub/mibs/v2/CISCO-SMI.my ftp://ftp.cisco.com/pub/mibs/v2/CISCO-ENVMON-MIB.my cd /usr/share/snmp/mibs wget ftp://ftp.cisco.com/pub/mibs/v2/CISCO-SMI.my wget ftp://ftp.cisco.com/pub/mibs/v2/CISCO-ENVMON-MIB.my Crear el archivo /usr/share/snmp/snmp.conf, y agregar: mibdirs /usr/share/snmp/mibs mibs ALL Guardar y salir. Probar de nuevo: snmpwalk -c GestionRedes -v2c X.X.X.X snmpwalk -c GestionRedes -v2c X.X.X.X .1.3.6.1.4.1.9.9.13.1.3 .1.3.6.1.4.1.11.2.14.11.1.2
6. Configuracion de snmpd (agente servidor de SNMP) en su PC: --------------------------------------------------------------* Editar el fichero: # vi /etc/snmp/snmpd.conf Comentar esta lnea (Agregar '#' al principio de la lnea): com2sec paranoid default public ... que se vea as: #com2sec paranoid default public Y remover el comentario y cambiar la cadena de comunidad: #com2sec readonly default public ... que se vea asi: com2sec readonly default GestionRedes * Edite el fichero /etc/default/snmpd, y encuentre esta linea: SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid 127.0.0.1'
Remover 127.0.0.1 al final, de forma tal que se vea: SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid' * Reiniciar snmpd # /etc/init.d/snmpd stop # /etc/init.d/snmpd start 7. Comprobar que SNMP este corriendo: --------------------------------------$ snmpstatus -c GestionRedes -v2c localhost 8. Prueba los servidores vecinos --------------------------------$ snmpstatus -c GestionRedes -v2c X.X.X.X 9. Que informacin puede obtener de los siguientes comandos: ------------------------------------------------------------Este comando? $ snmptable -c GestionRedes -v2c <su_servidor> hrStorageTable y este? $ snmptable -c GestionRedes -v2c <su_servidor> hrDeviceTable 10. Un ejemplo -------------Verifique que conexiones de TCP estan establecidas con su equipo: $ snmptable -c 'GestionRedes' -v2c <direccion_IP> tcpConn Cuantas conexiones? 11. Conexiones seguras: ------------------------------------------------------------En el router configurar SSH configure terminal aaa new-model crypto key generate rsa How many bits in the modulus [512]: 2048 username cisco secret 0 cisco line vty 0 4 transport input ssh exit ip ssh logging events ip ssh version 2 Desde el equipo Linux ejecutar: ssh [email protected] Solicite de nuevo la tabla de conexiones TCP: $ snmptable -c 'GestionRedes' -v2c <direccion_IP> tcpConn Que observas? 12. Servidor TFTP -------------------------Instalar servidor TFTP en Linux: sudo apt-get install xinetd tftpd tftp Agregar la configuracin en xinetd: sudo vi /etc/xinetd.d/
Agregar: service tftp { protocol = udp port = 69 socket_type = dgram wait = yes user = nobody server = /usr/sbin/in.tftpd server_args = var/lib/tftpboot -s disable = no } Crear los directorios adecuados: sudo mkdir /var/lib/tftpboot sudo chown -R nobody:nobody /var/lib/tftpboot sudo chmo7 -R 777 /var/lib/tftpboot Si el grupo no existe hay que crearlo: sudo addgroup nobody Reiniciamos xinetd /etc/init.d/xinetd start Copiar la configuracin: copy run tftp