Jack Moore

Email: jack(at)jmoore53.com
Project Updates

IPv6 in the Homelab

16 Jan 2024 » code, infrastructure, docker

Capturing and logging IPv6 address attempts is essential for understanding network traffic and ensuring robust security measures. Accurate logging allows for detailed monitoring and helps in identifying potential threats or misconfigurations.

To effectively log IPv6 addresses and integrate logs with monitoring tools, syslog-ng was utilized along with some configurations on the Nginx server.

Initial Setup and Evaluation:

IPv6 tables configuration was evaluated on the Nginx server to ensure proper handling of IPv6 addresses. It was confirmed that logs do occur on containers and that they follow a structure similar to IPv4, which is suitable for the current setup. However, some adjustments were necessary to ensure comprehensive logging.

Nginx Logging Configuration:

The Nginx server was configured to log requests and errors, including those for IPv6 addresses. The following Nginx configuration was added to manage logs:

log_format timed_combined '$remote_addr - $remote_user [$time_local] '
                          '"$host" "$request" $status $body_bytes_sent '
                          '"$http_referer" "$http_user_agent" '
                          '$request_time $upstream_response_time $pipe';

access_log /var/log/nginx/timed_combined.log timed_combined;
access_log /var/log/nginx/access.log;
access_log syslog:server=10.100.0.252:514,tag=nginxSyslogAccess timed_combined;
error_log /var/log/nginx/error.log;
error_log syslog:server=10.100.0.252:514,tag=nginxSyslogError;

This configuration ensures that both access and error logs are captured and sent to the syslog-ng server. The use of log_format named timed_combined captures additional details such as request time and upstream response time, which are valuable for analyzing server performance and client behavior.

Syslog-ng Configuration:

To filter and properly display Nginx logs in the monitoring tools, a syslog-ng filter was configured:

filter f_syslog_nginx { match("nginxSyslogError") or match("nginxSyslogAccess"); };

This filter ensures that only relevant Nginx logs are processed, reducing noise and improving clarity in log analysis tools like Kibana.

Verifying Log Appearance in Kibana:

After configuring syslog-ng and Nginx, the logs were checked to ensure they appeared correctly in Kibana. The following filter was used to confirm the presence of Nginx logs:

syslog_program: "nginxSyslogAccess"

All logs from Nginx, including those with IPv6 addresses, were properly displayed and filtered in Kibana, indicating that the setup was successful.

Through careful configuration of Nginx and syslog-ng, accurate logging for IPv6 addresses was achieved. This setup ensures comprehensive monitoring of network traffic, enhances security measures, and provides valuable data for ongoing analysis and optimization.

© Jack Moore - This site was last built Fri 30 Aug 2024 12:31:24 PM EDT