Solution 1:

Amazon AWS's Route53 is a reliable and well priced global load balancer which utilizes anycast. This is by far the simplest route.

If you want to set up anycast DNS yourself you would need to obtain an IP address and have multiple datacentre locations advertise this IP address in their BGP. Typically people purchase IP address ranges from their relevant authority however I have seen some datacentres that are willing to lease people IP addresses and allow them to advertise them from other datacentres.

The typical set up is that each server has both its own unique IP address and an anycast address. For example:

London has 1.1.1.1 and 3.3.3.3 NY has 1.1.1.2 and 3.3.3.3

A DNS server runs on each server listening on 3.3.3.3 and issues the unique IP for that server.

Remember that anycast is at the IP layer and thus below transport technologies such as TCP. As such, any transport that tracks state (e.g. TCP) is not suitable for anycast. DNS is (usually) UDP and is used as a method of distributing clients to their closest server to make a TCP connection.

Solution 2:

You need to use a service that will base the DNS response on their location. Either outsourced to a DNS company or built yourself. I think the technology you are really looking for is Global Server Load Balancing (GSLB), not AnyCast.

Most DNS companies offer this as a service.

PowerDNS seems to be a popular solution for DIY GSLB: http://www.powerdns.com/auth.html