Showing posts with label SNMP. Show all posts
Showing posts with label SNMP. Show all posts

Thursday, August 19, 2010

Fedora: Install & configure Net-SNMP running on IPv6

I've install net-snmp on my fedora machine for 'secret' purpose :P
Here are some basic tutorial but it works for me and perhaps all fedora user. I've experienced some errors if directly install the net-snmp. Thus, I try to install perl first (latest version) before installing and afterwards I didn't face any error to install.

Step 1: Installing Perl from source
Download tar ball (.tar.gz) of the latest version with type (maint) here

login as root, go to directory where the tar ball is located, extract and go inside directory
$ su
# tar xzvf perl-version.tar.gz
# cd perl-version

now, we configure (with default setting) to confirm with your platform
# ./Configure -de

compile and install
# make && make install

Note that it won't be installed if there is an error

if it is successfully installed, try . .
$ perl -v

output will be the version of newly installed perl. In my case:
This is perl 5, version 12, subversion 1 (v5.12.1) built for i686-linux

Step 2: Installing net-snmp from source
Go to net-snmp page and download source file (.tar.gz) under 'current release'. Same thing, extract the tar file
# tar xzvf net-snmp-version.tar.gz
# cd net-snmp-version

Then, configure using several option (press enter for each prompt)
# ./configure --enable-ipv6 --with-transports="UDP UDPIPv6" --with-libs=-lpthread --with-perl-modules

finally compile and install
# make && make test && make install

remember, if any error occurs installation won't finish

Step 3: snmpd configuration file
Go to snmp directory
# cd /usr/local/share/snmp

Then, we can create snmpd.conf file using this command
# snmpconf

Would you like me to read them in? Their content will be merged with the
output files created by this session.

Valid answer examples: "all", "none","3","1,2,5"

Read in which (default = all): none

next . .

I can create the following types of configuration files for you.
Select the file type you wish to create:
(you can create more than one as you run this program)

1: snmpd.conf
2: snmptrapd.conf
3: snmp.conf

Other options: quit

Select File: 1

Lastly, type 'finished' and 'quit'. You will get output like this
The following files were created:

snmpd.conf

Now, edit this file and replace with all content posted here
# gedit snmpd.conf

and add this line after this line '# sec.name source community'
[...]

com2sec6 local ::1 public

[...]

save the file and close.

Now, Run snmpd first just on udp with IPv6 on port 161 (as root)
# snmpd udp6:161

Then, try snmpwalk (You should have IPv6 configured)
# snmpwalk -v 1 -c public 'ipv6:[::1]' IP-MIB::ipAdEntIfIndex

Output will be somehow like this
IP-MIB::ipAdEntIfIndex.10.1.27.140 = INTEGER: 3
IP-MIB::ipAdEntIfIndex.127.0.0.1 = INTEGER: 1

If you got this, so i think it works ;)

Tuesday, February 9, 2010

SNMP & Cacti Configuration (PART 2)

SNMP configuration updated. Previously, I have posted SNMP & Cacti Configuration. I want to add some additional necessary information to configure which I have done.
Firstly I checked my SNMP if it's working or not:
$snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex

It suppose to return your ip as output like below:


In my case, SNMP is not working and return many different errors. What I have done to solve the problem is just edit snmpd configuration file (snmpd.conf). Below is my snmpd.conf (/etc/snmp/snmpd.conf), you could simply copy paste and try to your PC. (Copy the original file first so you have backup if something happen) -- I put the lines you have to check in red.


##########################################
# EXAMPLE.conf:
# An example configuration file for configuring the ucd-snmp snmpd agent.
#
##########################################
# This file is intended to only be an example. If, however, you want
# to use it, it should be placed in /etc/snmp/snmpd.conf.
# When the snmpd agent starts up, this is where it will look for it.
#
# You might be interested in generating your own snmpd.conf file using
# the "snmpconf" program (perl script) instead. It's a nice menu
# based interface to writing well commented configuration files. Try it!
#
# Note: This file is automatically generated from EXAMPLE.conf.def.
# Do NOT read the EXAMPLE.conf.def file! Instead, after you have run
# configure & make, and then make sure you read the EXAMPLE.conf file
# instead, as it will tailor itself to your configuration.

# All lines beginning with a '#' are comments and are intended for you
# to read. All other lines are configuration commands for the agent.

# PLEASE: read the snmpd.conf(5) manual page as well!

##########################################
# Access Control
##########################################
# YOU SHOULD CHANGE THE "COMMUNITY" TOKEN BELOW TO A NEW KEYWORD ONLY
# KNOWN AT YOUR SITE. YOU *MUST* CHANGE THE NETWORK TOKEN BELOW TO
# SOMETHING REFLECTING YOUR LOCAL NETWORK ADDRESS SPACE.

# By far, the most common question I get about the agent is "why won't
# it work?", when really it should be "how do I configure the agent to
# allow me to access it?"
#
# By default, the agent responds to the "public" community for read
# only access, if run out of the box without any configuration file in
# place. The following examples show you other ways of configuring
# the agent so that you can change the community names, and give
# yourself write access as well.
#
# The following lines change the access permissions of the agent so
# that the COMMUNITY string provides read-only access to your entire
# NETWORK (EG: 10.10.10.0/24), and read/write access to only the
# localhost (127.0.0.1, not its real ipaddress).
# For more information, read the FAQ as well as the snmpd.conf(5)
# manual page.

##########################################
# First, map the community name (COMMUNITY) into a security name
# (local and mynetwork, depending on where the request is coming
# from):
# sec.name source community
com2sec local localhost public
com2sec mynetwork 10.101.95.0/24 public

##########################################
# Second, map the security names into group names:
# sec.model sec.name
group MyROSystem v1 paranoid
group MyROSystem v2c paranoid
group MyROSystem usm paranoid
group MyROGroup v1 local
group MyROGroup v2c local
group MyROGroup usm local
group MyRWGroup v1 mynetwork
group MyRWGroup v2c mynetwork
group MyRWGroup usm mynetwork

##########################################
# Third, create a view for us to let the groups have rights to:
# incl/excl subtree mask
view all included .1 80
view system included .iso.org.dod.internet.mgmt.mib-2.system

##########################################
# Finally, grant the 2 groups access to the 1 view with different
# write permissions:
# context sec.model sec.level match read write notif
access MyROSystem "" any noauth exact system none none
access MyROGroup "" any noauth exact all none none
access MyRWGroup "" any noauth exact all all none

#--------------------------------------------

#############################################
# System contact information
# It is also possible to set the sysContact and sysLocation system
# variables through the snmpd.conf file. **PLEASE NOTE** that setting
# the value of these objects here makes these objects READ-ONLY
# (regardless of any access control settings). Any attempt to set the
# value of an object whose value is given here will fail with an error
# status of notWritable.
#Editing this value is optional, i dont do any changes
syslocation Unknown (configure /etc/snmp/snmpd.local.conf)
syscontact Root (configure /etc/snmp/snmpd.local.conf)

End changes. Leave code below this line as it is
################################################

After edit this file, save it. Then restart SNMP. Make sure you restart.
$sudo service snmpd restart

Then, do check again.
$snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex

That's all. :)

Friday, January 29, 2010

SNMP & Cacti Configuration

Basically, i refer my SNMP and Cacti installation here. It works nicely. I would like to paste here everything i have done to make it works in my PC.

Below is how the architecture looks since I want Cacti to monitor many devices at a time. Firstly, assign one PC as manager (which Cacti will be installed) and all of devices to be monitored. They are connected using SNMP.


Below is the setting I had done to my manager:

1) Firstly, install SNMP
$sudo apt-get install snmpd

2) Then check
$sudo gedit /etc/default/snmpd

Make sure
# snmpd control (yes means start daemon).
SNMPDRUN=yes

# snmpd options (use syslog, close stdin/out/err).
SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid 127.0.0.1'

3) Next,
$sudo gedit /etc/snmp/snmpd.conf

In the line of com2sec setting, I have adjusted as below (slightly different from How-To)
# sec.name source community
com2sec readonly localhost public

If you have your own community, you could use it for better security.

4) Check SNMP configuration
$snmpwalk -Os -c public -v 1 localhost system

(If you use your community, replace 'public' with your community name)

This command will return result something like this:


5) CACTI- Installation
I did exactly like here.

For all other devices, configure SNMP server same like above. That's all :)