Tuesday, October 17, 2017

Installing the SNMP Service

  1. Log in as root user and right click anywhere on the desktop then, click on Open Terminal.
  2. To verify if the SNMP package is installed, there are few ways:
[root@localhost ~]# rpm -qa | grepsnmp
[root@localhost ~]# snmpwalk
-bash: snmpwalk: command not found
[root@localhost ~]# ls /etc/snmp*
ls: /etc/snmp*: No such file or directory
This mean net-snmp package is not installed yet.

  • Install net-snmp & net-snmp-utils package via yum or up2date
CentOS/Fedora:

[root@localhost ~]# yum install net-snmp net-snmp-utils
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
* base: mirror.usonyx.net
* extras: mirror.usonyx.net
* updates: mirror.usonyx.net
Setting up Install Process
Resolving Dependencies
–> Running transaction check
—> Package net-snmp.i386 1:5.3.2.2-17.el5_8.1 set to be updated
–> Processing Dependency: libsensors.so.3 for package: net-snmp
—> Package net-snmp-utils.i386 1:5.3.2.2-17.el5_8.1 set to be updated
–> Running transaction check
—> Package lm_sensors.i386 0:2.10.7-9.el5 set to be updated
–> Finished Dependency Resolution
Dependencies Resolved
=======================================================================
=========
Package Arch Version
Repository Size
=======================================================================
=========
Installing:
net-snmp i386 1:5.3.2.2-17.el5_8.1 updates
703 k
net-snmp-utils i386 1:5.3.2.2-17.el5_8.1 updates
191 k
Installing for dependencies:
lm_sensors i386 2.10.7-9.el5 base 511 k
Transaction Summary
=======================================================================
Install 3 Package(s)
Upgrade 0 Package(s)
Total download size: 1.4 M
Is this ok [y/N]: y
Downloading Packages:
(1/3): net-snmp-utils-5.3.2.2-17.el5_8.1.i386.rpm | 191 kB
00:00
(2/3): lm_sensors-2.10.7-9.el5.i386.rpm | 511 kB
00:01
(3/3): net-snmp-5.3.2.2-17.el5_8.1.i386.rpm | 703 kB
00:01
——————————————————————————–
Total 408 kB/s | 1.4 MB
00:03
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing :
lm_sensors 1/3
Installing : netsnmp 2/3
Installing : net-snmputils 3/3
Installed: net-snmp.i386 1:5.3.2.2-17.el5_8.1 net-snmp-utils.i386 1:5.3.2.2-17.el5_8.1
Dependency Installed: lm_sensors.i386 0:2.10.7-9.el5
Complete!
  • For RHEL, use command:
    # up2date -v -i net-snmp-utils net-snmp
The SNMP service is now installed.

Configuring the SNMP Service on Linux RHEL/CentOS/Fedora
  1. Edit the file /etc/snmp/snmpd.conf using a text editor such as vi, enter:
    # vi /etc/snmp/snmpd.conf
  2. Press ‘I’ to enter the insert mode. Now, change/modify line(s) as follows:
    Find the following line:

    com2secnotConfigUser default public


    Replace with (make sure you replace 192.168.0.0/24 with your network/subnet) the following lines:


    com2sec local localhost public

    com2secmynetwork 192.168.0.0/24 public

    Scroll down a bit and find the following lines:

    groupnotConfigGroup v1 notConfigUser
    groupnotConfigGroup v2c notConfigUser

    Replace with:

    groupMyRWGroup v1 local
    groupMyRWGroup v2c local
    groupMyRWGroupusm local
    groupMyROGroup v1 mynetwork
    groupMyROGroup v2c mynetwork
    groupMyROGroupusmmynetwork


    Again scroll down a bit and locate the following line:

    viewsystemview included system


    Replace with:

    view all included .1


    Again scroll down a bit and find the following line:

    access notConfigGroup "" any noauth exact systemview none none


    Replace with:

    accessMyROGroup "" any noauth exact all none none
    access MyRWGroup "" any noauth exact all all none


    Scroll down a bit and find the following lines:

    syslocation Unknown (edit /etc/snmp/snmpd.conf)
    syscontact Root (configure /etc/snmp/snmp.local.conf)


    Replace with (make sure you supply appropriate values):

    syslocation Linux (RH3_UP2), Home Linux Router.
    syscontactYourNameHereyou@example.com


    Now to exit the text editor, press “Esc” key and the type “:wq”. This will save the changes you made and then quit the text file.


    Make sure you back up your file by entering the following command:


    # cp /etc/snmp/snmp.conf /etc/snmp/snmp.conf.backup

    • Start your SNMP server and test it:(a) To sure when Linux comes up snmpd always starts after the system reboot
    • # chkconfigsnmpd on
              (b) Start the snmpd service
     # servicesnmpd start

             (c) Finally, test your snmp server
     # snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex
The SNMP is now configured.

On Ubuntu

Installing the SNMP Service on:
1. Log in as ROOT user and open the terminal by pressing CTRL+ALT+T.
2. Now enter the following command:
# sudo apt-get update
# sudo apt-get install snmpd
3. This will install SNMP service and show you a completion message.
Configuring the SNMP Service
  1. Type the following command in the terminal to open the text file using text editor ‘vi’:
    # vi /etc/snmp/snmpd.conf
  2. Edit/Update the file as follows:
    rocommunity public
    syslocation “Describe the server’s location”
    syscontact youremail@address.com
  3. Now save and exit the textfile by pressing ENTER and then :wq.
  4. Now edit the following file:
    # vi /etc/default/snmpd
  5. Update it as follows:
# This file controls the activity of snmpd and snmptrapd
# MIB directories. /usr/share/snmp/mibs is the default, but
# including it here avoids some strange problems.
export MIBDIRS=/usr/share/snmp/mibs
# snmpd control (yes means start daemon).
SNMPDRUN=yes
# snmpd options (use syslog, close stdin/out/err).
# replace 204.x.y.z with your public IP
SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid
127.0.0.1 204.x.y.z'
# snmptrapd control (yes means start daemon). As of net-snmp
version
# 5.0, master agentx support must be enabled in snmpd before
snmptrapd
# can be run. See snmpd.conf(5) for how to do this.
TRAPDRUN=no
# snmptrapd options (use syslog).
TRAPDOPTS='-Lsd -p /var/run/snmptrapd.pid'
# create symlink on Debian legacy location to official RFC path
SNMPDCOMPAT=yes
  • Restart the SNMP service:
    # /etc/init.d/snmpd restart
The SNMP is now configured.

No comments:

Post a Comment