To configure snmp on Linux, you first need to install the snmpd package with the command :
apt-get install snmpd
Then edit the configuration file :
nano /etc/snmp/snmpd.conf
Change the following line (or put it as a comment):
agentAddress udp:127.0.0.1:161
And replace it with :
agentAddress udp:0.0.0.0:161
Next, you need to configure the SNMP community:
rocommunity read_community default
or rocommunity “ community name ” “ range ip (unique ip ) /subnet mask ”.
rocommunity read_community 10.7.0.14/32
WARNING, do not leave rocommunity with the default systemonly view (comment, delete or modify the following line):
# rocommunity public default -V systemonly
Then restart the SNMP service by typing :
/etc/init.d/snmpd restart
Toavoid the agent adds a line every X minutes to your log file (each time the Esia server interrogates it), don't forget to make SNMP less verbose.
In the /etc/default/snmpd file, replace the following line :
SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -g snmp -I -smux,mteTrigger,mteTriggerConf -p /run/snmpd.pid'
with the following:
SNMPDOPTS='-LS4d -Lf /dev/null -u snmp -g snmp -I -smux,mteTrigger,mteTriggerConf -p /run/snmpd.pid'
Lsd stands for Ls FACILITY where facility can be ('d' for LOG_DAEMON, 'u' for LOG_USER, or '0'-'7' for LOG_LOCAL0 through LOG_LOCAL7).
LS4d stands for LS LEVEL FACILITY and is therefore used to specify the error LEVEL (5 LOG_NOTICE by default) before the FACILITY (see above). The different levels are :
0 ou ! pour LOG_EMERG, 1 ou a pour LOG_ALERT, 2 ou c pour LOG_CRIT, 3 ou e pour LOG_ERR, 4 ou w pour LOG_WARNING, 5 ou n pour LOG_NOTICE, 6 ou i pour LOG_INFO, and 7 ou d pour LOG_DEBUG.
Enter the following command:
systemctl edit snmpd
This will (among other things) create the file « /etc/systemd/system/snmpd.service.d/override.conf ». Add this code to the :
[Service] ExecStart= ExecStart=/usr/sbin/snmpd -LS4d -Lf /dev/null -u Debian-snmp -g Debian-snmp -I -smux,mteTrigger,mteTriggerConf -f
Then restart the SNMP service by typing :
service snmpd restart
On Debian Buster if the service command does not exist you can restart with this command:
systemctl restart snmpd