Introduction à net-snmp Dimitri FOSSIER INPG/ESISAR.

27
Introduction à net- snmp Dimitri FOSSIER INPG/ESISAR

Transcript of Introduction à net-snmp Dimitri FOSSIER INPG/ESISAR.

Page 1: Introduction à net-snmp Dimitri FOSSIER INPG/ESISAR.

Introduction à net-snmp

Dimitri FOSSIERINPG/ESISAR

Page 2: Introduction à net-snmp Dimitri FOSSIER INPG/ESISAR.

Net-snmp : bref historique

Ex ucd-snmp (version 4.x et précédentes) UCD : University of California at

Davis SNMP

Actuellement : Dev :   Net-SNMP 5.1.pre3 (29/10) Stable : Net-SNMP 5.0.9 (06/09)

Page 3: Introduction à net-snmp Dimitri FOSSIER INPG/ESISAR.

Net-snmp : qu’est ce que c’est ?

Des outils en rapport avec SNMP : Un agent évolutif Une bibliothèque SNMP Des outils pour interroger/mettre à

jour des agents SNMP Des outils pour générer/gérer les

traps Un navigateur MIB : tkmib

Page 4: Introduction à net-snmp Dimitri FOSSIER INPG/ESISAR.

Net-snmp : installation (1)

Soit avec les packages debian apt-get install …

Soit en compilant les dernières sources : ./configure make make install

Page 5: Introduction à net-snmp Dimitri FOSSIER INPG/ESISAR.

Net-snmp : installation (2)

Répondre aux questions : sysContact sysLocation …

Installation dans /usr/local par défaut.

Page 6: Introduction à net-snmp Dimitri FOSSIER INPG/ESISAR.

Net-snmp : répertoires, fichiers

Par défaut dans /usr/local /usr/local/sbin/snmpd : démon snmp

/usr/local/share/snmp : fichiers de configuration, eg : snmpd.conf, snmp.conf

/usr/local/share/snmp/mibs : lieu de stockage des mibs

Page 7: Introduction à net-snmp Dimitri FOSSIER INPG/ESISAR.

Net-snmp : les commandes

snmptranslate : traduire un OID sous une forme vers une autre (Texte->Num ..) Aide au parcours de l’arbre MIB snmpget : recevoir des informations snmpgetnext : recevoir des informations dont on ne connaît pas l’index snmpwalk : plusieurs informations à la fois snmptable : afficher une table snmp. snmpset : opération d’écriture. snmptrap : envoi/réception de traps (alertes)

Page 8: Introduction à net-snmp Dimitri FOSSIER INPG/ESISAR.

Net-snmp : exemples (1)

snmptranslate -On .1.3.6.1.2.1.1.3.0 system.sysUpTime.0

snmpget 192.168.130.29 public system.sysUpTime.0 system.sysUpTime.0 = Timeticks: (586731977) 67 days, 21:48:39.77

Page 9: Introduction à net-snmp Dimitri FOSSIER INPG/ESISAR.

Net-snmp : exemples (2)

snmpgetnext 192.168.130.29 public system.sysUpTime.0 system.sysContact.0 = « [email protected] »

snmptable 192.168.130.29 public sysORTable

->Table contenant des informations plus lisibles en retour par rapport à une commande snmpwalk

Page 10: Introduction à net-snmp Dimitri FOSSIER INPG/ESISAR.

Net-snmp : exemples (3)

snmpset 192.168.130.29 public system.sysContact.0 s « [email protected] » system.sysContact.0 = « [email protected] »

Page 11: Introduction à net-snmp Dimitri FOSSIER INPG/ESISAR.

Net-snmp : exemples (4)

snmpwalk 192.168.130.29 public system Interrogation routeur cisco salle

TP« Ethereal »

Page 12: Introduction à net-snmp Dimitri FOSSIER INPG/ESISAR.

Net-snmp : réponse interrogation du routeur

system.sysDescr.0 = Cisco Internetwork Operating System Software IOS (tm) C1700 Software (C1700-Y-M), Version 12.2(8)T1, RELEASE SOFTWARE (fc2)TAC Support: http://www.cisco.com/tacCopyright (c) 1986-2002 by cisco Systems, Inc.Compiled Sat 30-Mar-02 13:54 by ccaisystem.sysObjectID.0 = OID: enterprises.9.1.444system.sysUpTime.0 = Timeticks: (25822424) 2 days, 23:43:44.24system.sysContact.0 = system.sysName.0 = berlinsystem.sysLocation.0 = system.sysServices.0 = 78system.sysORLastChange.0 = Timeticks: (0) 0:00:00.00

Page 13: Introduction à net-snmp Dimitri FOSSIER INPG/ESISAR.

Interroger le routeur Cisco…

il faut : Rajouter les MIBS cisco sur le manager :

ftp://ftp.cisco.com/pub/mibs/ /usr/local/share/mibs ou ~/.snmp/mibs export MIBS=+MY-MIBou echo "mibs +MY-MIB" >>

$HOME/.snmp/snmp.conf

Page 14: Introduction à net-snmp Dimitri FOSSIER INPG/ESISAR.

Interroger le routeur Cisco

Configurer le routeur pour pouvoir l’interroger - exemple : enable conf t snmp-server host mon_IP snmp-server enable traps snmp

authentification linkdown linkup coldstart

snmp-server community public RO

Page 15: Introduction à net-snmp Dimitri FOSSIER INPG/ESISAR.

Net-snmp : l’interface tkmib

En tcl/tk et Perl

Page 16: Introduction à net-snmp Dimitri FOSSIER INPG/ESISAR.

Faire évoluer l’agent (1)

Principe: Rajouter des modules pour supporter une nouvelle MIBTrois fichiers nécessaires pour implémenter le module Un fichier de définition de la MIB (pour

l’application externe de gestion du réseau)

Un fichier header C Un fichier source C

Page 17: Introduction à net-snmp Dimitri FOSSIER INPG/ESISAR.

Faire évoluer l’agent (2)

Deux solutions, soit: Ecrire les trois fichiers à la main Ecrire le fichier de définition de la MIB

et utiliser l’outil « mib2c » pour générer les fichiers C.

Page 18: Introduction à net-snmp Dimitri FOSSIER INPG/ESISAR.

Exercice supplémentaire

Analyse d’une trame

Page 19: Introduction à net-snmp Dimitri FOSSIER INPG/ESISAR.

La source

00 00

00 00 A3 E0 53 16 00 A0 24 70 C2 B7 08 00 45 00

00 10

00 45 1A 03 00 00 1E 11 72 8B C0 09 C8 02 C0 09

00 20

C8 04 04 00 00 A1 00 31 7E 18 30 27 02 01 00 04

00 30

06 70 75 62 6C 69 63 A0 1A 02 02 0F A4 02 01 00

00 40

02 01 00 30 0E 30 0C 06 08 2B 06 01 02 01 01 03

00 50

00 05 00 00 0A 00 7E

Page 20: Introduction à net-snmp Dimitri FOSSIER INPG/ESISAR.

La source (suite)

00 00

00 00 43 E0 53 16 00 A0 24 70 C2 B7 08 00 45 00

00 10

00 45 1A 03 00 00 1E 11 72 8B C0 09 C8 02 C0 09

00 20

C8 04 04 00 00 A1 00 31 7E 18 30 27 02 01 00 04

00 30

06 70 75 62 6C 69 63 A0 1A 02 02 0F A4 02 01 00

00 40

02 01 00 30 0E 30 0C 06 08 2B 06 01 02 01 01 03

00 50

00 05 00 00 0A 00 7E

Page 21: Introduction à net-snmp Dimitri FOSSIER INPG/ESISAR.

Séquence

30 27 27 = 39 octets

Page 22: Introduction à net-snmp Dimitri FOSSIER INPG/ESISAR.

Séquence

30 27 27 = 39 octets

Entier 02 01 : 00

Page 23: Introduction à net-snmp Dimitri FOSSIER INPG/ESISAR.

Séquence

30

27 27 = 39 octets

Entier 02 01 : 00

Caractère

04 06 : 70 75 62 6C 69 63

P U B L I C

Header

Page 24: Introduction à net-snmp Dimitri FOSSIER INPG/ESISAR.

Séquence

30 27 27 = 39 octets

Entier 02 01 : 00

Caractère

04 06 : 70 75 62 6C 69 63

P U B L I C

Séquence

A0A0 = 1010 0000 (Get

Request)

1A 1A = 26 octets

PDU

Page 25: Introduction à net-snmp Dimitri FOSSIER INPG/ESISAR.

Séquence

30

27 27 = 39 octets

Entier 02 01 : 00

Caractère

04 06 : 70 75 62 6C 69 63

P U B L I C

Séquence

A0A0 = 1010 0000 (Get

Request)

1A 1A = 26 octets

Entier 02 02 : 0F A4 Req. ID = 4004

Entier 02 01 : 00 Error status : 0

Entier 02 01 : 00 Error index : 0

PDU

Page 26: Introduction à net-snmp Dimitri FOSSIER INPG/ESISAR.

Séquence

30

27 27 = 39 octets

Entier 02 01 : 00

Caractère

04 06 : 70 75 62 6C 69 63

P U B L I C

Séquence

A0A0 = 1010 0000 (Get

Request)

1A 1A = 26 octets

Entier 02 02 : 0F A4 Req. ID = 4004

Entier 02 01 : 00 Error statut : 0

Entier 02 01 : 00 Error index : 0

Séquence

30 0E 0E = 14 octets

Séquence

30 0C OC = 12 octets

Objet 06 08 : 2B 06 01 02 01 01 03 00

1.3.

6. 1. 2. 1. 1. 3. 0

Null 05 00

Page 27: Introduction à net-snmp Dimitri FOSSIER INPG/ESISAR.

1-sysDescr2-sysObjectID3-sysUpTime4-sysContact5-sysName6-sysLocation

1 – 3 – 6 – 1 – 2 – 1 – 1 – 3

Addr. Trans.3

Syst1

Interface2

IP4

ICMP5

TCP6

UDP7

EGP8

MIB I1

2

Directory1

Mgmt2

Experim.3

Private4

Internet1

2

3

4

1

2

3

4

5

DoD6

STD0

ORG3

2

1

UIT0

ISO1

2