Skip to content

Instantly share code, notes, and snippets.

@egeneralov
Created October 4, 2019 18:05
Show Gist options
  • Select an option

  • Save egeneralov/8fa37fdd5e4ad8baf69d68560bada9a6 to your computer and use it in GitHub Desktop.

Select an option

Save egeneralov/8fa37fdd5e4ad8baf69d68560bada9a6 to your computer and use it in GitHub Desktop.
#!/bin/bash -xe
cat << EOF > /etc/systemd/system/log-dns-query.service
[Unit]
Description=dns
[Service]
ExecStart=/bin/sh -c "script -q -c \"tcpdump -l port 53 2>/dev/null | grep --line-buffered ' A? ' | cut -d' ' -f8\" | tee -a /var/log/dns.log"
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl restart log-dns-query.service
journalctl -u log-dns-query.service -f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment