How to edit the hosts to block IP address? I know how to block certain website, like if I want to block google I can use this line in the host

0.0.0.0 www.google.com.hk
        www.google.com.hk


But my question is how can I block certain IP address? Like how can I block certain IP address like 17.154.66.79?
Technically, OS X can make use of /etc/hosts.allow and /etc/hosts.deny files that will  work with standard resolvable hostnames. For blocking IP addresses, using iptables is the usual method but apparently Apple deprecated its use beginning with Lion and switched to pf for this function. Check and read the links in this thread on SuperUser for info on using pf and perhaps a GUI front-end for it.