If you want to prevent a single user hitting F5 a million times from messing with your analytics you need to track IPs which requires the banner.
You need to disclose it in your privacy policy, you need to delete it after a reasonable retention period and you can't use those logs for other purposes like ad targeting, but you don't need a consent banner to track things that you are legitimately using for security purposes.
What makes that a legitimate interest and not advertising?
This part I guess