How to ban a site (or a directory) access by IP address
If you want prevent someone (or something) to access your site from a given IP, you can do it easily adding following lines to your .htaccess file:
order allow,deny
deny from IP-ADDRESS
allow from all
(replace "IP-ADDRESS" with the IP address you need to block)
You can add as many "deny from" commands as needed.
You can specify a single IP (i.e. 111.111.111.111) or a class (i.e. 111.111.111. stay from "all IPs from 111.111.111.1 to 111.111.111.255")
How to restrict a site (or a directory) access by IP address
In order to secure a full site or a single directory (i.e., the admin area of a WordPress site), you can easily allow access only from your own IP.
Edit the .htaccess of the directory to procect, adding following lines:
order deny,allow
deny from all
allow from YOUR-IP-ADDRESS
(replace "YOUR-IP-ADDRESS" with your own IP address)