Just search for the IP range of the countries, normally forum software allow for banning of IPs, just add them in.
Do you mean to make your forums safe from hackers? That would mean you are suggesting hackers are all from one country. Hmmm, there everywhere.
I don't see how you could prevent someone from a certain country to access your forum except when you specifically identified the allowed countries in the registration page through a drop-down menu. Even then, the likely perpetrator can still choose another country so you're still dead. But why need to ban a country? ... It's pity how some people could ruin the chances of their own country and their countrymen because of some bad practices. What about the good guys in that country who want to gain access to your site, who might have useful contributions? Oh, well, that's your call. Try wisdomtool's suggestion. That could be done in the .htaccess