This manner is usually wrong because the first virtual host may not be able to represent the whole server. So the trick I recommend is that we put a dummy virtual host as the first one in the configuration file. httpd will take it as the default host when there’s nothing in the server document root.
[root@test ~]# vi /etc/httpd/conf/httpd.conf
Redirect 404 /
As you can see, I redirect all attempts on the server IP to a 404 Not Found for any URI on this server. Of course, you can also redirect a 403 Forbidden in this dummy directive, but the anonymity of this server could be compromised. I will explain more in this post:
How to Return “404 Not Found” Instead of “403 Forbidden”
Please note that, the ServerName in the directive must match your server IP.