|
| 1 | +--- |
| 2 | +layout: page |
| 3 | +title: "DNS IP" |
| 4 | +description: "Instructions on how to integrate a DNS IP sensor into Home Assistant." |
| 5 | +date: 2017-02-25 11:05 |
| 6 | +sidebar: true |
| 7 | +comments: false |
| 8 | +sharing: true |
| 9 | +footer: true |
| 10 | +ha_category: Sensor |
| 11 | +ha_iot_class: "Cloud Polling" |
| 12 | +ha_release: "0.40" |
| 13 | +--- |
| 14 | + |
| 15 | + |
| 16 | +The `dnsip` sensor will expose an IP address, fetched via DNS resolution, as its value. There are two operational modes: |
| 17 | + |
| 18 | +1. When you enable the sensor with minimal configuration, it will query [OpenDNS](https://www.opendns.com/)' nameserver with the hostname `myip.opendns.com`, which will resolve to your external/public IP address. |
| 19 | +2. If you specify a `hostname`, a regular DNS lookup will be performed, providing you the IP the hostname resolves to. |
| 20 | + |
| 21 | +You may also override the nameserver that is being used by setting the `resolver` parameter to any nameserver you like. |
| 22 | + |
| 23 | +To enable this sensor, add the following lines to your `configuration.yaml` file: |
| 24 | + |
| 25 | +```yaml |
| 26 | +# Example configuration.yaml entry |
| 27 | +sensor: |
| 28 | + - platform: dnsip |
| 29 | +``` |
| 30 | +
|
| 31 | +Configuration variables: |
| 32 | +
|
| 33 | +- **hostname** (*Optional*): The hostname for which to perform the DNS query. Default: `myip.opendns.com` (special hostname that resolves to your public IP) |
| 34 | +- **resolver** (*Optional*): The DNS server to target the query at. Default: `208.67.222.222` (OpenDNS) |
| 35 | +- **ipv6** (*Optional*): Set this to `true` or `false` if IPv6 should be used. When resolving the public IP, this will be the IP of the machine HASS is running on. |
| 36 | +- **resolver_ipv6** (*Optional*): The IPv6 DNS server to target the query at. Default: `2620:0:ccc::2` (OpenDNS) |
| 37 | +- **scan_interval** (*Optional*): Defines number of seconds for polling interval. Default: `120` seconds. |
| 38 | + |
| 39 | +#### {% linkable_title Extended example %} |
| 40 | + |
| 41 | +```yaml |
| 42 | +# Example configuration.yaml entry |
| 43 | +sensor: |
| 44 | + # Own public IPv4 address |
| 45 | + - platform: dnsip |
| 46 | + # Resolve IP address of home-assistant.io via Google DNS |
| 47 | + - platform: dnsip |
| 48 | + hostname: home-assistant.io |
| 49 | + resolver: 8.8.8.8 |
| 50 | +``` |
0 commit comments