Obtaining an External IP Address

The following section assumes that you already have Hotrod (possibly deployed on some Bboxes) up and running, for more information related to getting up and running see our Getting Started Guide.

Sometimes it is necessary to index the external IP address or your site, in particular if Hotrod is running on a Bbox that might be located at a home, small office or store that uses a consumer grade internet connection.

A simple solution, using Hotrod would be to deploy a pipe that queries a website that provides an external IP address service (such as that dyndns.org, ipecho.net or ident.me) resolves the public IP address of the site and allows it to be indexed in the user's data analytics and dash-boarding solutions. Knowing the external IP address allows network administrators to trace the location's Internet Service Provider and even rudimentary location.

One way to approach this would be to create a pipe as follows and deploy that to the sites of interest.

name: externalIP
context:
    interval: 3m
# List of external IP providers to choose from
    extip:
    - 'http://v4.ident.me'
    - 'http://ipecho.net/plain'
    - 'http://checkip.dyndns.org'
input:
    exec:
        command: echo ok
        interval: '{{interval}}'
actions:
# Randomly pick one of the external IP providers
- script:
    let:
    - provider: pick_random({{extip}})
- exec:
    command: curl --silent ${provider}
- extract:
    input-field: stdout
    pattern: (\d+\.\d+.\d+\.\d+)
    output-fields:
    - external_ip
output:
    write: console

In the above pipe we showcase how to use an input as an action, and how to leverage script to select a random item in a list. This is done to reduce the possible traffic to a particular provider, we also induce an event only once every 3m (3 minutes) in order to avoid overloading the provider in the event that there are many sites running this pipe.

Note that most of these services have specific Terms Of Services that should be adhered to and that the sites listed in this demo were chosen for illustrative purposes only.