github.com/outbrain/consul@v1.4.5/website/source/docs/guides/external.html.md (about) 1 --- 2 layout: "docs" 3 page_title: "External Services" 4 sidebar_current: "docs-guides-external" 5 description: |- 6 Very few infrastructures are entirely self-contained. Most rely on a multitude of external service providers. Consul supports this by allowing for the definition of external services, services that are not provided by a local node. 7 --- 8 9 # Registering an External Service 10 11 Very few infrastructures are entirely self-contained. Most rely on a multitude 12 of external service providers. Consul supports this by allowing for the definition 13 of external services, services that are not provided by a local node. There's also a 14 companion project called [Consul ESM](https://github.com/hashicorp/consul-esm) which 15 is a daemon that functions as an external service monitor that can help run health 16 checks for external services. 17 18 Most services are registered in Consul through the use of a 19 [service definition](/docs/agent/services.html). However, this approach registers 20 the local node as the service provider. In the case of external services, we must 21 instead register the service with the catalog rather than as part of a standard 22 node service definition. 23 24 Once registered, the DNS interface will be able to return the appropriate A 25 records or CNAME records for the service. The service will also appear in standard 26 queries against the API. Consul must be configured with a list of 27 [recursors](/docs/agent/options.html#recursors) for it to be able to resolve 28 external service addresses. 29 30 Let us suppose we want to register a "search" service that is provided by 31 "www.google.com". We might accomplish that like so: 32 33 ```text 34 $ curl -X PUT -d '{"Datacenter": "dc1", "Node": "google", 35 "Address": "www.google.com", 36 "Service": {"Service": "search", "Port": 80}}' 37 http://127.0.0.1:8500/v1/catalog/register 38 ``` 39 40 Add an upstream DNS server to the list of recursors to Consul's configuration. Example with Google's public DNS server: 41 ```text 42 "recursors":["8.8.8.8"] 43 ``` 44 45 If we do a DNS lookup now, we can see the new search service: 46 47 ```text 48 ; <<>> DiG 9.8.3-P1 <<>> @127.0.0.1 -p 8600 search.service.consul. 49 ; (1 server found) 50 ;; global options: +cmd 51 ;; Got answer: 52 ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 13313 53 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 0 54 55 ;; QUESTION SECTION: 56 ;search.service.consul. IN A 57 58 ;; ANSWER SECTION: 59 search.service.consul. 0 IN CNAME www.google.com. 60 www.google.com. 264 IN A 74.125.239.114 61 www.google.com. 264 IN A 74.125.239.115 62 www.google.com. 264 IN A 74.125.239.116 63 64 ;; Query time: 41 msec 65 ;; SERVER: 127.0.0.1#8600(127.0.0.1) 66 ;; WHEN: Tue Feb 25 17:45:12 2014 67 ;; MSG SIZE rcvd: 178 68 ``` 69 70 If at any time we want to deregister the service, we simply do: 71 72 ```text 73 $ curl -X PUT -d '{"Datacenter": "dc1", "Node": "google"}' http://127.0.0.1:8500/v1/catalog/deregister 74 ``` 75 76 This will deregister the `google` node along with all services it provides. 77 78 For more information, please see the [HTTP Catalog API](/api/catalog.html).