Layer 7 API Management

Expand all | Collapse all

requestHost IP as resolved by DNS

Jump to Best Answer
  • 1.  requestHost IP as resolved by DNS

    Posted 06-19-2019 05:13 AM
    Is there a way to retrieve the resolved DNS IP of the requestHost on the gateway?

    ------------------------------
    API Tech Lead
    Sanlam
    ------------------------------


  • 2.  RE: requestHost IP as resolved by DNS

    Posted 06-19-2019 10:39 PM
    If you're talking about the IP of the reqeustor, you can use ${request.tcp.remoteip} context variable to get the IP of the requestor.
    But usually there should be a load balancer before the gateway cluster, in that case the variable will always return the IP  of the load balancer. Then your LB should be configured to send the x-forwarded-for header to contain the IP of original requestor, so that the gateway can check the value of XFF header to retrieve the IP of the original requestor.

    Regards,
    Mark



  • 3.  RE: requestHost IP as resolved by DNS

    Posted 06-20-2019 02:31 AM

    I am referring to the host defined in the Route.
    The image snip is from a route deployed via the Portal.

    In this case I need the IP of the host portion of the context variable ${apiLocation}.


    I want to confirm if the gateways are resolving hosts correctly.
    We also had issues in the past where IP's were changed but the DNS was cached in Java. This cache time was reduced but I  need to be able to troubleshoot this.



    ------------------------------
    API Tech Lead
    Sanlam
    ------------------------------



  • 4.  RE: requestHost IP as resolved by DNS
    Best Answer

    Posted 06-20-2019 03:35 AM
    Dear Sanlam,
    You can try ${response.tcp.remoteAddress}, but I am doubt that it can work as you expected.
    I believe it only works if the route assertion is successful, in your case, if the cached DNS is wrong, the route assertion should fail and all the response properties should be empty(not set).

    Regards,
    Mark