>>Hardwa+Bj
When you receive a request to your website (or any service), that request comes from an IP address. There are databases that can tell you what country an IP address is from. It's not perfect, but it works well enough 99.99% of the time. Then, if the country is blacklisted, you do not allow access.