How to Install SNMP on a Virtual Machine (VM) Based on Your OS


Restu Oktafiandi
Published Blog · 4 min read · October 12, 2024

In this guide, we’ll walk you through the steps to install SNMP (Simple Network Management Protocol) on a virtual machine (VM), covering multiple operating systems. SNMP is a widely used protocol for monitoring and managing devices in a network, and setting it up in a VM can help you monitor network devices or simulate network environments.

SNMP is a protocol used for network management. It helps administrators manage network performance, find and solve network issues, and plan for network growth. SNMP works by sending data (known as SNMP messages) between network devices and a central management system.

Before installing SNMP, it’s crucial to configure your virtual machine’s network settings to use bridged networking mode. This allows the VM to be on the same network as your host machine and other physical devices. In bridged mode, the VM acts like a physical machine, receiving its own IP address from the network’s DHCP server.

Installing SNMP on Ubuntu/Debian

  1. Update your system packages
  2. 
      sudo apt update
    
    
    
  3. Install the SNMP package and agent
  4. 
      sudo apt install snmp snmpd
              
    
    
  5. Configure SNMP by editing the config file
  6. 
      sudo nano /etc/snmp/snmpd.conf
    
    
    

    Find the line that starts with agentAddress and change it to

    
      agentAddress udp:161,udp6:[::1]:161
    
    
    

    Change the community string from public to something more secure (e.g., your_community_string):

    
      rocommunity your_community_string
    
    
    
  7. Restart the SNMP service
  8. 
      sudo systemctl restart snmpd
    
    
    
  9. Check if SNMP is running
  10. 
      sudo systemctl status snmpd
    
    
    

The command snmpwalk -v 2c -c your_community_string localhost is used to test an SNMP (Simple Network Management Protocol) setup. It performs a walk through SNMP objects on a local machine (localhost), using version 2c (-v 2c) and the specified community string (-c your_community_string) to retrieve data. This helps in verifying SNMP configurations and ensuring that the system responds to SNMP queries.

If the community string is "public," the command would look like this


snmpwalk -v 2c -c public localhost
      

<< Back