F5 – BigIP LTM basic iRules hacks

0 Flares Facebook 0 Twitter 0 Google+ 0 LinkedIn 0 Email -- 0 Flares ×

=============================

when HTTP_RESPONSE {
if { [HTTP::status] [== 404} {
HTTP::redirect “http://www.example.com/newlocation.html”
}
}

=====================================================
when RULE_INIT {
set cookie_name “piy_which_resolved”
}

when HTTP_REQUEST {
if { [IP::addr [IP::client_addr] equals 122.122.122.221] } {
HTTP::cookie insert name $::cookie_name value india_piy path “/”
} elseif {[IP::addr [IP::client_addr] equals 122.122.122.222] } {
HTTP::cookie insert name $::cookie_name value us_piy path “/”
}
}

when HTTP_REQUEST {

# Check if requested path is /
if {[HTTP::path] eq “/”}{
HTTP::cookie insert name $::cookie_name value us_piy path “/”
} else {
virtual myvip
}

==========================================
Rule for VIP1

when RULE_INIT {
set cookie_name “fromwhere”
}

when HTTP_REQUEST {

# Check if requested path is /
if {[HTTP::path] eq “/”}{
HTTP::cookie insert name $::cookie_name value india_piy path “/”
}

log local0. “Client Connected, IP: [IP::client_addr]”
log local0. “Local Address, IP: [IP::local_addr]”
log local0. “Virtual Server: [virtual]”

}
===============================================
Rule for VIP2

when RULE_INIT {
set cookie_name “fromwhere”
}
when HTTP_REQUEST {

# Check if requested path is /
if {[HTTP::path] eq “/”}{
HTTP::cookie insert name $::cookie_name value us_piy path “/”
}

log local0. “Client Connected, IP: [IP::client_addr]”
log local0. “Local Address, IP: [IP::local_addr]”
log local0. “Virtual Server: [virtual]”

}

===============================================

when HTTP_REQUEST {
if { [IP::addr [IP::remote_addr] equals 10.0.0.10] } {
HTTP::redirect “http://my.vip.example.com/”
}
}

=====================================================

when CLIENT_ACCEPTED {
set server_ip [ IP::local_addr ]
set client_ip [ IP::client_addr ]
if {$client_ip ==”0.0.0.0″} {
discard
return
}

if { [ matchclass $server_ip equals $::host_for_transparent_proxy ] } {
#log local0.info ” (TPROXY ROUTE)’$client_ip’ —> Divert to MSP ‘$server_ip'”
use node 10.217.164.212 8080
return
} elseif { [ matchclass $client_ip equals $::net_for_mobile_ip_test0045_apn ] } {
#log local0.info ” (WA-Proxy ROUTE)’$client_ip’ —> Divert to WA ‘$server_ip'”
persist source_addr
use pool WA_8080_pool
return
} else {
#log local0.info ” (TPROXY ROUTE)’$client_ip’ —> Forward to ‘$server_ip'”
virtual ANY-Forward
}
}

===============================================================

Comments

comments

4 Replies to “F5 – BigIP LTM basic iRules hacks”

  1. Hi Piyush..

    Which event driven scripting language is used for these irules. Is this F5 specific or something else like simula, linden or tcl .. ANy idea. I just want to understand an irule what its doing for that I need to understand the code.

Leave a Reply

Your email address will not be published. Required fields are marked *