Dockerfile:
FROM ubuntu:latest
RUN apt update && apt install -y snmp snmpd && apt clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN sed -i 's/rocommunity/rwcommunity/g;s/127.0.0.1\,\[::1\]/0.0.0.0/g' /etc/snmp/snmpd.conf
COPY ./start.sh /
RUN chmod +x /start.sh
CMD ["/start.sh"]
start.sh:
#!/bin/bash
while sleep 2; do
if [[ $(snmpwalk -v2c -c public 127.0.0.1 iso.3.6.1.2.1.1.5.0 | awk '{print $4}' | tr -d '"') == "give-me-flag" ]]; then
snmpset -v2c -c public 127.0.0.1 iso.3.6.1.2.1.1.5.0 s "flag-is-this"
fi
done &
sleep 2 && snmpset -v2c -c public 127.0.0.1 iso.3.6.1.2.1.1.5.0 s "hostname-is-here" &
/usr/sbin/snmpd -Lo -a -f
Create two files Dockerfile and start.sh in one directory and build image with command:
docker build -t <image-name>:<tag> .
docker run -d --name snmpd -p 161:161/udp <image-name>:<tag>
or just run existing image with command:
docker run -d --name snmpd -p 161:161/udp rhxserver/snmpd:v2
Content type
Image
Digest
sha256:c5743e6d9…
Size
41.4 MB
Last updated
over 2 years ago
docker pull rhxserver/snmpd:v2