Forum Discussion

besogon_9363's avatar
besogon_9363
Icon for Nimbostratus rankNimbostratus
Dec 08, 2011

irule to direct traffic...

Need to build an irule to direct traffic to another VS only if there are no active members in the pool associated with the first VS. Any help is greatly appreciated.

Thanks

 

  • e.g.

    [root@ve1023:Active] config  b virtual bar list
    virtual bar {
       snat automap
       pool foo
       destination 172.28.19.79:80
       ip protocol 6
       rules myrule
    }
    [root@ve1023:Active] config  b pool foo list
    pool foo {
       monitor all fake
       members 200.200.200.101:80 {}
    }
    [root@ve1023:Active] config  b pool foo|grep -i pool\ member
    +-> POOL MEMBER foo/200.200.200.101:80   inactive,down
    [root@ve1023:Active] config  b rule myrule list
    rule myrule {
       when CLIENT_ACCEPTED {
            if {[active_members [LB::server pool]] < 1} {
                    virtual bar2
            }
    }
    }
    
    [root@ve1023:Active] config  b virtual bar2 list
    virtual bar2 {
       snat automap
       pool foo2
       destination 1.1.1.1:80
       ip protocol 6
    }
    [root@ve1023:Active] config  b pool foo2 list
    pool foo2 {
       members 200.200.200.102:80 {}
    }
    
     curl -I http://172.28.19.79/
    HTTP/1.1 200 OK
    Date: Thu, 08 Dec 2011 04:25:41 GMT
    Server: Apache/2.2.3 (CentOS)
    Last-Modified: Tue, 08 Nov 2011 12:26:29 GMT
    ETag: "4183f1-30-47e02740"
    Accept-Ranges: bytes
    Content-Length: 48
    Connection: close
    Content-Type: text/html; charset=UTF-8
    
    [root@ve1023:Active] config  tcpdump -nni 0.0 port 80 and not host 200.200.200.10 and 'tcp[13] & 2!=0'
    tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
    listening on 0.0, link-type EN10MB (Ethernet), capture size 108 bytes
    20:26:54.272408 IP 172.28.19.251.39231 > 172.28.19.79.80: S 3171176811:3171176811(0) win 5840 
    20:26:54.272447 IP 172.28.19.79.80 > 172.28.19.251.39231: S 165646667:165646667(0) ack 3171176812 win 4380 
    20:26:54.273506 IP 172.28.19.251.39231 > 1.1.1.1.80: S 1021857758:1021857758(0) win 4380 
    20:26:54.273511 IP 172.28.19.251.39231 > 1.1.1.1.80: S 1021857758:1021857758(0) win 4380 
    20:26:54.273521 IP 1.1.1.1.80 > 172.28.19.251.39231: S 300771454:300771454(0) ack 1021857759 win 4380 
    20:26:54.273533 IP 1.1.1.1.80 > 172.28.19.251.39231: S 300771454:300771454(0) ack 1021857759 win 4380 
    20:26:54.273557 IP 200.200.200.100.39231 > 200.200.200.102.80: S 2110616188:2110616188(0) win 4380 
    20:26:54.274554 IP 200.200.200.102.80 > 200.200.200.100.39231: S 1477245557:1477245557(0) ack 2110616189 win 5792