outbound traffic for specific url by using specific IP

The gateway of all my pool members is F5. I have SNAT and VS for outbound traffic. Therefore the outside world see the IP1 - which is set on my SNAT for my outbound traffic. I want the pool member go to some specific URL such as www.yahoo.com. The outside world will see another IP2 instead of IP1. Do we have some irule that can achieve my goal?

You would need a virtual server performing transparent http proxying… I dont think it’s simple! If you can configure you nodes to use an HTTP proxy, then you could use a VIP+iRule that implement HTTP proxy. and which then would apply your logic to SNATing… I think.

Mohamed.

If you have a wildcard forwarding Virtual Server (that is, listening on 0.0.0.0:0), you may also create a wildcard port 80 VS (that is, listening on 0.0.0.0:80), the add the http profile and the following iRule:

when HTTP_REQUEST {
    if { [string tolower [HTTP::host]] equals "www.yahoo.com" } {
        snat 5.6.7.8
    }
}

Change 5.6.7.8 to the appropriate IP (or use a SNAT pool and the snatpool command. Assign your default SNAT (either AutoMap or the appropriate SNAT pool) from your wildcard forwarding VS to the new port 80 VS. That way, SNAT IP1 will be used for all traffic except that bound for www.yahoo.com. Make sure that both Virtual Servers are bound to only the VLAN from which your pool member traffic originates.

If you want to intercept SSL traffic, that is much trickier, because you would need to stand up an SSL forward proxy and the pool members would need to be provided a trusted internal signing certificate which signs for www.yahoo.com. It absolutely can be done, but is, as Mohamed says, not simple.

If you have a wildcard forwarding Virtual Server (that is, listening on 0.0.0.0:0), you may also create a wildcard port 80 VS (that is, listening on 0.0.0.0:80), the add the http profile and the following iRule:

when HTTP_REQUEST {
    if { [string tolower [HTTP::host]] equals "www.yahoo.com" } {
        snat 5.6.7.8
    }
}

Change 5.6.7.8 to the appropriate IP (or use a SNAT pool and the snatpool command. Assign your default SNAT (either AutoMap or the appropriate SNAT pool) from your wildcard forwarding VS to the new port 80 VS. That way, SNAT IP1 will be used for all traffic except that bound for www.yahoo.com. Make sure that both Virtual Servers are bound to only the VLAN from which your pool member traffic originates.

If you want to intercept SSL traffic, that is much trickier, because you would need to stand up an SSL forward proxy and the pool members would need to be provided a trusted internal signing certificate which signs for www.yahoo.com. It absolutely can be done, but is, as Mohamed says, not simple.

Oh, and consider using a Local Traffic Policy instead, if you are running 11.4 or higher:

You would still create the second (port 80 only) VS, but all of the logic above can be accomplished using a Local Traffic Policy attached to that second VS.

That virtual would SNAT to some IP, and then send traffic where?

That virtual would SNAT to some IP, and then send traffic where?

@Mohamed, assuming it is applied to a wildcard VS (destination is 0.0.0.0/0) it would leave the destination address unchanged (assuming that the address translation -- meaning destination translation -- field is unset). For delivery, the BIG-IP would follow its route table.

I think you are mixing up IP Forwarding VS behavior, with that of Standard VS. You can’t have both.

Thanks, Mohamed.

Sorry that was not clear. To clarify: - You cannot use that iRule on an IP forwarding VS, because you cannot apply an http profile to it. - On a standard VS, where you can apply that iRule, you need a pool to serve http traffic from, or the iRule needs to implement transparent proxy behavior… Oh, this is a request for google.com, let’s resolve that name in DNS, then lets get this request answered from that server.

Makes sense?

Thanks, Mohamed.

Naturally that is true for the forwarding Virtual Server (i.e., one may not apply an http profile to it), but it turns out that -- while it may seem somewhat counter-intuitive -- that assertion is not correct for Standard Virtual Servers. If there is no pool and (destination) Address Translation is disabled, it will forward using BIG-IP’s normal routing (I just verified on 11.5.3 to make sure I was remembering correctly (: ). If you wanted to exert more control over the route direction, you may create a pool that contains gateways (routers) and still disable (destination) Address Translation. That will have the same effect (but use the gateways’ routing rather than BIG-IP).

But a fair point, in any case. I was not explicit about using a Standard VS, and that is definitely confusing now that I’m reading back through my posts.

Thanks for clarifying… I tried to create such a VS, but for some reason it does not seem to be actually handling the traffic…Anyway, I would be interested to hear of this worked out for you John.

Thanks for clarifying… I tried to create such a VS, but for some reason it does not seem to be actually handling the traffic…Anyway, I would be interested to hear of this worked out for you John.

Ok…I get it works but not exactly what I want. I still want to know whether I can get help from here.

Here is what I have done but only for https traffic. I have two VS. VS1 - all outbound traffic for all pool members by using IP1 on snat1. VS2 - all outbound https traffic for all pool members by using IP2 on snat2. All pool member are using F5 to be the default gateway.

VS1 setup as below.

  1. VS type - performance layer4.
  2. Source - 0.0.0.0/0.
  3. Destination - network - 0.0.0.0/0.0.0.0 and all ports.
  4. snat - using snat1.
  5. no pool members.

VS2 set up as below.

  1. VS type - performance layer4.
  2. source - 10.100.8.0/22 - this is my DMZ where all pool members are.
  3. Destination - network - 0.0.0.0/0.0.0.0 and port - 443 .
  4. snat - using snat2.
  5. no pool members.

Therefore, all https outbound traffic from pool members are using snat2 - IP2. Others outbound traffic from pool members are using snat1 - IP1.

I want to know how to set up ONLY specific URL like https://www.yahoo.com outbound traffic by using snat2 and the others are using snat1 (including others URL https).

Firstly, I assume you are using SSL offloading. If so, you cannot use a “Performance (L4)” VS for this; clientssl requires a Standard VS. However, if you are using SSL offloading, and going to public locations (like www.yahoo.com) then you must use Proxy SSL or an SSL Forward Proxy with a set of wildcard certificates signed by a local CA trusted by the clients.

Anyhow, here is a configuration that should get you at least close to what you want. I am assuming that 10.10.212.200 is the default gateway for the BIG-IP:

These are the two SNAT addresses you want, each in its own pool
ltm snatpool snat-pool-01 { members { 10.10.212.105 } }
ltm snatpool snat-pool-02 { members { 10.10.212.125 } }

 This is the pool to be used in the port 80 case.  It points to the BIG-IP's
 default gateway (10.10.212.200, in my setup)
ltm pool pool-gateway-01 {
    members {
        10.10.212.200:any {
            address 10.10.212.200
            session monitor-enabled
            state up
        }
    }
    monitor gateway_icmp 
}

 This is the iRule applied to the port 80 VS that selects the second SNAT IP
 if the host destination is www.yahoo.com
ltm rule rul-select-snat {
    when HTTP_REQUEST {
    if { [HTTP::host] eq "www.yahoo.com" } { 
        snatpool snat-pool-02
    }
}

 This is the wildcard VS.  You might as well make it a forwarding VS.
ltm virtual vs-forwarding {
    destination 0.0.0.0:any
    ip-forward
    mask any
    profiles {
        fastL4 { }
    }
    source 0.0.0.0/0
    source-address-translation {
        pool snat-pool-01
        type snat
    }
    translate-address disabled
    translate-port disabled
    vlans {
        external
    }
    vlans-enabled
    vs-index 5
}

 This is the port 80 wildcard address VS that is only used by
 the subset of hosts as you wish.  Notice that the default
 SNAT address is the same as the other VS (snat-pool-01).  The
 iRule selects the other snat address (snat-pool-02) if the
 particular host matches.
ltm virtual vs-http-01 {
    destination 0.0.0.0:http
    ip-protocol tcp
    mask any
    pool pool-gateway-01
    profiles {
        clientssl {
            context clientside
        }
        http { }
        mptcp-mobile-optimized { }
    }
    rules {
        rul-select-snat
    }
    source 10.100.8.0/22
    source-address-translation {
        pool snat-pool-01
        type snat
    }
    vlans {
        external
    }
    vlans-enabled
    vs-index 6
}

Firstly, I assume you are using SSL offloading. If so, you cannot use a “Performance (L4)” VS for this; clientssl requires a Standard VS. However, if you are using SSL offloading, and going to public locations (like www.yahoo.com) then you must use Proxy SSL or an SSL Forward Proxy with a set of wildcard certificates signed by a local CA trusted by the clients.

Anyhow, here is a configuration that should get you at least close to what you want. I am assuming that 10.10.212.200 is the default gateway for the BIG-IP:

These are the two SNAT addresses you want, each in its own pool
ltm snatpool snat-pool-01 { members { 10.10.212.105 } }
ltm snatpool snat-pool-02 { members { 10.10.212.125 } }

 This is the pool to be used in the port 80 case.  It points to the BIG-IP's
 default gateway (10.10.212.200, in my setup)
ltm pool pool-gateway-01 {
    members {
        10.10.212.200:any {
            address 10.10.212.200
            session monitor-enabled
            state up
        }
    }
    monitor gateway_icmp 
}

 This is the iRule applied to the port 80 VS that selects the second SNAT IP
 if the host destination is www.yahoo.com
ltm rule rul-select-snat {
    when HTTP_REQUEST {
    if { [HTTP::host] eq "www.yahoo.com" } { 
        snatpool snat-pool-02
    }
}

 This is the wildcard VS.  You might as well make it a forwarding VS.
ltm virtual vs-forwarding {
    destination 0.0.0.0:any
    ip-forward
    mask any
    profiles {
        fastL4 { }
    }
    source 0.0.0.0/0
    source-address-translation {
        pool snat-pool-01
        type snat
    }
    translate-address disabled
    translate-port disabled
    vlans {
        external
    }
    vlans-enabled
    vs-index 5
}

 This is the port 80 wildcard address VS that is only used by
 the subset of hosts as you wish.  Notice that the default
 SNAT address is the same as the other VS (snat-pool-01).  The
 iRule selects the other snat address (snat-pool-02) if the
 particular host matches.
ltm virtual vs-http-01 {
    destination 0.0.0.0:http
    ip-protocol tcp
    mask any
    pool pool-gateway-01
    profiles {
        clientssl {
            context clientside
        }
        http { }
        mptcp-mobile-optimized { }
    }
    rules {
        rul-select-snat
    }
    source 10.100.8.0/22
    source-address-translation {
        pool snat-pool-01
        type snat
    }
    vlans {
        external
    }
    vlans-enabled
    vs-index 6
}

All the https traffic is for outbound from all pool members. Therefore, there is no SSL offloading. With “Performance (L4)” VS, how can I filter specific URL to different snat?

All the https traffic is for outbound from all pool members. Therefore, there is no SSL offloading. With “Performance (L4)” VS, how can I filter specific URL to different snat?

Hi,

if you are not using SSL offloading, you can try to inspect client data and search SNI in SSL negotiation.

the following question / answer can help you.

https://devcentral.f5.com/questions/match-ssl-sni-and-redirect-ssl-traffic-without-ssl-termination

Can anyone review the info https://devcentral.f5.com/questions/i-rule-help-route-incoming-traffic-based-on-source-subnet-amp-url-contains-string-admin-or-intra & help me fix the issue …thanks!