Typically, you would create virtual servers to handle this functionality. You can create a pool each for the ISP1 and IPS2 routers. You can then reference those pools in specific port virtual servers. To handle the remaining traffic not destined for a specific port virtual server, you can create a pool of both routers (each defined on port 0) and create a wildcard virtual server pointing to that pool.
You might be create an iRule to do all of this, but it’s simpler to use virtual servers.
You can take a look at the LTM config guide for your version on AskF5 for details on configuring pools and virtual servers.
You would still define the same pools and then use switch on TCP::local_port to select which pool to send the request to. Here’s a simple example:
when CLIENT_ACCEPTED {
Check the requested port
switch [TCP::local_port] {
21 { pool isp1_router_pool }
25 { pool isp2_router_pool }
80 { pool isp1_router_pool }
443 { pool isp1_router_pool }
default { pool isp1_isp2_router_pool }
}
}
This might not handle FTP traffic though if the server needs to open a data connection back to the client. This is handled automatically with a VIP and FTP profile though.