Snmpd Listen to Specific IP Address ( BIND To Selected Interfaces )

By default, snmpd listens on all available network interfaces. However, you can configure it to listen only on specific IP addresses or network interfaces. Here’s how to do it:

  1. Edit the snmpd configuration file, usually located at /etc/snmp/snmpd.conf, using your favorite text editor.
  2. Find the line that starts with agentAddress, which specifies the network address and port that snmpd listens on.
  3. Change the line to specify the IP address and port that you want snmpd to listen on. For example, to bind snmpd to the IP address 192.168.1.10 and port 161, use the following line:
agentAddress udp:192.168.1.10:161
  1. Save the changes to the configuration file and restart snmpd to apply the new configuration:
# systemctl restart snmpd

This will cause snmpd to only listen on the specified IP address and port. If you have multiple network interfaces and want to bind snmpd to a specific interface, you can use the interface name instead of the IP address in the agentAddress line. For example, to bind snmpd to the eth0 interface, use the following line:

agentAddress udp:eth0:161

Note that you can also specify a range of IP addresses using CIDR notation, such as 192.168.1.0/24, to listen on all IP addresses in that range.

Leave a Comment