This can be done in more than one way. I use both.
You can use the access.conf file in your WWW server
(assuming you are running Apache). This is straight forward and is well documented on
http://www.apache.org/
You can also enable IP Firewall on your linux server. This
requires the right configuration parameters in the kernel plus a tool [ we use the command line ipfwadm() ] to set up the linux firewall.
The access.conf in Apache is easiest for WWW only concerns. However, the firewall tools are very robust and highly flexible (and more complex to configure).
There are www-based tools to simplify this, but I don't use them. If someone knows a good one, please post!