1. Objectif
Décrire la configuration SNMP sur un équipement Linux.
2. Debian, Ubuntu
2.1. Installation de SNMP
root@localhost # apt-get install snmp snmpd
2.2. Configuration
Editer le fichier de configuration SNMP :
root@localhost # nano /etc/snmp/snmpd.conf
Réaliser un backup du fichier avant modification
Il faut autoriser l’accès en lecture des données SNMP.
#AGENT BEHABIOUR#
agentAddress udp:161
#ACCESS CONTROL#
rocommunity <communaute> localhost
rocommunity <communaute> <IP BOX>
Ensuite éditez le fichier /etc/default/snmpd :
SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid 127.0.0.1'
et remplacez 127.0.0.1 par l’adresse IP de l’interface réseau utilisée pour communiquer avec la machine B. Pour ne pas faire de filtrage à ce niveau il suffit d’enlever l’adresse IP.
Enregistrer le fichier de configuration puis relancer le service :
root@localhost # /etc/init.d/snmpd restart
3. Red Hat Entreprise Linux 3,4 and 7
3.1. Enabling SNMP access and trap forwarding for Red Hat Enterprise Linux versions 3 and 4
The OpenIPMI driver supported on Red Hat Enterprise Linux® versions 3 and 4 has a dependency on the version of Net-SNMP that is included with those Linux distributions. IBM® Director Core Services requires a different Net-SNMP version, 5.2.1. Installation of Net-SNMP 5.2.1 without removing the existing Net-SNMP version is required for IBM Director SNMP access and trap forwarding without compromising OpenIPMI services.
Complete the following steps to enable SNMP access and trap forwarding for managed systems running Red Hat Enterprise Linux versions 3 and 4:
1. Download the net-snmp-5.2.1.tar.gz file from the Net-SNMP Web site at www.net-snmp.org/download.html.
2. Build and install the Net-SNMP libraries using the following steps.
Notes:
- This procedure does not perform a full installation of Net-SNMP, but installs only the Net-SNMP libraries, which are required for IBM Director Core Services SNMP functions.
- Refer to the INSTALL and README files included in the net-snmp-5.2.1.tar.gz package for additional installation information.
Untar the source files. Type the following command and press Enter.
tar -xvzf net-snmp-5.2.1.tar.gz
Change to the source directory. Type the following command and press Enter.
cd net-snmp-5.2.1
Build the Net-SNMP libraries with default options. Type the following commands (press Enter after each).
./configure --with-defaultsmake
Install the Net-SNMP libraries only to /usr/local/lib. Type the following command and press Enter.
make installlibs
To enable trap forwarding, edit the /etc/init.d/dacimlist file and uncomment the following two lines two lines in the SNMP End Consumer section.
LD_LIBRARY_PATH=/usr/local/lib export LD_LIBRARY_PATH
Note: The configuration changes will not take effect until you restart the cimlistener daemon in step 7.
To enable SNMP access, edit the /etc/init.d/dasnmp file and uncomment the following two lines in the section regarding the location of the net-snmp libraries.
LD_LIBRARY_PATH=/usr/local/lib export LD_LIBRARY_PATH
Configure the SNMP daemon that ships with Red Hat Enterprise Linux to support AgentX agents. For details, see the documentation on the Net-SNMP Web Site.
Create the file /usr/local/share/snmp/snmpd.conf to specify trapsink and trapcommunity settings. You might have to create the directory. This file should contain only settings for trapcommunity and trapsink.
a) Specify a trap community value by adding a line containing the word trapcommunity followed by a space and the trapcommunity value, as in the following example.
trapcommunity public
b) Specify a trapsink value for each destination to which IBM Director will send SNMP traps. Add a line containing the word trapsink followed by a space and the trapsink value, as in the following example.
trapsink 192.168.1.1
Restart the cimlistener daemon by typing the following commands and pressing Enter after each:
/etc/init.d/dacimlist stop/etc/init.d/dacimlist start
Restart the IBM Director AgentX subagent by typing the following commands and pressing Enter after each:
/etc/init.d/dasnmp stop /etc/init.d/dasnmp start
3.2. Installer SNMP pour Red Hat Enterprise Linux 7
Red Hat Enterprise Linux 7 inclut la suite de logiciels Net-SNMP, qui offre un agent flexible et extensible ou simple network management protocol (SNMP). Cet agent et ses utilitaires associés peuvent être utilisés pour fournir des données de performance à partir d’un grand nombre de systèmes sur une variété d’outils qui prennent en charge les interrogations via le protocole SNMP
.
root
:~]# yum install net-snmp net-snmp-libs net-snmp-utils
Exécuter le démon Net-SNMP
snmpd
, le démon de l’agent SNMP. Cette section fournit des informations sur la manière de lancer, arrêter, et redémarrer le service snmpd
.snmpd
dans la session actuelle, veuillez saisir ce qui suit dans l’invite de shell en tant qu’utilisateur root
:systemctl start snmpd.service
systemctl enable snmpd.service
Configurer Net-SNMP
/etc/snmp/snmpd.conf
. Le fichier par défaut snmpd.conf
inclus avec Red Hat Enterprise Linux 7 contient beaucoup de commentaires et peut servir de bon point de départ pour la configuration de l’agent.snmpd.conf
(5). En outre, il existe un utilitaire dans le paquet net-snmp nommé snmpconf
, qui peut être utilisé de manière interactive pour générer une configuration d’agent valide.Configurer une communauté SNMP Version 2c
rocommunity
ou rwcommunity
dans le fichier de configuration /etc/snmp/snmpd.conf
. Le format des directives est comme suit :directive community [source [OID]]
system
à un client utilisant la chaîne de communité « redhat » sur la machine locale :rocommunity redhat 127.0.0.1 .1.3.6.1.2.1.1
snmpwalk
avec les options -v
et -c
.~]# snmpwalk -v2c -c redhat localhost system
SNMPv2-MIB::sysDescr.0 = STRING: Linux localhost.localdomain 3.10.0-123.el7.x86_64 #1 SMP Mon May 5 11:16:57 EDT 2014 x86_64 SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.10 DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (101376) 0:16:53.76 SNMPv2-MIB::sysContact.0 = STRING: UNIX Admin <admin@example.com> SNMPv2-MIB::sysName.0 = STRING: localhost.localdomain SNMPv2-MIB::sysLocation.0 = STRING: Datacenter, Row 4, Rack 3[sortie tronquée]
Configurer un utilisateur SNMP Version 3
net-snmp-create-v3-user
. Cette command ajoute des entrées aux fichiers /var/lib/net-snmp/snmpd.conf
et /etc/snmp/snmpd.conf
qui créent l’utilisateur et offrent accès à l’utilisateur. Remarque que la commande net-snmp-create-v3-user
peut uniquement être exécutée lorsque l’agent n’est pas en cours d’exécution. L’exemple suivant crée l’utilisateur « admin » avec le mot de passe « redhatsnmp » :~]#systemctl stop snmpd.service
~]#net-snmp-create-v3-user
Enter a SNMPv3 user name to create: admin Enter authentication pass-phrase: redhatsnmp Enter encryption pass-phrase: [press return to reuse the authentication pass-phrase] adding the following line to /var/lib/net-snmp/snmpd.conf: createUser admin MD5 "redhatsnmp" DES adding the following line to /etc/snmp/snmpd.conf: rwuser admin ~]#systemctl start snmpd.service
rwuser
(ou rouser
lorsque l’option de ligne de commande -ro
est fournie) ajoutée par net-snmp-create-v3-user
à /etc/snmp/snmpd.conf
possède un format similaire aux directives rwcommunity
et rocommunity
:directive user [noauth
|auth
|priv
] [OID]
auth
). L’option noauth
vous permet d’autoriser des requêtes non authentifiées, et l’option priv
applique l’utilisation du chiffrement. L’option authpriv
spécifie que les requêtes doivent être authentifiées et que les réponses doivent être chiffrées.rwuser admin authpriv .1
.snmp/
dans le répertoire personnel de l’utilisateur, ainsi qu’un fichier de configuration nommé snmp.conf
dans ce répertoire (~/.snmp/snmp.conf
) avec les lignes suivantes :defVersion 3 defSecurityLevel authPriv defSecurityName admin defPassphrase redhatsnmp
snmpwalk
utilisera ces paramètres d’authentification lorsque des requêtes sont effectuées sur l’agent :~]$ snmpwalk -v3 localhost system
SNMPv2-MIB::sysDescr.0 = STRING: Linux localhost.localdomain 3.10.0-123.el7.x86_64 #1 SMP Mon May 5 11:16:57 EDT 2014 x86_64[sortie tronquée]