
Passives DNS-Capture- und Monitoring-Toolkit
Wir erkunden eine verwaltete SaaS-Lösung für dnsmonster! Helfen Sie mit, die Zukunft des passiven DNS-Monitorings zu gestalten, indem Sie Ihr Feedback und Ihre Anforderungen teilen: Nehmen Sie an unserer kurzen Umfrage teil
Inhaltsverzeichnis
Passives DNS-Überwachungsframework, erstellt mit Golang.
dnsmonster implementiert einen Paketsniffer für DNS-Verkehr. Es kann Verkehr aus einer pcap-Datei, einer Live-Schnittstelle oder einem dnstap-Socket akzeptieren und verwendet werden, um Hunderttausende von DNS-Abfragen pro Sekunde zu indizieren und zu speichern. Es hat gezeigt, dass es auf einem handelsüblichen Computer über 200.000 DNS-Abfragen pro Sekunde indizieren kann. Es zielt darauf ab, skalierbar, einfach und benutzerfreundlich zu sein und Sicherheitsteams zu helfen, die Details des DNS-Verkehrs eines Unternehmens zu verstehen. dnsmonster versucht nicht, DNS-Konversationen zu verfolgen, sondern zielt darauf ab, DNS-Pakete sofort zu indizieren, sobald sie eintreffen. Es versucht auch nicht, die Privatsphäre der Endbenutzer zu verletzen, da es Layer-3-IPs (IPv4 und IPv6) maskieren kann, sodass Teams Trendanalysen auf aggregierten Daten durchführen können, ohne die Abfragen einer Einzelperson zuordnen zu können. Blogbeitrag
Der Code vor Version 1.x wird als Beta-Qualität betrachtet und kann breaking changes unterliegen. Bitte besuchen Sie die Release-Notes für jedes Tag, um die Liste der Breaking Scenarios zwischen den einzelnen Versionen zu sehen und wie Sie potenziellen Datenverlust vermeiden können.```mermaid graph TD subgraph Input B1["network input"] B2["pcap file"] B3["dnstap socket"] end
subgraph "Process"
C1["Sampling based of ratio"]
C2["Packet Process"]
C3["Dispatcher"]
O11["Output1"]
O12["Domain Skip (optional)"]
O13["Domain Allow (optional)"]
O21["Output2"]
O22["Domain Skip (optional)"]
O23["Domain Allow (optional)"]
O31["Output3"]
O32["Domain Skip (optional)"]
O33["Domain Allow (optional)"]
end
B1 --> Process
B2 --> Process
B3 --> Process
C1 --> C2
C2 --> C3
C3 --> O11
C3 --> O21
C3 --> O31
O11 --> O12 --> O13
O21 --> O22 --> O23
O31 --> O32 --> O33
subgraph Output
Splunk
Syslog
H["ClickHouse"]
Postgres
Kafka
I["JSON File"]
Influx
Elastic
J["stdout"]
Parquet
Sentinel
end
O13 --> H
O23 --> I
O33 --> J
# Hauptmerkmale
- Fähigkeit, Linux' `afpacket` und Zero-Copy-Paketerfassung zu verwenden.
- Unterstützt BPF
- Fähigkeit, IP-Adressen zu maskieren, um die Privatsphäre zu verbessern
- Fähigkeit, ein Vorverarbeitungs-Sampling-Verhältnis festzulegen
- Fähigkeit, eine Liste von "skip" `fqdn`s zu haben, um das Schreiben bestimmter Domains/Suffixe/Präfixe in den Speicher zu vermeiden
- Fähigkeit, eine Liste von "allow"-Domains zu haben, um Zugriffe auf bestimmte Domains zu protokollieren
- Hot-Reload von Skip- und Allow-Domain-Dateien/URLs
- Modularer Output mit konfigurierbarer Logik pro Ausgabestream.
- Automatische Datenaufbewahrungsrichtlinie unter Verwendung von ClickHouses TTL-Attribut
- Integriertes Grafana-Dashboard für ClickHouse-Output.
- Fähigkeit, als einzelnes, statisch gelinktes Binärprogramm ausgeliefert zu werden
- Fähigkeit, mit Umgebungsvariablen, Befehlszeilenoptionen oder Konfigurationsdatei konfiguriert zu werden
- Fähigkeit, Ausgaben unter Verwendung von ClickHouses SAMPLE-Funktion zu sampeln
- Fähigkeit, Metriken mit `prometheus` und `statstd` zu senden
- Hohe Kompressionsrate dank ClickHouses integriertem LZ4-Speicher
- Unterstützt DNS Over TCP, fragmentiertes DNS (UDP/TCP) und IPv6
- Unterstützt [dnstap](https://github.com/dnstap/golang-dnstap) über Unix-Socket oder TCP
- Integrierte SIEM-Integration mit Splunk und Microsoft Sentinel
# Installation
## Linux
Die beste Möglichkeit, mit `dnsmonster` zu beginnen, ist das Herunterladen der Binärdatei aus dem Release-Bereich. Die Binärdatei ist statisch gegen `musl` gebaut, daher sollte sie auf vielen Distributionen sofort funktionieren. Für `afpacket`-Unterstützung benötigen Sie Kernel 3.x+. Jede moderne Linux-Distribution (CentOS/RHEL 7+, Ubuntu 14.0.4.2+, Debian 7+) wird mit einer 3.x+-Version ausgeliefert, sodass es sofort funktionieren sollte. Wenn Ihre Distribution mit der vorkompilierten Version nicht funktioniert, reichen Sie bitte ein Issue mit den Details ein und bauen Sie `dnsmonster` manuell mit diesem Abschnitt [Manuell bauen](#build-manually).
### Container
Da `dnsmonster` Rohpaketerfassungsfunktionalität verwendet, muss der Docker/Podman-Daemon dem Container die entsprechende Capability gewähren```
sudo docker run --rm -it --net=host --cap-add NET_RAW --cap-add NET_ADMIN --name dnsmonster ghcr.io/mosajjal/dnsmonster:latest --devName lo --stdoutOutputType=1
libpcap:
Stellen Sie sicher, dass die Pakete go, libpcap-devel und linux-headers installiert sind. Die Namen der Pakete können je nach Ihrer Distribution abweichen. Danach klonen Sie einfach das Repository und führen Sie go build ./cmd/dnsmonster aus.```sh
git clone https://github.com/mosajjal/dnsmonster --depth 1 /tmp/dnsmonster
cd /tmp/dnsmonster
go get
go build -o dnsmonster ./cmd/dnsmonster- ohne `libpcap`:
`dnsmonster` nutzt nur eine einzige Funktion von `libpcap`, und zwar die Umwandlung der `tcpdump`-artigen Filter in BPF-Bytecode. Wenn Sie ohne BPF-Unterstützung auskommen können, können Sie `dnsmonster` ohne `libpcap` bauen. Beachten Sie, dass die Paketerfassung auf allen anderen Plattformen auf `libpcap` zurückfällt, sodass es zu einer harten Abhängigkeit wird (*BSD, Windows, Darwin)```sh
git clone https://github.com/mosajjal/dnsmonster --depth 1 /tmp/dnsmonster
cd /tmp/dnsmonster
go get
go build -o dnsmonster -tags nolibpcap ./cmd/dnsmonster
Wenn Sie eine Kopie von libpcap.a besitzen, können Sie es statisch mit dnsmonster verlinken und ein vollständig statisches Build erstellen. Im folgenden Code ändern Sie bitte /root/libpcap-1.9.1/libpcap.a zum Speicherort Ihrer Kopie.```
git clone https://github.com/mosajjal/dnsmonster --depth 1 /tmp/dnsmonster
cd /tmp/dnsmonster/
go get
go build --ldflags "-L /root/libpcap-1.9.1/libpcap.a -linkmode external -extldflags "-I/usr/include/libnl3 -lnl-genl-3 -lnl-3 -static"" -a -o dnsmonster ./cmd/dnsmonster
Weitere Informationen zur Erstellung der statisch gelinkten Binärdatei finden Sie in [diesem](https://github.com/fenkohq/dnsmonster/blob/main/Dockerfile) Dockerfile.
## Windows
Das Erstellen unter Windows ist weitgehend dasselbe wie unter Linux. Stellen Sie einfach sicher, dass Sie `npcap` installiert haben. Klonen Sie das Repository (`--history 1` funktioniert) und führen Sie `go get` und `go build ./cmd/dnsmonster` aus.
Wie bereits erwähnt, ist für die Windows-Version der Binärdatei die Installation von [npcap](https://nmap.org/npcap/#download) erforderlich. Nach der Installation sollte die Binärdatei sofort funktionieren. Sie wurde in einer Windows 10-Umgebung getestet und funktionierte problemlos. Um die Schnittstellennamen für den Parameter `--devName` zu ermitteln und mit dem Sniffing zu beginnen, gehen Sie wie folgt vor:
- Öffnen Sie cmd.exe als Administrator und führen Sie Folgendes aus: `getmac.exe`. Sie sehen eine Tabelle mit den MAC-Adressen Ihrer Schnittstellen und einer Spalte „Transport Name“ mit einem Eintrag wie diesem: `\Device\Tcpip_{16000000-0000-0000-0000-145C4638064C}`
- Führen Sie `dnsmonster.exe` in `cmd.exe` wie folgt aus:```sh
dnsmonster.exe --devName \Device\NPF_{16000000-0000-0000-0000-145C4638064C}
Beachten Sie, dass Sie \Tcpip von getmac.exe in \NPF ändern und dann an dnsmonster.exe übergeben müssen.
Ähnlich wie bei Linux und Windows, stellen Sie sicher, dass git, libpcap und go installiert sind, und folgen Sie dann den gleichen Anweisungen:```sh
git clone https://github.com/mosajjal/dnsmonster --depth 1 /tmp/dnsmonster
cd /tmp/dnsmonster
go get
go build -o dnsmonster ./cmd/dnsmonster
# Architecture
## All-in-One-Installation mit Docker

Im Beispiel-Diagramm wird der eingehende/ausgehende Datenverkehr des DNS-Servers erfasst. Danach wird eine optionale Paketaggregationsebene hinzugefügt, bevor der Datenverkehr den DNSMonster-Server erreicht. Die ausgehenden Daten der DNS-Server sind sehr nützlich für die Cache- und Leistungsanalyse der DNS-Flotte. Falls kein Aggregator verfügbar ist, können Sie beide TAPs direkt mit DNSMonster verbinden und zwei DNSMonster-Agenten den Datenverkehr überwachen lassen.
Das Ausführen von `./autobuild.sh` erstellt mehrere Container:
* mehrere Instanzen von `dnsmonster`, um den Datenverkehr auf jeder Schnittstelle zu überwachen. Die Schnittstellenliste wird im Rahmen von `autobuild.sh` abgefragt.
* eine Instanz von `clickhouse`, um die Ausgabe von `dnsmonster` zu sammeln und alle Protokolle/Daten in einem Daten- und einem Protokollverzeichnis zu speichern. Beide werden im Rahmen von `autobuild.sh` abgefragt.
* eine Instanz von `grafana`, die auf die `clickhouse`-Daten mit einem vorgefertigten Dashboard zugreift.
### All-in-One-Demo
[](static/aio_demo.svg)
## Unternehmenseinsatz

# Konfiguration
DNSMonster kann auf drei verschiedene Arten konfiguriert werden: über Befehlszeilenoptionen, Umgebungsvariablen und Konfigurationsdatei. Rangfolge:
- Befehlszeilenoptionen (Groß-/Kleinschreibung wird nicht beachtet)
- Umgebungsvariablen (immer Großbuchstaben)
- Konfigurationsdatei (Groß-/Kleinschreibung wird beachtet, Kleinbuchstaben)
- Standardwerte (keine Konfiguration)
## Befehlszeilenoptionen
Beachten Sie, dass Befehlszeilenargumente ab Version v0.9.5 die Groß-/Kleinschreibung nicht beachten.
[//]: <> (start of command line options)```sh
# [capture]
# Device used to capture
--devname=
# Pcap filename to run
--pcapfile=
# dnstap socket path. Example: unix:///tmp/dnstap.sock, tcp://127.0.0.1:8080
--dnstapsocket=
# Port selected to filter packets
--port=53
# Capture Sampling by a:b. eg sampleRatio of 1:100 will process 1 percent of the incoming packets
--sampleratio=1:1
# Cleans up packet hash table used for deduplication
--dedupcleanupinterval=1m0s
# Set the dnstap socket permission, only applicable when unix:// is used
--dnstappermission=755
# Number of routines used to handle received packets
--packethandlercount=2
# Size of the tcp assembler
--tcpassemblychannelsize=10000
# Size of the tcp result channel
--tcpresultchannelsize=10000
# Number of routines used to handle tcp packets
--tcphandlercount=1
# Size of the channel to send packets to be defragged
--defraggerchannelsize=10000
# Size of the channel where the defragged packets are returned
--defraggerchannelreturnsize=10000
# Size of the packet handler channel
--packetchannelsize=1000
# Afpacket Buffersize in MB
--afpacketbuffersizemb=64
# BPF filter applied to the packet stream. If port is selected, the packets will not be defragged.
--filter=((ip and (ip[9] == 6 or ip[9] == 17)) or (ip6 and (ip6[6] == 17 or ip6[6] == 6 or ip6[6] == 44)))
# Use AFPacket for live captures. Supported on Linux 3.0+ only
--useafpacket
# The PCAP capture does not contain ethernet frames
--noetherframe
# Deduplicate incoming packets, Only supported with --devName and --pcapFile. Experimental
--dedup
# Do not put the interface in promiscuous mode
--nopromiscuous
# [clickhouse_output]
# Address of the clickhouse database to save the results. multiple values can be provided.
--clickhouseaddress=localhost:9000
# Username to connect to the clickhouse database
--clickhouseusername=
# Password to connect to the clickhouse database
--clickhousepassword=
# Database to connect to the clickhouse database
--clickhousedatabase=default
# Table which data will be stored on clickhouse database
--clickhousetable=DNS_LOG
# Interval between sending results to ClickHouse. If non-0, Batch size is ignored and batch delay is used
--clickhousedelay=0s
# Clickhouse connection LZ4 compression level, 0 means no compression
--clickhousecompress=0
# Debug Clickhouse connection
--clickhousedebug
# Use TLS for Clickhouse connection
--clickhousesecure
# Save full packet query and response in JSON format.
--clickhousesavefullquery
# Use DNSTap identity field instead of ServerName for the identity field in ClickHouse
--clickhouseusednstapidentity
# What should be written to clickhouse. options:
# 0: Disable Output
# 1: Enable Output without any filters
# 2: Enable Output and apply skipdomains logic
# 3: Enable Output and apply allowdomains logic
# 4: Enable Output and apply both skip and allow domains logic
--clickhouseoutputtype=0
# Minimum capacity of the cache array used to send data to clickhouse. Set close to the queries per second received to prevent allocations
--clickhousebatchsize=100000
# Number of Clickhouse output Workers
--clickhouseworkers=1
# Channel Size for each Clickhouse Worker
--clickhouseworkerchannelsize=100000
# [elastic_output]
# What should be written to elastic. options:
# 0: Disable Output
# 1: Enable Output without any filters
# 2: Enable Output and apply skipdomains logic
# 3: Enable Output and apply allowdomains logic
# 4: Enable Output and apply both skip and allow domains logic
--elasticoutputtype=0
# elastic endpoint address, example: http://127.0.0.1:9200. Used if elasticOutputType is not none
--elasticoutputendpoint=
# elastic index
--elasticoutputindex=default
# Send data to Elastic in batch sizes
--elasticbatchsize=1000
# Interval between sending results to Elastic if Batch size is not filled
--elasticbatchdelay=1s
# [file_output]
# What should be written to file. options:
# 0: Disable Output
# 1: Enable Output without any filters
# 2: Enable Output and apply skipdomains logic
# 3: Enable Output and apply allowdomains logic
# 4: Enable Output and apply both skip and allow domains logic
--fileoutputtype=0
# Path to output folder. Used if fileoutputType is not none
--fileoutputpath=
# Interval to rotate the file in cron format
--fileoutputrotatecron=0 0 * * *
# Number of files to keep. 0 to disable rotation
--fileoutputrotatecount=4
# Output format for file. options:json, csv, csv_no_header, gotemplate. note that the csv splits the datetime format into multiple fields
--fileoutputformat=json
# Go Template to format the output as needed
--fileoutputgotemplate={{.}}
# [influx_output]
# What should be written to influx. options:
# 0: Disable Output
# 1: Enable Output without any filters
# 2: Enable Output and apply skipdomains logic
# 3: Enable Output and apply allowdomains logic
# 4: Enable Output and apply both skip and allow domains logic
--influxoutputtype=0
# influx Server address, example: http://localhost:8086. Used if influxOutputType is not none
--influxoutputserver=
# Influx Server Auth Token
--influxoutputtoken=dnsmonster
# Influx Server Bucket
--influxoutputbucket=dnsmonster
# Influx Server Org
--influxoutputorg=dnsmonster
# Minimum capacity of the cache array used to send data to Influx
--influxoutputworkers=8
# Minimum capacity of the cache array used to send data to Influx
--influxbatchsize=1000
# [kafka_output]
# What should be written to kafka. options:
# 0: Disable Output
# 1: Enable Output without any filters
# 2: Enable Output and apply skipdomains logic
# 3: Enable Output and apply allowdomains logic
# 4: Enable Output and apply both skip and allow domains logic
--kafkaoutputtype=0
# kafka broker address(es), example: 127.0.0.1:9092. Used if kafkaOutputType is not none
--kafkaoutputbroker=
# Kafka topic for logging
--kafkaoutputtopic=dnsmonster
# Minimum capacity of the cache array used to send data to Kafka
--kafkabatchsize=1000
# Output format. options:json, gob.
--kafkaoutputformat=json
# Kafka connection timeout in seconds
--kafkatimeout=3
# Interval between sending results to Kafka if Batch size is not filled
--kafkabatchdelay=1s
# Compress Kafka connection
--kafkacompress
# Compression Type Kafka connection [snappy gzip lz4 zstd]; default(snappy).
--kafkacompressiontype=snappy
# Use TLS for kafka connection
--kafkasecure
# Path of CA certificate that signs Kafka broker certificate
--kafkacacertificatepath=
# Path of TLS certificate to present to broker
--kafkatlscertificatepath=
# Path of TLS certificate key
--kafkatlskeypath=
# [parquet_output]
# What should be written to parquet file. options:
# 0: Disable Output
# 1: Enable Output without any filters
# 2: Enable Output and apply skipdomains logic
# 3: Enable Output and apply allowdomains logic
# 4: Enable Output and apply both skip and allow domains logic
--parquetoutputtype=0
# Path to output folder. Used if parquetoutputtype is not none
--parquetoutputpath=
# Number of records to write to parquet file before flushing
--parquetflushbatchsize=10000
# Number of workers to write to parquet file
--parquetworkercount=4
# Size of the write buffer in bytes
--parquetwritebuffersize=256000
# [psql_output]
# What should be written to Microsoft Psql. options:
# 0: Disable Output
# 1: Enable Output without any filters
# 2: Enable Output and apply skipdomains logic
# 3: Enable Output and apply allowdomains logic
# 4: Enable Output and apply both skip and allow domains logic
--psqloutputtype=0
# Psql endpoint used. must be in uri format. example: postgres://username:password@hostname:port/database?sslmode=disable
--psqlendpoint=
# Psql table which data will be stored on database
--psqltable=DNS_LOG
# Number of PSQL workers
--psqlworkers=1
# Psql Batch Size
--psqlbatchsize=1
# Interval between sending results to Psql if Batch size is not filled. Any value larger than zero takes precedence over Batch Size
--psqlbatchdelay=0s
# Timeout for any INSERT operation before we consider them failed
--psqlbatchtimeout=5s
# Save full packet query and response in JSON format.
--psqlsavefullquery
# [sentinel_output]
# What should be written to Microsoft Sentinel. options:
# 0: Disable Output
# 1: Enable Output without any filters
# 2: Enable Output and apply skipdomains logic
# 3: Enable Output and apply allowdomains logic
# 4: Enable Output and apply both skip and allow domains logic
--sentineloutputtype=0
# Sentinel Shared Key, either the primary or secondary, can be found in Agents Management page under Log Analytics workspace
--sentineloutputsharedkey=
# Sentinel Customer Id. can be found in Agents Management page under Log Analytics workspace
--sentineloutputcustomerid=
# Sentinel Output LogType
--sentineloutputlogtype=dnsmonster
# Sentinel Output Proxy in URI format
--sentineloutputproxy=
# Sentinel Batch Size
--sentinelbatchsize=100
# Interval between sending results to Sentinel if Batch size is not filled. Any value larger than zero takes precedence over Batch Size
--sentinelbatchdelay=0s
# [splunk_output]
# What should be written to HEC. options:
# 0: Disable Output
# 1: Enable Output without any filters
# 2: Enable Output and apply skipdomains logic
# 3: Enable Output and apply allowdomains logic
# 4: Enable Output and apply both skip and allow domains logic
--splunkoutputtype=0
# splunk endpoint address, example: http://127.0.0.1:8088. Used if splunkOutputType is not none, can be specified multiple times for load balanace and HA
--splunkoutputendpoint=
# Splunk HEC Token
--splunkoutputtoken=00000000-0000-0000-0000-000000000000
# Splunk Output Index
--splunkoutputindex=temp
# Splunk Output Proxy in URI format
--splunkoutputproxy=
# Splunk Output Source
--splunkoutputsource=dnsmonster
# Splunk Output Sourcetype
--splunkoutputsourcetype=json
# Send data to HEC in batch sizes
--splunkbatchsize=1000
# Interval between sending results to HEC if Batch size is not filled
--splunkbatchdelay=1s
# [stdout_output]
# What should be written to stdout. options:
# 0: Disable Output
# 1: Enable Output without any filters
# 2: Enable Output and apply skipdomains logic
# 3: Enable Output and apply allowdomains logic
# 4: Enable Output and apply both skip and allow domains logic
--stdoutoutputtype=0
# Output format for stdout. options:json,csv, csv_no_header, gotemplate. note that the csv splits the datetime format into multiple fields
--stdoutoutputformat=json
# Go Template to format the output as needed
--stdoutoutputgotemplate={{.}}
# Number of workers
--stdoutoutputworkercount=8
# [syslog_output]
# What should be written to Syslog server. options:
# 0: Disable Output
# 1: Enable Output without any filters
# 2: Enable Output and apply skipdomains logic
# 3: Enable Output and apply allowdomains logic
# 4: Enable Output and apply both skip and allow domains logic
--syslogoutputtype=0
# Syslog endpoint address, example: udp://127.0.0.1:514, tcp://127.0.0.1:514. Used if syslogOutputType is not none
--syslogoutputendpoint=udp://127.0.0.1:514
# [victoria_output]
# Victoria Output Endpoint. example: http://localhost:9428/insert/jsonline?_msg_field=rcode_id&_time_field=time
--victoriaoutputendpoint=
# What should be written to Microsoft Victoria. options:
# 0: Disable Output
# 1: Enable Output without any filters
# 2: Enable Output and apply skipdomains logic
# 3: Enable Output and apply allowdomains logic
# 4: Enable Output and apply both skip and allow domains logic
--victoriaoutputtype=0
# Victoria Output Proxy in URI format
--victoriaoutputproxy=
# Number of workers
--victoriaoutputworkers=8
# Victoria Batch Size
--victoriabatchsize=100
# Interval between sending results to Victoria if Batch size is not filled. Any value larger than zero takes precedence over Batch Size
--victoriabatchdelay=0s
# [zinc_output]
# What should be written to zinc. options:
# 0: Disable Output
# 1: Enable Output without any filters
# 2: Enable Output and apply skipdomains logic
# 3: Enable Output and apply allowdomains logic
# 4: Enable Output and apply both skip and allow domains logic
--zincoutputtype=0
# index used to save data in Zinc
--zincoutputindex=dnsmonster
# zinc endpoint address, example: http://127.0.0.1:9200/api/default/_bulk. Used if zincOutputType is not none
--zincoutputendpoint=
# zinc username, example: [email protected]. Used if zincOutputType is not none
--zincoutputusername=
# zinc password, example: password. Used if zincOutputType is not none
--zincoutputpassword=
# Send data to Zinc in batch sizes
--zincbatchsize=1000
# Interval between sending results to Zinc if Batch size is not filled
--zincbatchdelay=1s
# Zing request timeout
--zinctimeout=10s
# [general]
# Garbage Collection interval for tcp assembly and ip defragmentation
--gctime=10s
# Duration to calculate interface stats
--capturestatsdelay=1s
# Mask IPv4s by bits. 32 means all the bits of IP is saved in DB
--masksize4=32
# Mask IPv6s by bits. 32 means all the bits of IP is saved in DB
--masksize6=128
# Name of the server used to index the metrics.
--servername=default
# Set debug Log format
--logformat=text
# Set debug Log level, 0:PANIC, 1:ERROR, 2:WARN, 3:INFO, 4:DEBUG
--loglevel=3
# Size of the result processor channel size
--resultchannelsize=100000
# write cpu profile to file
--cpuprofile=
# write memory profile to file
--memprofile=
# GOMAXPROCS variable
--gomaxprocs=-1
# Limit of packets logged to clickhouse every iteration. Default 0 (disabled)
--packetlimit=0
# Skip outputing domains matching items in the CSV file path. Can accept a URL (http:// or https://) or path
--skipdomainsfile=
# Hot-Reload skipdomainsfile interval
--skipdomainsrefreshinterval=1m0s
# Allow Domains logic input file. Can accept a URL (http:// or https://) or path
--allowdomainsfile=
# Hot-Reload allowdomainsfile file interval
--allowdomainsrefreshinterval=1m0s
# Skip TLS verification when making HTTPS connections
--skiptlsverification
# [metric]
# Metric Endpoint Service
--metricendpointtype=
# Statsd endpoint. Example: 127.0.0.1:8125
--metricstatsdagent=
# Prometheus Registry endpoint. Example: http://0.0.0.0:2112/metric
--metricprometheusendpoint=
# Format for output.
--metricformat=json
# Interval between sending results to Metric Endpoint
--metricflushinterval=10s
Alle Flags können auch über Umgebungsvariablen gesetzt werden. Beachten Sie, dass der Name jedes Parameters immer in Großbuchstaben ist und das Präfix für alle Variablen "DNSMONSTER" ist.
Beispiel:```shell $ export DNSMONSTER_PORT=53 $ export DNSMONSTER_DEVNAME=lo $ sudo -E dnsmonster
## Konfigurationsdatei
Sie können `dnsmonster` mit dem folgenden Befehl ausführen, um die Konfigurationsdatei zu verwenden:```shell
$ sudo dnsmonster --config=dnsmonster.ini
# Or you can use environment variables to set the configuration file path
$ export DNSMONSTER_CONFIG=dnsmonster.ini
$ sudo -E dnsmonster
Die Standard-Aufbewahrungsrichtlinie für die ClickHouse-Tabellen ist auf 30 Tage festgelegt. Sie können die Anzahl ändern, indem Sie die Container mit ./autobuild.sh erstellen. Da ClickHouse keinen internen Zeitstempel hat, prüft die TTL das Datum eingehender Pakete in pcap-Dateien. Beim Importieren alter pcap-Dateien kann ClickHouse also automatisch beginnen, die Daten zu entfernen, während sie geschrieben werden, und Sie werden in Ihrem Grafana keine tatsächlichen Daten sehen. Um das zu beheben, können Sie die TTL auf einen Tag älter als Ihr frühestes Paket in der PCAP-Datei ändern.
HINWEIS: Um eine TTL zu einem beliebigen Zeitpunkt zu ändern, müssen Sie eine direkte Verbindung zum Clickhouse-Server mit einem clickhouse-Client herstellen und die folgende SQL-Anweisung ausführen (dieses Beispiel ändert sie von 30 auf 90 Tage):```sql
ALTER TABLE DNS_LOG MODIFY TTL DnsDate + INTERVAL 90 DAY;`
HINWEIS: Der obige Befehl ändert nur die TTL für die rohen DNS-Protokolldaten, die den Großteil Ihres Kapazitätsverbrauchs ausmachen. Um sicherzustellen, dass Sie die TTL für jede einzelne Aggregationstabelle anpassen, können Sie Folgendes ausführen:```sql
ALTER TABLE DNS_LOG MODIFY TTL DnsDate + INTERVAL 90 DAY;
ALTER TABLE `.inner.DNS_DOMAIN_COUNT` MODIFY TTL DnsDate + INTERVAL 90 DAY;
ALTER TABLE `.inner.DNS_DOMAIN_UNIQUE` MODIFY TTL DnsDate + INTERVAL 90 DAY;
ALTER TABLE `.inner.DNS_PROTOCOL` MODIFY TTL DnsDate + INTERVAL 90 DAY;
ALTER TABLE `.inner.DNS_GENERAL_AGGREGATIONS` MODIFY TTL DnsDate + INTERVAL 90 DAY;
ALTER TABLE `.inner.DNS_EDNS` MODIFY TTL DnsDate + INTERVAL 90 DAY;
ALTER TABLE `.inner.DNS_OPCODE` MODIFY TTL DnsDate + INTERVAL 90 DAY;
ALTER TABLE `.inner.DNS_TYPE` MODIFY TTL DnsDate + INTERVAL 90 DAY;
ALTER TABLE `.inner.DNS_CLASS` MODIFY TTL DnsDate + INTERVAL 90 DAY;
ALTER TABLE `.inner.DNS_RESPONSECODE` MODIFY TTL DnsDate + INTERVAL 90 DAY;
ALTER TABLE `.inner.DNS_SRCIP_MASK` MODIFY TTL DnsDate + INTERVAL 90 DAY;
UPDATE: In der neuesten Version von clickhouse haben die .inner-Tabellen nicht denselben Namen wie die entsprechenden Aggregationsansichten. Um die TTL zu ändern, müssen Sie die Tabellennamen im UUID-Format mit SHOW TABLES finden und den ALTER-Befehl mit diesen UUIDs wiederholen.
dnsmonster unterstützt Pre-Process-Sampling von Paketen mittels eines einfachen Parameters: sampleRatio. Dieser Parameter akzeptiert einen "Ratio"-Wert wie 1:2. 1:2 bedeutet, dass von jeweils zwei ankommenden Paketen nur eines verarbeitet wird (50% Sampling). Beachten Sie, dass dieses Sampling NACH den bpf-Filtern und nicht davor stattfindet. Wenn Sie Probleme haben, mit dem Volumen Ihres DNS-Datenverkehrs Schritt zu halten, können Sie dies auf z. B. 2:10 setzen, was bedeutet, dass 20% der Pakete, die Ihren bpf-Filter passieren, von dnsmonster verarbeitet werden.
dnsmonster unterstützt eine Post-Process-Domain-Skip-Liste, um das Schreiben von verrauschten, sich wiederholenden Daten in Ihre Datenbank zu vermeiden. Die Domain-Skip-Liste ist eine CSV-formatierte Datei mit nur zwei Spalten: einer Zeichenfolge und einer Logik für diese bestimmte Zeichenfolge. dnsmonster unterstützt drei Logiken: prefix, suffix und fqdn. prefix und suffix bedeuten, dass nur Domains, die mit der angegebenen Zeichenfolge beginnen/enden, vom Schreiben in die DB ausgeschlossen werden. Beachten Sie, dass die Verarbeitung der DNS-Fragen erfolgt, daher wird Ihre Zeichenfolge höchstwahrscheinlich einen abschließenden . haben, der auch in Ihrer Skip-Liste enthalten sein muss (sehen Sie sich zur besseren Veranschaulichung skipdomains.csv.sample an). Sie können auch einen vollständigen FQDN-Abgleich durchführen, um das Schreiben stark verrauschter FQDNs in Ihre Datenbank zu vermeiden.
dnsmonster verfügt über das Konzept der Allowdomains, das dabei hilft, die Erkennung zu erstellen, wenn bestimmte FQDNs, Präfixe oder Suffixe im DNS-Datenverkehr vorhanden sind. Da dnsmonster mehrere Ausgabestreams mit unterschiedlicher Logik für jeden unterstützt, ist es möglich, den gesamten DNS-Datenverkehr in ClickHouse zu sammeln, aber nur Allowlist-Domains in der Standardausgabe oder in einer Datei in derselben Instanz von dnsmonster zu sammeln.
Standardmäßig haben die Haupttabellen, die von tables.sql (DNS_LOG) erstellt werden, die Fähigkeit, ein Ergebnis bei Bedarf herunterzurechnen, da jede DNS-Frage eine semi-eindeutige UUID besitzt. Weitere Informationen zu SAMPLE-Abfragen in Clickhouse finden Sie in diesem Dokument.
HINWEIS: Wenn Ihre pcap-Datei von einer der Meta-Interfaces von Linux erfasst wurde (z. B. tcpdump -i any), kann dnsmonster den Ethernet-Frame nicht daraus lesen, da dieser nicht existiert. Sie können ein Tool wie tcprewrite verwenden, um die pcap-Datei in Ethernet zu konvertieren.
afpacket-UnterstützungallowDomains und skipDomains von HTTP(S)-Endpunkten zu ladenlibpcap-Abhängigkeit und Umstellung auf pcapgo für die Paketverarbeitungstatsd- und Prometheus-Unterstützung![]() | Kostenloses Code-Signing unter Windows bereitgestellt von signpath.io, Zertifikat von der SignPath Foundation |