Linux: Log Suspicious Martian Packets / Un-routable Source Addresses

To log suspicious Martian packets (packets with un-routable source addresses) in Linux, you can modify the kernel’s syslog configuration. Here is an example of how to do it:

  1. Edit the /etc/sysctl.conf file and add the following line:
net.ipv4.conf.all.log_martians = 1
  1. Save the changes and reload the sysctl configuration:
sysctl -p
  1. Configure the syslog daemon to log the messages generated by the kernel. You can do this by adding the following line to your syslog configuration file (e.g., /etc/rsyslog.d/50-default.conf):
kern.* /var/log/kernel.log
  1. Restart the syslog service:
systemctl restart syslog

Now, the kernel will log any Martian packets in the /var/log/kernel.log file. You can use tools like grep or tail to view the log and monitor for any suspicious activity.

Leave a Comment