05
2024
08
17:16:43

开启VMware ESXi 5.5的SNMP服务 ESXi 5.5 配置firewall rule只允许特定的IP地址或者网段访问SSH和SNMP服务

8dd64f0c5d9d9a874e97c04df97d97b0_esxi_snmp_mib-600x142.png

因为需要监控ESXi vSphere 5.5 hosts 的数据,准备使用SNMP的方式获取需要的数据。但是发现ESXi5.5的SNMP默认是没有开启的(false),因此需要设置密码和开启ESXi的SNMP服务,为了安全起见只允许特定的IP地址或者IP段能够获取ESXi的SNMP的数据。

默认ESXi snmp的服务是关闭状态的

~ # cat /etc/vmware/snmp.xml
snmp_xml

esxcli system snmp set --communities public #设置SNMP的密码,建议不要使用通用的snmp密码public
esxcli system snmp set --enable true #设置启用snmp

esxcli network firewall ruleset set --ruleset-id snmp --allowed-all true #设置运行ESXi的防火墙通过snmp
esxcli network firewall ruleset set --ruleset-id snmp --enabled true

/etc/init.d/snmpd restart #重新启动snmp

You can change the firewall rule to only allow a specific subnet or host if you would like to.
为了安全起见只允许特定的IP地址或者IP段能够获取ESXi的SNMP的数据

esxcli network firewall ruleset set --ruleset-id snmp --allowed-all false
esxcli network firewall ruleset allowedip add --ruleset-id snmp --ip-address 192.168.12.0/24
esxcli network firewall ruleset set --ruleset-id snmp --enabled true
/etc/init.d/snmpd restart

# snmpwalk -v 2c -c public 192.168.12.237 .1 | grep Huawei
SNMPv2-SMI::mib-2.47.1.1.1.1.2.1 = STRING: "Huawei Technologies Co., Ltd. RH1288 V3"
SNMPv2-SMI::mib-2.47.1.1.1.1.12.1 = STRING: "Huawei Technologies Co., Ltd."

snmpwalk -v 2c -c public 192.168.12.237 sysDescr.0

snmpwalk -v 2c -c public 192.168.12.237 hrDeviceDescr.1

snmpwalk -v 2c -c public 192.168.12.237 mib-2.47.1.1.1.1.2.1

snmpwalk -v 2c -c public 192.168.12.237 enterprises.6876.3.5.2.1.5.1

使用 SNMPv2-MIB监控VMWARE ESXi的设备
esxi_open_snmp_service

esxi_snmp_mib


ESXi 5.5 配置firewall rule只允许特定的IP地址或者网段访问SSH和SNMP服务
只允许特定的IP地址或者IP段能够获取ESXi的SNMP的数据
You can change the firewall rule to only allow a specific subnet or host if you would like to.

esxcli network firewall ruleset set --ruleset-id snmp --allowed-all false
esxcli network firewall ruleset allowedip add --ruleset-id snmp --ip-address 192.168.12.0/24
esxcli network firewall ruleset set --ruleset-id snmp --enabled true
/etc/init.d/snmpd restart

只允许特定的IP地址或者IP段能够访问SSH服务

esxcli network firewall ruleset list

esxcli network firewall ruleset set --ruleset-id sshServer --allowed-all false
esxcli network firewall ruleset allowedip add --ruleset-id sshServer --ip-address 192.168.66.0/24
esxcli network firewall ruleset allowedip add --ruleset-id sshServer --ip-address 192.168.12.0/24
esxcli network firewall ruleset set --ruleset-id sshServer --enabled true
/etc/init.d/SSH restart

防火墙保存位置/etc/vmware/firewall/

chmod 744 /etc/vmware/firewall/service.xml
chmod +t /etc/vmware/firewall/service.xml

Refresh the firewall rules for the changes to take effect by running the command:
esxcli network firewall refresh
or
localcli network firewall refresh

reboot -f 重启ESXi,非必要步骤。
firewall_rule




推荐本站淘宝优惠价购买喜欢的宝贝:

image.png

本文链接:https://hqyman.cn/post/7426.html 非本站原创文章欢迎转载,原创文章需保留本站地址!

分享到:
打赏





休息一下~~


« 上一篇 下一篇 »

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

请先 登录 再评论,若不是会员请先 注册

您的IP地址是: