Forum Discussion
Ken_Wong_48678
Aug 01, 2005Historic F5 Account
use irule to match virtual server name to node name
Hi,
This is Ken. I encounter a problem and need to write some irule to help.
There are two notes servers, client collect the server should use the server's hostname. The server discard any non hostname connection.
But, I need to load balancing the servers. I am trying to use irule to replace the request virtual server name to original server's hostname. I just write the following rule to handle single server. Can anyone give me some suggestions that I can use to load balancing two servers. Thanks!
Regards,
Ken
when CLIENT_ACCEPTED {
if { [TCP::remote_port] == 1352 } {
log local0. "Connect to Notes Server [IP::client_addr]:[TCP::client_port] --> [IP::server_addr]:[TCP::server_port]"
}
}
when CLIENT_DATA {
if { [TCP::payload] contains "WEBCSD00N" } {
TCP::payload replace 62 9 "WEBCSD01N"
log local0. "Replace payload [findstr [TCP::payload] "CN=" 9]"
pool WEBCSD01N_pool
}
TCP::release
}
- Ken_Wong_48678Historic F5 AccountHi,
when CLIENT_ACCEPTED { if { [TCP::remote_port] == 1352 } { log local0. "Connect to Notes Server [IP::client_addr]:[TCP::client_port] --> [IP::server_addr]:[TCP::server_port]" TCP::collect } } when CLIENT_DATA { set orig_host_start [string first "CN=" [TCP::payload]] TCP::release $orig_host_start TCP::collect set orig_notes_host [string range [TCP::payload] 3 12] if { $orig_notes_host matches "WEBCSD0AN" } { TCP::payload replace 3 12 "WEBCSD01N" pool WEBCSD01N_pool } else { TCP::payload replace 3 12 "WEBCSD02N" pool WEBCSD02N_pool } TCP::release }
- Ken_Wong_48678Historic F5 AccountThe error is
when CLIENT_ACCEPTED { if { [TCP::remote_port] == 1352 } { log local0. "Connect to Notes Server [IP::client_addr]: [TCP::client_port] --> [IP::server_addr]:[TCP::server_port]" TCP::collect } } when CLIENT_DATA { set orig_host_start [string first "CN=" [TCP::payload]] TCP::release $orig_host_start TCP::collect set orig_notes_host [string range [TCP::payload] 3 12] if { $orig_notes_host eg "WEBCSD0AN" } { TCP::payload replace 3 12 "WEBCSD01N" pool WEBCSD01N_pool } else { TCP::payload replace 3 12 "WEBCSD02N" pool WEBCSD02N_pool } TCP::release }
- unRuleY_95363Historic F5 AccountYes, that's an "EQ" not an "EG". The font for code (especially in bold italics) really does make it look like a lowercase G. I apologize for that.
- Ken_Wong_48678Historic F5 AccountThanks, I have tested my irule but encounter some problems. I hope you guys can give me some advices.
- unRuleY_95363Historic F5 AccountIs the host name in the first TCP packet or a following packet? That could explain why you don't see it.
binary scan [TCP::payload] h* pkt_in_hex puts "Rcvd: $pkt_in_hex"
- Ken_Wong_48678Historic F5 AccountHi,
- unRuleY_95363Historic F5 AccountYes, but you will need to enhance your rule to collect more data before releasing. Do you know if the host will always be found? If so, then you could keep collecting until you find the host and then modify it and release.
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects