For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

Robert_Luechte2's avatar
Sep 15, 2015

iRule function to get node IP address from node name

Does anyone know of a method to retrieve the IP address of a node when you know the name of the node? I would like to to a LB::status command for a pool member, but I only know the name of the node, not the IP address.

 

I could potentially do it with a NAME method but that seems like a lot of overhead, especially with a lot of pool members.

 

3 Replies

  • Hi Robert,

     

    why did you only know the name of the node, but not its IP? Or are you talking about a dynamic scenario in which context you only have the name available?

     

    Can you please explain in more detail what you want to achieve? I mean what kind of request is coming in to the VS and what should be the outcome of your iRule?

     

    Ciao Stefan :)

     

  • I'm trying to create a pool member status page like the one described at this link:

     

    pool-member-status-page-on-a-virtual-server-v11

     

    The command

     

    for POOLNAME in `tmsh list ltm pool | grep -i "ltm pool" |  sort | awk '{print $3}'`; do
        for POOLMEMBER in `tmsh list ltm pool $POOLNAME | grep : | sort | awk '{print $1}'`; do
                echo \"$POOLNAME/$POOLMEMBER\", >> ${classfile}
        done
    done

    returns the pool name, the node name, and the port. It does not return the node IP address. But the LB::status method requires the pool member IP address, not the name. I could probably modify the code to return the IP address, but then I wouldn't have the node name and the port. I'm picky and I would like to have both because I want to display the name of the node/pool member on the web page so the users won't have to look up the IP address, plus the port is required for the LB::status method.

     

  • Hi Robert,

    what about something like this? (sorry haven't the correct syntax in mind right now, but it should point you in the right direction)

    for POOLNAME in `tmsh list ltm pool | grep -i "ltm pool" |  sort | awk '{print $3}'`; do
        for POOLMEMBER in `tmsh list ltm pool $POOLNAME | grep : | sort | awk '{print $1}'`; do
            POOLMEMBER_NAME=
            POOLMEMBER_PORT=
            POOLMEMBER_IP_TMP=($(tmsh list ltm node $POOLMEMBER_NAME | grep "address"))
            POOLMEMBER_IP=
            echo \"$POOLNAME/$POOLMEMBER_NAME/$POOLMEMBER_IP/$POOLMEMBER_PORT\", >> ${classfile}
        done
    done
    

    Ciao Stefan 🙂