Testing Trap With Linux Operating System: Difference between revisions
No edit summary |
|||
(19 intermediate revisions by the same user not shown) | |||
Line 11: | Line 11: | ||
$ sudo apt install <package_name> | $ sudo apt install <package_name> | ||
'''Important note:''' before continuing make sure that SNMP Trap package is configured. SNMP configuration example can be found here [[SNMP configuration example]]. | |||
'''Important note:''' before continuing make sure that SNMP Trap package is configured. SNMP configuration example can be found [[SNMP configuration example | |||
==Editing configuration files== | ==Editing configuration files== | ||
Line 21: | Line 17: | ||
===Snmpd.conf=== | ===Snmpd.conf=== | ||
This is not required for Trap listening service, but with this configuration '''snmpget''' command will be able to establish connection without requiring port number in the command line. | This is not required for Trap listening service, but with this configuration '''snmpget''' command will be able to establish connection without requiring port number in the command line. | ||
Edit snmpd.conf file, it can be found in ''' ''/etc/snmp/'' '''directory. Example of the command: | Edit snmpd.conf file, it can be found in ''' ''/etc/snmp/'' '''directory. Example of the command: | ||
Line 27: | Line 23: | ||
$ sudo nano /etc/snmp/snmpd.conf | $ sudo nano /etc/snmp/snmpd.conf | ||
Find a line containing '''"agenAddress udp:127.0.0.1:161"''' and comment it by adding '''#''' symbol at the beginning of the line. | Find a line containing '''"agenAddress udp:127.0.0.1:161"''' and comment it by adding '''#''' symbol at the beginning of the line. Uncomment line '''"agenAddress udp:161,udp6[::1]:161"'''. If you chose diferent SNMP port change '''161''' into your chosen port. '''Make sure to use exactly the same port as in SNMP package configuration on Teltonika device'''. | ||
[[File:Networking device configurationexample traps with terminal snmpd config | [[File:Networking device configurationexample traps with terminal snmpd config v1.png]] | ||
---- | ---- | ||
===Snmptrapd.conf=== | ===Snmptrapd.conf=== | ||
Line 51: | Line 47: | ||
'''Also''' you can change first line to '''disableAuthorization yes'''. This will disable all authorizations and any group will be able to send traps to the SNMP Manager. | '''Also''' you can change first line to '''disableAuthorization yes'''. This will disable all authorizations and any group will be able to send traps to the SNMP Manager. | ||
[[File:Networking device configurationexample traps with terminal snmptrapd config | [[File:Networking device configurationexample traps with terminal snmptrapd config v1.png]] | ||
---- | ---- | ||
===Creating Trap listening service=== | ===Creating Trap listening service=== | ||
This is required for launching Trap listening service with extra configurations, we will use it to describe the log file | This is required for launching Trap listening service with extra configurations, we will use it to describe the log file, where all traps will be recorded. | ||
Use this command: | Use this command: | ||
Line 64: | Line 60: | ||
'''[Service]''' | '''[Service]''' | ||
'''ExecStart=''' | '''ExecStart=''' | ||
'''ExecStart=/usr/sbin/snmptrapd -Ln -f -Lf /var/log/snmptrapd.log''' | '''ExecStart=/usr/sbin/snmptrapd -Ln -f -Lf /var/log/snmptrapd.log''' | ||
This configuration will write the log | This configuration will write the log into ''' ''/var/log/'' ''' folder and into ''' ''snmptrapd.log'' ''' file. You can change the log file directory and file name. | ||
[[File:Networking device configurationexample | [[File:Networking device configurationexample creating snmptrapd service v1.png]] | ||
---- | ---- | ||
===Loading MIB file=== | ===Loading MIB file=== | ||
MIB file will be used to translate OID codes to more readable format | MIB file will be used to translate OID codes to more readable format | ||
Revision as of 08:20, 19 September 2019
Summary
This chapter is a guide on configuring SNMP Trap listening service on Linux OS.
Preconditions
To configure Trap listening service these packages are required: snmp , snmpd, snmptt, snmptrapd.
To install these packages run command for each package:
$ sudo apt install <package_name>
Important note: before continuing make sure that SNMP Trap package is configured. SNMP configuration example can be found here SNMP configuration example.
Editing configuration files
Snmpd.conf
This is not required for Trap listening service, but with this configuration snmpget command will be able to establish connection without requiring port number in the command line.
Edit snmpd.conf file, it can be found in /etc/snmp/ directory. Example of the command:
$ sudo nano /etc/snmp/snmpd.conf
Find a line containing "agenAddress udp:127.0.0.1:161" and comment it by adding # symbol at the beginning of the line. Uncomment line "agenAddress udp:161,udp6[::1]:161". If you chose diferent SNMP port change 161 into your chosen port. Make sure to use exactly the same port as in SNMP package configuration on Teltonika device.
Snmptrapd.conf
This is required to specify community you described in SNMP Trap package configuration, to describe Trap port and how to handle caught Trap messages.
Edit snmptrapd.conf file, it can be found in /etc/snmp/ directory. Example of the command:
$ sudo nano /etc/snmp/snmptrapd.conf
Add these lines at the beginning of the file:
authcommunity log,execute,net public
snmpTrapdAddr udp:1110
traphandle default /usr/sbin/snmptt
In the first line change public to your community group described in SNMP Trap package configuration. In the second line change 1110 port number to your described port number in SNMP Trap package of the Teltonika device.
Also you can change first line to disableAuthorization yes. This will disable all authorizations and any group will be able to send traps to the SNMP Manager.
Creating Trap listening service
This is required for launching Trap listening service with extra configurations, we will use it to describe the log file, where all traps will be recorded.
Use this command:
$ sudo systemctl edit snmptrapd.service
Write these lines into the file:
[Service] ExecStart= ExecStart=/usr/sbin/snmptrapd -Ln -f -Lf /var/log/snmptrapd.log
This configuration will write the log into /var/log/ folder and into snmptrapd.log file. You can change the log file directory and file name.
Loading MIB file
MIB file will be used to translate OID codes to more readable format