You most likely have noticed that beside a service listed in the WebUI, there is nowhere to configure any options, and that attempting to start the service, it just won’t start.
The service has to be configured with the community string in order to be started. The only way of configuring the service, is using the shell.
1. Start the SSH service, if not already started
2. Login to the host with root credentials
3. Configure the community string using the following command :
esxcli system snmp set --communities community_name
Example – If your community name is “itechlounge”, the command would be :
esxcli system snmp set --communities itechlounge
4. Enable the service to start with the host :
esxcli system snmp set --enable true
OPTIONAL : If your host is directly connected to a public network, it is a very good idea to limit the exposure by adding a firewall rule to restrict to a certain IP or subnet (replace the example subnet 10.0.0.0/24 to fit your needs) :
esxcli network firewall ruleset set --ruleset-id snmp --allowed-all false esxcli network firewall ruleset allowedip add --ruleset-id snmp --ip-address 10.0.0.0/24 esxcli network firewall ruleset set --ruleset-id snmp --enabled true
5. Start the service :
/etc/init.d/snmpd restart
Additionally, here is how to configure SNMP traps :
esxcli system snmp set --targets target_IP_address@162/community_name
Note : SNMP service has to be restarted after setting SNMP traps as well.