How to log connections in OpenWRT?

Solution 1:

You can do this with log rules in the firewall. This will generate a lot of traffic, so you likely want to send the logs to another server. The default logger may truncate the logs so you may want to install another logger like syslog-ng as I documented in OpenWRT syslog-ng Installation. You won't geet the hostnames, as by the time they are being routed they have been converted to IP addresses.

You may want to use Shorewall or Shorewall-lite to generate the firewall for you.

If you are concerned about logging web traffic, then you may want to use Squid or some other proxy which will log all the accesses. Your Open-WRT router likely isn't likely to run it though.