Connection access to certain countries

I want to give users from certain country access to get succesful connection, if country not match than it must not get access. I just do not know how to check that it comes from the right country ip

Example;

ip = socket.request.connection.remoteAddress;
if (ip === 'de'){
 give acces 
{ else }
 callback('INVALID_COUNTRY');
}

What is the best way to check variable ip if the IP is from Germany for example or France