Ceci est une ancienne révision du document !
Table des matières
Exercice pratique
Le problème
Soit un switch (toujours le même), configuré comme indiqué ici, c'est-à-dire que nous disposons d'un serveur RADIUS, avec une base de données qui recense toutes les adresses MAC de nos stations.
Nous avons enrichi cette base en ajoutant le nom des stations. Par ailleurs, nous avons une table qui relie le numéro de chaque port du switch au numéro de la prise dans l'établissement.
Nous voulons utiliser SNMP pour savoir quels sont les clients actuellement en service et sur quelle prise (i.e. sur quel port de switch) ils sont branchés.
SNMP va peut-être nous permettre de savoir quelles adresses MAC sont présentes sur chaque port du switch (habituellement une seule), si notre BRIDGE-MIB définit cette information et indique où la trouver. C'est dans ces cas qu'un browser de MIB montre son utilité. Même tkmib sera plus agréable à manipuler que snmptranslate.
Notons un outil en ligne digne d'intérêt, le « SimpleWeb » dans la rubrique MIBs en ce qui nous concerne dans le cas de figure. Nous trouvons la BRIDGE-MIB, développons son arborescence, et voyons que :
BRIDGE-MIB::dot1dTpFdbAddress
dot1dTpFdbAddress OBJECT-TYPE
-- FROM BRIDGE-MIB
-- TEXTUAL CONVENTION MacAddress
SYNTAX OCTET STRING (6)
DISPLAY-HINT "1x:"
MAX-ACCESS read-only
STATUS current
DESCRIPTION "A unicast MAC address for which the bridge has
forwarding and/or filtering information."
::= { iso(1) org(3) dod(6) internet(1) mgmt(2) mib-2(1) dot1dBridge(17) dot1dTp(4) dot1dTpFdbTable(3) dot1dTpFdbEntry(1) 1 }
et que
BRIDGE-MIB::dot1dTpFdbPort
dot1dTpFdbPort OBJECT-TYPE
-- FROM BRIDGE-MIB
SYNTAX Integer32
MAX-ACCESS read-only
STATUS current
DESCRIPTION "Either the value '0', or the port number of the port on
which a frame having a source address equal to the value
of the corresponding instance of dot1dTpFdbAddress has
been seen. A value of '0' indicates that the port
number has not been learned, but that the bridge does
have some forwarding/filtering information about this
address (e.g., in the dot1dStaticTable). Implementors
are encouraged to assign the port value to this object
whenever it is learned, even for addresses for which the
corresponding value of dot1dTpFdbStatus is not
learned(3)."
::= { iso(1) org(3) dod(6) internet(1) mgmt(2) mib-2(1) dot1dBridge(17) dot1dTp(4) dot1dTpFdbTable(3) dot1dTpFdbEntry(1) 2 }
Ces deux OIDs sont susceptibles de nous intéresser.
Comme par ce beau jour d'été (nous sommes le 13 juillet 2010), il n'y a pas grand monde dans l'établissement, nous allons réaliser la manipulation sur le switch de tête, celui qui connecte tous les serveurs et les autres switches, le seul qui voit du monde à cette date.
dot1dTpFdbAddress
~$ snmpbulkwalk -Ob -m +/var/lib/mibs/ietf/BRIDGE-MIB -c public -v 2c 172.16.252.4 BRIDGE-MIB::dot1dTpFdbAddress
BRIDGE-MIB::dot1dTpFdbAddress.0.5.93.8.128.1 = STRING: 0:5:5d:8:80:1 BRIDGE-MIB::dot1dTpFdbAddress.0.19.212.88.167.204 = STRING: 0:13:d4:58:a7:cc BRIDGE-MIB::dot1dTpFdbAddress.0.23.8.228.70.128 = STRING: 0:17:8:e4:46:80 BRIDGE-MIB::dot1dTpFdbAddress.0.23.8.228.70.206 = STRING: 0:17:8:e4:46:ce BRIDGE-MIB::dot1dTpFdbAddress.0.23.8.228.197.0 = STRING: 0:17:8:e4:c5:0 BRIDGE-MIB::dot1dTpFdbAddress.0.23.8.228.197.79 = STRING: 0:17:8:e4:c5:4f BRIDGE-MIB::dot1dTpFdbAddress.0.33.145.133.119.77 = STRING: 0:21:91:85:77:4d BRIDGE-MIB::dot1dTpFdbAddress.0.35.84.55.145.46 = STRING: 0:23:54:37:91:2e BRIDGE-MIB::dot1dTpFdbAddress.0.48.132.58.84.111 = STRING: 0:30:84:3a:54:6f BRIDGE-MIB::dot1dTpFdbAddress.0.48.132.58.85.170 = STRING: 0:30:84:3a:55:aa BRIDGE-MIB::dot1dTpFdbAddress.0.48.132.58.97.178 = STRING: 0:30:84:3a:61:b2 BRIDGE-MIB::dot1dTpFdbAddress.0.48.132.58.99.185 = STRING: 0:30:84:3a:63:b9 BRIDGE-MIB::dot1dTpFdbAddress.0.48.132.58.99.199 = STRING: 0:30:84:3a:63:c7 BRIDGE-MIB::dot1dTpFdbAddress.0.48.132.58.100.151 = STRING: 0:30:84:3a:64:97 BRIDGE-MIB::dot1dTpFdbAddress.144.230.186.157.115.173 = STRING: 90:e6:ba:9d:73:ad
~$ snmpbulkwalk -Ot -m +/var/lib/mibs/ietf/BRIDGE-MIB -c public -v 2c 172.16.252.4 BRIDGE-MIB::dot1dTpFdbPort BRIDGE-MIB::dot1dTpFdbPort.'..]…' = INTEGER: 11 BRIDGE-MIB::dot1dTpFdbPort.'…X..' = INTEGER: 5 BRIDGE-MIB::dot1dTpFdbPort.'….F.' = INTEGER: 23 BRIDGE-MIB::dot1dTpFdbPort.'….F.' = INTEGER: 23 BRIDGE-MIB::dot1dTpFdbPort.'……' = INTEGER: 24 BRIDGE-MIB::dot1dTpFdbPort.'…..O' = INTEGER: 24 BRIDGE-MIB::dot1dTpFdbPort.'.!..wM' = INTEGER: 0 BRIDGE-MIB::dot1dTpFdbPort.'.#T7..' = INTEGER: 6 BRIDGE-MIB::dot1dTpFdbPort.'.0.:To' = INTEGER: 8 BRIDGE-MIB::dot1dTpFdbPort.'.0.:U.' = INTEGER: 9 BRIDGE-MIB::dot1dTpFdbPort.'.0.:a.' = INTEGER: 10 BRIDGE-MIB::dot1dTpFdbPort.'.0.:c.' = INTEGER: 4 BRIDGE-MIB::dot1dTpFdbPort.'.0.:c.' = INTEGER: 3 BRIDGE-MIB::dot1dTpFdbPort.'.0.:d.' = INTEGER: 7 BRIDGE-MIB::dot1dTpFdbPort.'….s.' = INTEGER: 13
On doit pouvoir faire plus clair peut-être ?
~$ snmpbulkwalk -On -m +/var/lib/mibs/ietf/BRIDGE-MIB -c public -v 2c 172.16.252.4 BRIDGE-MIB::dot1dTpFdbPort .1.3.6.1.2.1.17.4.3.1.2.0.5.93.8.128.1 = INTEGER: 11 .1.3.6.1.2.1.17.4.3.1.2.0.19.212.88.167.204 = INTEGER: 5 .1.3.6.1.2.1.17.4.3.1.2.0.23.8.228.70.128 = INTEGER: 23 .1.3.6.1.2.1.17.4.3.1.2.0.23.8.228.70.206 = INTEGER: 23 .1.3.6.1.2.1.17.4.3.1.2.0.23.8.228.197.0 = INTEGER: 24 .1.3.6.1.2.1.17.4.3.1.2.0.23.8.228.197.79 = INTEGER: 24 .1.3.6.1.2.1.17.4.3.1.2.0.33.145.133.119.77 = INTEGER: 0 .1.3.6.1.2.1.17.4.3.1.2.0.35.84.55.145.46 = INTEGER: 6 .1.3.6.1.2.1.17.4.3.1.2.0.48.132.58.84.111 = INTEGER: 8 .1.3.6.1.2.1.17.4.3.1.2.0.48.132.58.85.170 = INTEGER: 9 .1.3.6.1.2.1.17.4.3.1.2.0.48.132.58.97.178 = INTEGER: 10 .1.3.6.1.2.1.17.4.3.1.2.0.48.132.58.99.185 = INTEGER: 4 .1.3.6.1.2.1.17.4.3.1.2.0.48.132.58.99.199 = INTEGER: 3 .1.3.6.1.2.1.17.4.3.1.2.0.48.132.58.100.151 = INTEGER: 7 .1.3.6.1.2.1.17.4.3.1.2.144.230.186.157.115.173 = INTEGER: 13
plus « numérique » mais à priori pas plus clair. Essayons encore :
~$ snmpbulkwalk -OX -m +/var/lib/mibs/ietf/BRIDGE-MIB -c public -v 2c 172.16.252.4 BRIDGE-MIB::dot1dTpFdbPort BRIDGE-MIB::dot1dTpFdbPort[STRING: 0:5:5d:8:80:1] = INTEGER: 11 BRIDGE-MIB::dot1dTpFdbPort[STRING: 0:13:d4:58:a7:cc] = INTEGER: 5 BRIDGE-MIB::dot1dTpFdbPort[STRING: 0:17:8:e4:46:80] = INTEGER: 23 BRIDGE-MIB::dot1dTpFdbPort[STRING: 0:17:8:e4:46:ce] = INTEGER: 23 BRIDGE-MIB::dot1dTpFdbPort[STRING: 0:17:8:e4:c5:0] = INTEGER: 24 BRIDGE-MIB::dot1dTpFdbPort[STRING: 0:17:8:e4:c5:4f] = INTEGER: 24 BRIDGE-MIB::dot1dTpFdbPort[STRING: 0:21:91:85:77:4d] = INTEGER: 0 BRIDGE-MIB::dot1dTpFdbPort[STRING: 0:23:54:37:91:2e] = INTEGER: 6 BRIDGE-MIB::dot1dTpFdbPort[STRING: 0:30:84:3a:54:6f] = INTEGER: 8 BRIDGE-MIB::dot1dTpFdbPort[STRING: 0:30:84:3a:55:aa] = INTEGER: 9 BRIDGE-MIB::dot1dTpFdbPort[STRING: 0:30:84:3a:61:b2] = INTEGER: 10 BRIDGE-MIB::dot1dTpFdbPort[STRING: 0:30:84:3a:63:b9] = INTEGER: 4 BRIDGE-MIB::dot1dTpFdbPort[STRING: 0:30:84:3a:63:c7] = INTEGER: 3 BRIDGE-MIB::dot1dTpFdbPort[STRING: 0:30:84:3a:64:97] = INTEGER: 7 BRIDGE-MIB::dot1dTpFdbPort[STRING: 90:e6:ba:9d:73:ad] = INTEGER: 13
Ah, ça commence à ressembler à quelque chose de plus compréhensible : la chaine entre crochets rappèle furieusement une adresse MAC et la valeur (INTEGER) le numéro du port.