Docker to BIG-IP: Map container names to DNS

Problem this snippet solves:

The associated iRule is used in the DevCentral article:

This will intercept DNS requests and return an IP address based on a name from a data group.

How to use this snippet:

Attach to LTM virtual that is the GTM listener (53).

Code :

        set lower_name [string tolower [DNS::question name]]
        if { $lower_name ends_with "" } {
            set container [getfield $lower_name "." 1]
             #log local0. "container $container"
             set node_addr [class match -value $container equals dg_docker_container]
             if {$node_addr ne "" }
                set node_ip  [getfield $node_addr ":" 1]
                DNS::answer insert "[DNS::question name]. 30 [DNS::question class] [DNS::question type] $node_ip"

        # Stop further processing of the query after this iRule and send the answer to the client
               } else {
                DNS::answer clear
                DNS::header rcode NXDOMAIN
Published Sep 01, 2015
Version 1.0

Was this article helpful?

No CommentsBe the first to comment