Linux Links‎ > ‎

SNMPd


SNMPd is not installed by default. You must first install snmpd.

apt-get update; apt-get install snmpd

You should see many lines;

The following NEW packages will be installed:
libsensors4 libsnmp-base libsnmp15 snmpd
0 upgraded, 4 newly installed, 0 to remove and 1 not upgraded.
Need to get 1,659 kB of archives.
After this operation, 4,210 kB of additional disk space will be used.
Do you want to continue [Y/n]?

You click just hit enter. It will download and install snmp. When this is done.

Open the configuration file:

nano /etc/snmp/snmpd.conf

The first thing to change will be at the top of the configuration file.

# AGENT BEHAVIOUR
#

# Listen for connections from the local system only
#agentAddress udp:127.0.0.1:161
# Listen for connections on all interfaces (both IPv4 *and* IPv6)
agentAddress udp:161,udp6:[::1]:161

You are changing 2 things here. By default:
#agentAddress udp:127.0.0.1:161 will be agentAddress udp:127.0.0.1:161

AND

agentAddress udp:161,udp6:[::1]:161 will be #agentAddress udp:161,udp6:[::1]:161

Simply make the change to make it appear like above in blue.

Further down the configuration file you can add the following.

Add the following for your internal ip addresses:

rocommunity secret 10.0.0.0/8
rocommunity secret 172.16.0.0/12
rocommunity secret 192.186.0.0/16

Press ctrl+x to exit. Type y to save, and press Enter for the file name.

Restart the SNMP agent:

/etc/init.d/snmpd restart

This should be all you need to do in most cases. Now from Netmon add your server.




---------------------------------------
Old instructions


# apt-get install snmpd snmp



other stuff:

you have to edit your snmpd.conf file to have "DISK" in it in order to monitor disk space


SNMP setup for server (DEBIAN)

$ sudo apt-get install snmpd

snmpd is now installed but we still have to tweak it a little bit to make it work as we want.

1.2. Configuring SNMPD

The first thing we want to make sure is that snmpd is only going to wait for connections on localhost. To do this, edit file /etc/default/snmpd and make sure those values are set:

SNMPDRUN=yes
SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid 127.0.0.1'

If you want your server to listen on all interfaces, remove the 127.0.0.1 bit.

Installing SNMP Server in Debian

If you want to install snmp server in debian you need to install snmpd package using the following command

#apt-get install snmpd

This will complete the installation process.

Configuring SNMP Server in Debian

Default Configuration files are located at /etc/snmp directory this contains the following files.

snmpd.conf snmptrapd.conf

/etc/snmp/snmpd.conf - configuration file for the Net-SNMP SNMP agent.

/etc/snmp/snmptrapd.conf - configuration file for the Net-SNMP trap daemon.

Now we need to concentrate on snmpd.conf file for our configuration. If you want to see the default snmpd.conf file. 

Before doing any changes to your /etc/snmp/snmpd.conf file take a copy of original file using the following command

#cp /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.orig

Set up the snmp server to allow read access from the other machines in your network for this you need to open the file /etc/snmp/snmpd.conf change the following Configuration and save the file.

 first step

sec.name           source  community
   com2sec paranoid default public
#com2sec readonly default public
#com2sec readwrite default private

to

#com2sec paranoid default public
   com2sec local   localhost public
   com2sec localNet 192.168.0.0 /24 public
#com2sec readwrite default private

you can define the source whichever way you want like only allow from local machine for that you need to add 127.0.0.1 under source and you can define your community in this case we are using public as our community.

Second Step

####
# 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 readonly
group MyROGroup v2c readonly
group MyROGroup usm readonly
group MyRWGroup v1 readwrite
group MyRWGroup v2c readwrite
group MyRWGroup usm readwrite

to

group MyROSystem v1 local
group MyROSystem v2c local
group MyROSystem usm local
group MyROGroup v1 localnet
group MyROGroup v2c localnet
group MyROGroup usm localnet
group MyRWGroup v1 local
group MyRWGroup v2c local
group MyRWGroup usm local

Third Step

####
# 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

Don't chnage anything here leave this one as default setting

Final Step

####
# 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

Don't chnage anything here leave this one as default setting.

Optional Configuration

# System contact information

syslocation Unknown (configure /etc/snmp/snmpd.local.conf)
syscontact Root <root@localhost> (configure /etc/snmp/snmpd.local.conf)

to

syslocation MainDatacenter
syscontact webmaster@debianhelp.co.uk

Now the above configuration able to access local and 192.168.0.0 /24 network machines to use full functionality of MIB's this is very important if you want to collect the information from existing machines in above network.

Now you need to restart the snmp services using the following command

#/etc/init.d/snmpd restart

Now the SNMP server configuration is active and running.

Testing your Configuration

#snmpwalk localhost -c public -v1


Comments