0

i use this command to live see apache logs: sudo tail -f /var/log/apache2/access.log I use a Ubuntu 18 VPS wich i have root access. this logs are also saved to the access.log file true? (because when i search some string in the live mode i find some things that i do not see when i use CAT to see the access.log file)

My questions is: is there a way to FOR every log to find info of the IP and save to another file the HOSTNAME of that IP together with the log data?

Diego
  • 1
  • 2
  • `grep 127.0.0.1 /var/log/apache/access*.log` would look for 127.0.0.1 in access*.log you just need to use `>mynewlog` to redirect the output – djdomi Sep 21 '22 at 17:33

1 Answers1

0

You can use one package from apache httpd bundle, named logresolve. With command like:

logresolve  < access.log > access.log.new

You can resolve the IPs from access.log. For more information you can check here.

If you want to extract only IPs you can use command like:

awk '{print $1} access.log|sort -u >IP_addresses
Romeo Ninov
  • 5,263
  • 4
  • 20
  • 26