Trouble in getting the correct source IP for snmptrapd pods in zabbix kubernetes

Hi ,

Thanks in advance !!

I am facing an issue in a zabbix deployment in a kubernetes , it is related to snmptrap communication from external machine to zabbix-pod.
In zabbix-snmptrad pod , external ip is changes to some pod IP .

kindly look into this problem, and let me know the work-around to solving this issue.

Please find details below :

I am following the the url : “https://github.com/zabbix/zabbix-docker/blob/4.4/kubernetes.yaml
to deploy the zabbix containers in a kubernetes,
I successfully deployed it in a kubernetes,

but, I am facing an issue , while sending snmptrap from external machine(outside our cluster) to the zabbix-server (via zabbix-snmptraps container),
actually , the ZBXTRAP showing different ip than external machine and that different ip is in the network segment of k8s pod-cidr,
,and i think ZBXTRAP ip is use in zabbix-server web-ui to monitor the snmptrap , so correct IP should be assign to the ZBXTRAP, which has to be external machine IP.

here, the logs I am getting in zabbix-snmptraps container
, 192.168.43.192 – ZBXTRAP IP
172.19.8.104 – external-machine IP

#cat snmptraps.log
20200303.114748 ZBXTRAP 192.168.43.192 SNMPv2-MIB::coldStart 0 (null) SNMP-COMMUNITY-MIB::snmpTrapAddress.0 172.19.8.104 SNMP-COMMUNITY-MIB::snmpTrapCommunity.0 public SNMPv2-MIB::snmpTrapEnterprise.0 SNMPv2-SMI::snmpModules
20200303.114748 ZBXTRAP 192.168.43.192 SNMPv2-MIB::coldStart 0 (null) SNMP-COMMUNITY-MIB::snmpTrapAddress.0 172.19.8.104 SNMP-COMMUNITY-MIB::snmpTrapCommunity.0 public SNMPv2-MIB::snmpTrapEnterprise.0 SNMPv2-SMI::snmpModules

NOTE: when IP using the IP “192.168.43.192” , it is working fine and showing the snmptrap log in zabbix-web gui , but when I am using the “172.19.8.104” IP is doesn’t showing any log in zabbix-web.

1 Like

did u managed to solve the issue?
I’m in the same situation as you :frowning:

Hi All,

We also faced the same issue and fixed it after adding externalTrafficPolicy=Local to SnmpTrapd Service.

A service with a NodePort s a virtual entity managed by kube-proxy . This address/port combination is available on every node in the cluster and forwards any local (pod) service traffic to the endpoints IP and port.

The externalTrafficPolicy=Local setting makes a NodePort service use only a local Pod to service the incoming traffic. This avoids a network hop which removes the need to rewrite the source of the packet (via NAT). This results in the real network IP arriving at the pod servicing the connection, rather than one of the cluster nodes being the source IP.

Please refer below link: