I need to write an iRule for a pool that will direct traffic to the correct member by incoming IP address. The pool members are setup to push traffic to member on service port 9081.
(e.g). Traffic destined for IP address 10.10.10.20 will go to .20, but if .20 is down traffic will go to pool member 10.10.10.21 and vice versa. Traffic with IP header 10.10.10.21 will go to member .21, but if not available will go to .20.
I am sure this is a simple iRule, but my synax is terrible. Any help would be appreciated
Nevermind… I thought you wanted to select the pool based on the source IP address. Can you elaborate on what you’re trying to implement?
Do you have two virtual server IP addresses which you want to map to two server IP addresses? If so, you could create one VS on 1.0.0.1 which points to a pool containing 2.0.0.1 as priority 100 and 2.0.0.2 as priority 1. And you can create a second VS on 1.0.0.2 which points to a pool containing 2.0.0.2 as priority 100 and 2.0.0.1 as priority 1. The higher priority pool member would take precedence as long as it is marked up. If it marked down, connections would go to the lower priority member.
The traffic will have the destination IP address in the packet. So I need to direct the traffic based on target IP. (e.g header packet will contain the target pool member it needs to go to by IP address 10.10.10.20). But, if this server is ever unavailable, I will need it to go to the other pool member 10.10.10.21. I need to build the rule to cover this both ways.
I don’t think that would work as is. I don’t think both servers could be configured for 10.10.10.20 and 10.10.10.21. You would get IP conflicts if both hosts answered ARPs for both addresses.
It seems like it would be a lot more complicated to try to do something like transparent load balancing compared with just using a new IP address and load balancing the two servers with that.
I am not sure I follow. Do you think if the traffic intended for .20 cannot get there, then it would produce an IP conflict b/c it would then try to go to .21 but doesn’t match that address.
I will have to follow up with the application group, but the IP address may just be part of the content not the actual header packet. If this is the case, do you think this could be done?
What protocol/type of application is this for? Have you done something like this before?
I’m trying to work out the layer2/3 logistics of what you’re describing.
It sounds like you’d want LTM to answer an ARP request for 10.10.10.20 and then check the state of server1 which is also answering for 10.10.10.20. If it’s up, then send the request to server1. If server1 is down, then you’d want to check the state of server2. If server2 is up, then you’d want to translate the destination MAC address of the request and send it to 10.10.10.20 using server2’s MAC address. Finally, if server1 and server2 are down, you’d potentially want to take some default action like send a reset back.
I’m not sure how LTM would be able to identify server1 and server2. I guess you could hardcode ARP entries for two dummy IP addresses and add these to the pool (1.1.1.1 MAC: 00:00:00:00:00:01 priority 100 and 2.2.2.2 MAC: 00:00:00:00:00:02 priority 10, assuming these MAC addresses were the real ones from server1 and server2). You could then create a VS on 10.10.10.20 with destination address translation disabled.
It’s been forever since I tested a layer 2 bridging implementation. I’m not sure if you’d need VLAN groups for this or not. I’m also not sure whether the above description would work or is optimal.
Citizen, are you out there? Can you make sense of this?
What protocol/type of application is this for? Is it TCP, HTTP, something custom built on UDP, etc?
If you have IP address for the VS that’s different than the two servers it should be very simple to configure. Just add the two servers to a pool with server1 at a higher priority and configure a VS which references that pool. If you need to rewrite the TCP or HTTP payload based on the destination IP address, you can do that using a stream profile or by buffering the content with TCP::collect or HTTP::collect.
This will be for Soap calls over HTTP. The traffic is intended for IBM Websphere application (Java based).
I just spoke with the developer. Forget the whole issue about having the destination IP address in the content. The traffic will be sent to a URL (VS IP address). What he was expecting to see the LTM to recognize the originating traffic coming from 10.10.10.20 and that the LTM would be able to send the traffic back to the same member of the pool 10.10.10.20. If 10.10.10.20 was not available, then push the traffic to the other member (10.10.10.21). This sounds like the issue with layer2/3.
What if I create 2 VS"s? 10.10.10.20 generates data to LTM VS 1, with .20 priority 1 and .21 as priority 2. 10.10.10.21 generates data to LTM VS 2, and .21 is priority 1 with .20 as priority 2. Create separate pools for both VS.
What is the purpose of having two virtual servers or two IP’s to reference the two servers? Typically, you’d either want to talk to a single high availability IP address (load balanced) or one IP per server for maintenance or similar.
If this is SOAP over HTTP, I’m guessing you’ll end up using a new IP for the virtual server and translate the destination IP address to the real server IP. If there is an IP address in the request and/or response payload that needs to be rewritten, you can do this using HTTP::collect (Click here). If the length of the IP address string in the request payload is the same as what you’re replacing it with (length of 111.11.11.111 = length of 222.22.22.222), you could use a stream profile and STREAM::expression iRule (Click here) to rewrite the payload. A stream profile and iRule would buffer less payload and be more efficient than using HTTP::collect.
I think I forgot to mention that the VIP server IP address is a separate VLAN than the pool members, so I think that the IP conflict mentioned earlier will not be an issue.
I will not need to rewrite the IP Address. The IP address in the payload will match the pool member that it originated from and we would like to push back to same member (service port 9081) if available. If that member is not available, then push that packet to the other member of the pool on service port 9081.
If what you are saying is that you have a SOAP message that contains an element which will tell you which pool member to send it to, then what you need to do is:
- search for that element using [XML::element]
- make a variable out of its value [set]
- then switch on that variable [switch]
- when you match it, you can use [active_members] to check if the pool member is available
- then write a session entry using [session] if you need to
- and direct the traffic to it using the member specification in [pool]