Code:
alias GetCountry {
  var %dns = $$?="Enter DNS"
  var %country = $gettok(%dns,-1,46)
  var %host = $deltok(%dns,-1,46)
}


Note that this will give you everything before the final "country" in the DNS as the host.

Examples:
www.google.co.uk
host: www.google.co
country: uk

I didn't automatically remove the first part (www in this case), because it can sometimes be part of the host if the www isn't present.

If you give some good examples of hosts that you want handled and how you want the %host variable to display the host, we can improve this for you. Or, just continue from where this script ends.

You should be able to take this and stick it into an on input event if you like. This was just to show how it's done.