Skip to main content

Install and configure SNMP on CentOS 7

# Introduction
SNMP, or Simple Network Management Protocol, is widely used to communicate with and monitor network devices, servers, and more,
all via IP. In this case, we’ll be installing an SNMP agent on a CentOS 6.5 server, which will allow for collection of data from
our server, and make the information available to a remote SNMP manager.


# Install SNMP packages
yum -y install net-snmp net-snmp-utils

# Configure SNMP
cp /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.orig
cat <<'EOF' > /etc/snmp/snmpd.conf
###################################################################
#          SNMP configuration - Customzie by Sam KUON             #
###################################################################
# Agent address
#agentaddress    udp:161
agentAddress udp:161,udp6:[::1]:161

## Access control
#@@ Firstly, Map the community into a security name
#           sec.name            source                  community
#com2sec    <sec.name>          <monitor_server>        <community_password>
#com2sec6   <sec.name>          <monitor_server_ipv6>   <community_password>
com2sec     AllowSpecific       192.168.50.10           only4spec!
com2sec     AllowAll            192.168.50.10           not4you!

#@@ Secondly, Map the security name into a group
# group.name sec.model               sec.name
#group      <group_name>        <security_mode>         <security_name>
group       SpecificGroup       v2c                     AllowSpecific
group       AllGroup            v2c                     AllowAll

#@@ Thirdly, Create a view to let group have rights to:
#@@ Open up the whole tree for ro, make the RFC 1213 required ones rw.
# Define 'SystemView', which includes everything under .1.3.6.1.2.1.1 (or .1.3.6.1.2.1.25.1)
# Define 'AllView', which includes everything under .1
#           view.name           incl/excl               subtree.mask(Optional)
view        SystemView          included                .1.3.6.1.2.1.1
view        SystemView          included                .1.3.6.1.2.1.25.1.1
view        AllView             included                .1

#@@ Finally, Grant right to group
# Give 'SpecificGroup' read access to objects in the view 'SystemView'
# Give 'AllGroup' read access to objects in the view 'AllView'
#           group.name      context model   level   prefix  read        write   notify
access      SpecificGroup   ""      any     noauth  exact   SystemView  none    none
access      AllGroup        ""      any     noauth  exact   AllView     none    none

## System contact information
#syslocation    <location set>
#syscontact     <contact_info>
syslocation     Infrastructure, PNH, KH
syscontact      Sam KUON, Email:sam.kuonssp@gmail.com, Mob: 086231646

## <<<<<<<<<<<<<<<<<<<<<<<<<<<< End of config >>>>>>>>>>>>>>>>>>>>>>>>>>>>#
EOF

# IPTABLES
echo '-A INPUT -m state --state NEW -m udp -p udp --dport 161 -j ACCEPT' >> /etc/sysconfig/iptables.extra
lokkit --custom-rules=ipv4:filter:/etc/sysconfig/iptables.extra

# Enable and start SNMP service
systemctl enable snmpd
systemctl start snmpd

# To test SNMP configuration
snmpwalk -v 2c -c <community> -O e <servername or IP address>
snmpwalk -v 2c -c not4you! -O e 192.168.50.20
snmpwalk -v 2c -c allowfromall! -O e 192.168.50.20

"Semoga artikel ini dapat bermanfaat"

Comments

Popular posts from this blog

Generating your SSH key in Windows

Pembahasan ini adalah kelanjutan dari " Creating a User Account " bisa teman-teman baca-baca pada halaman sebelum nya disini . Bagian ini saya membahas bagaimana cara nya membuat Public keys pada windows sehingga ketika login sudah tidak menggunakan password dan sangat memudahkan akan tetapi ketika Generate publik keys  di windows tidak bisa digunakan dari Terminal Linux , jika ingin supaya bisa dipergunakan di windows dan linux maka harus membuat public keys di linux. Untuk pembahasan Generate di linux akan saya bahas di slide selanjutnya dan bisa dibaca disini . Step 1. Download Putty terlebih dahulu disini  sesuaikan ke Opetaring System teman-teman Step 2. Setelah di download dan di instal buka Putty Key Generator, key comment, key pass dan confirm pass available bisa di isi ataupun tidak. dan pada saat melakukan Generate kursor temen-temen selalu digerakan supaya bisa sampai terbuat seperti dibawah ini. Step 3. Copy isi dari Public keys yang sudah dibuat dan paste pad...

Creating a User Account

Cara menambahkan user baru pada linux dengan menggunakan private key sangat mudah dan berikut ini cara nya : 1. Tambahkan nama user sesuai pada script dibawah ini     useradd nama_user -m -s /bin/bash 2. Masuk kedalam direktori user     cd /home/nama_user 3. Buat folder .ssh     mkdir .ssh 4. Berikan privilages pada folder tempat public key     chmod 0700 .ssh/ 5. Tambahkan authorized_keys yang mana ini akan berisi public key     touch .ssh/authorized_keys 6. Berikan privilages pada authorized_keys     chmod 0644 .ssh/authorized_keys 7. Berikan kepemilikan folder user     chown -R nama_user .ssh 8. Buka authorized_keys yang sudah di buat diatas lalu masukan blic key user  dan selanjut nya di simpan    nano .ssh/authorized_keys 9.  Cara menyimpan jika menggunaka perintah "nano" pada linux maka "ctrl+x" lalu ketik "Y" dan enter 10. Jika menggunakan perintah "vi" pada centos maka tekan "Esc" lalu "shi...

nginx proxy server localhost / loadbalancer permission denied

Ketika terjadi permaslasahan pada configurasi memang sangat menyebalkan tapi dari situ lah kita akan mendapat ilmu baru, pda kasus ini terjadi permasalahan "Permission denied" service yang di pakai nginx sebagai "loadbalancer" port default yang dipakai 80 tetapi dikarenakan webserverA dan webserverB menggunakan port 8080 kesulitan untuk forwarding ke webserver. cara pengecekan ya sebagaiberikut. 1. Lakukan dari luar curl -i 127.0.0.1:8080 jika terjadi seperti berikut ini.      curl -i 127.0.0.1:8080      HTTP/1.1 502 Bad Gateway      Server: nginx      Date: Wed, 08 Jul 2020 18:00:06 GMT      Content-Type: text/html      Content-Length: 150      Connection: keep-alive      <html>      <head><title>502 Bad Gateway</title></head>      <body>      <center><h1>502 Bad Gateway</h...