F5-iRule 规则编写详解

上传人:W**** 文档编号:135771281 上传时间:2020-06-18 格式:PPT 页数:86 大小:2.65MB
返回 下载 相关 举报
F5-iRule 规则编写详解_第1页
第1页 / 共86页
F5-iRule 规则编写详解_第2页
第2页 / 共86页
F5-iRule 规则编写详解_第3页
第3页 / 共86页
F5-iRule 规则编写详解_第4页
第4页 / 共86页
F5-iRule 规则编写详解_第5页
第5页 / 共86页
点击查看更多>>
资源描述

《F5-iRule 规则编写详解》由会员分享,可在线阅读,更多相关《F5-iRule 规则编写详解(86页珍藏版)》请在金锄头文库上搜索。

1、F5iRule详解 L4和L7交换的本质区别 L2 Payload L3 L4 L7 Header FullPayload 对不定址 不定长的特征码进行的交换是L7交换的特征 对L7交换特征的提取 iRule WhatisaniRule iRule是一种脚本语言工具它的语法是基于TCL语言的大部分TCL语言的功能都被支持同时还有很多iRule的扩展功能它能帮你实现许多扩展功能当你在CLI GUI介面无法找到对应的命令 菜单请相信iRule iRules的组成元素 iRules是基于事件驱动 Event Driven 的由LTM系统触发你在iRules中指定 期望的事件iRules是由以下的基本

2、元素构成 事件声明操作符iRules命令 iRules的基本格式 事件声明 表达式 iRules命令 whenCLIENT ACCEPTED if IP addr IP remote addr equals 202 101 1 0 24 discard iRule的创建和管理 1 iRule的创建和管理 2 Datagroup的创建 1 Datagroup的创建 2 iRuleEditor iRule的引用 1 新建virtualserver iRule的引用 2 已有virtualserver iRule案例 1 whenHTTP REQUEST if HTTP uri starts wit

3、h csp dwr and HTTP uri ends with js poolcsp6 cache pool elseif HTTP uri starts with csp js poolcsp6 cache pool elseif HTTP uri starts with csp resources poolcsp6 cache pool elseif HTTP uri starts with csp help poolcsp6 cache pool elseif HTTP uri starts with csp esales poolcsp6 esales pool else poolc

4、sp6 professional pool iRule例子 2 whenHTTP REQUEST if HTTP headerexistsx up calling line id persistuie HTTP headervaluesx up calling line id loglocal0 thephonenumberis HTTP headervaluesx up calling line id 根据http数据包中的手机号码做会话保持 iRule例子 3 whenHTTP REQUEST if matchclass HTTP uri ends with class end poolp

5、ool gatewayloglocal0 theuriis HTTP uri matchuriclass elseif matchclass HTTP host contains class domain poolpool gatewayloglocal0 thedomainnameis HTTP host matchclass domain else poolCSS W3loglocal0 theuriis HTTP uri usecache 全局变量 在v10在不要再采用 而是直接把 去掉 classclass domain classclass end aspx cfm cgi jsp

6、php phtml shtml iRule案例 4 whenCLIENT ACCEPTED loglocal0 theclientis IP remote addr theserveris IP local addr if IP addr IP local addr equals10 64 238 0 23 IP addr IP local addr equals10 64 69 0 23 IP addr IP local addr equals10 64 208 0 23 IP addr IP remote addr equals192 168 68 106 IP addr IP remot

7、e addr equals192 168 68 109 IP addr IP remote addr equals192 168 68 113 IP addr IP remote addr equals192 168 68 114 snat10 228 69 133loglocal0 snatto10 228 69 133 elseif IP addr IP local addr equals10 64 238 0 23 IP addr IP local addr equals10 64 69 0 23 IP addr IP local addr equals10 64 208 0 23 IP

8、 addr IP remote addr equals192 168 68 132 IP addr IP remote addr equals192 168 68 135 IP addr IP remote addr equals192 168 68 139 snat192 168 68 219loglocal0 snatto192 168 68 219 else snat172 16 0 130loglocal0 snatto172 16 0 130 iRule调试 log命令 Log的输出会放在 var log ltm中 var log ltmiRule本身如果有错误 也会放在 var l

9、og ltm可以增加一些debug语句 来验证iRule的运行loglocal0 Startoftherule loglocal0 Middleoftherule loglocal0 Endoftherule Log命令的输出 TheargumentforthelogstatementisthefacilitydotlevelFacilitiesare local0is var log ltmlocal1is var log emlocal2is var log gtmlocal3is var log asmlocal4is var log ltmlocal5is var log pktfil

10、terlocal6is var log httpd httpd errorslocal7is var log boot log注意log命令会消耗资源 请在正式生产上 一定要注释掉 iRule的资源 iRule论坛 iRule其他 请注意一定要充分测试F5support只支持命令的语法 但无法支持客户的iRule应用逻辑有顾问服务可以购买 一起开发 演示 TCLFoundational 变量表达式流程控制if then elseswitchfor 变量 基本操作setunsetappend incr 变量 列表setlst item1 item2 item3 lindexlindex lind

11、ex lindex a1 2 3 lindex a 123 lappend linsert 在index之前插入内容lreplace 替换first至last之间的内容如果变量不足 则删除对应部分llength 变量 全局变量RULE INIT内定义的均为全局变量 varname为全局变量使用全局变量将导致CMP失效 即只能单CPU处理流量 这在v10以后的版本一定非常注意 表达式与操作符 TCLStandard 表达式与操作符 iRulesExtended 关联操作符containsmatches 参考Tcl stringmatch equalsstarts withends withmat

12、ches regex 参考常用简单正则表达式 逻辑操作符not and or 表达式 关于字符串比较 TCL语言习惯性的将字符串转换为数值进行比较3 20 建议使用eq ne FlowControl if then elseif then else Notice then and else areoptional注意 请采用尽量少的elseif elseif FlowControl switch option dosomethingelse default don tdoanything 尽可能多的使用switch 而不是if FlowControl SwitchOptions Convert

13、 If to Switch FlowControl For for for seti3 i 12 incri puts Iinsidesecondloop i iRuleFoundational1 全局命令功能函数功能命令事件 iRules命令 iRule命令类型数据流控制命令 Statement 数据流的目的地选择是否进行SNAT没有返回值数据提取命令 Query 获取数据流中指定的内容数据操作命令 Datamanipulation 修改数据流中指定的内容实用工具命令 Utility 一组功能函数 提供常用的数据解析功能 iRules命令 全局命令1 iRules命令 全局命令2 whenS

14、ERVER CONNECTED if IP addr clientside IP remote addr equals10 1 1 80 discard iRules命令 全局命令3 iRules命令 全局命令4 iRules命令 全局命令5 whenCLIENT ACCEPTED if TCP local port equals531 snatpoolchat snatpool elseif TCP local port equals25 snatpoolsmtp snatpoolmember10 20 30 40 iRules命令 全局命令6 iRules命令 全局命令7 whenHTTP

15、 REQUEST if cpuusage5sec 1 poolwww else HTTP redirect iRules命令 全局命令8 iRules命令 功能函数 iRules命令 功能函数 iRules命令 功能函数 Findstr HTTP payload fid 4 iRules命令 TCLStringFunc iRules命令 TCLSCAN iRules命令 TCLBINARYSCAN TMOSCommands祥解 LB OneConnect相关命令TCP IP相关命令HTTP Cache DNS相关命令 TMOSCMD LB TMOSCMD OneConnect TMOSCMD

16、LINK TMOSCMD IP whenCLIENT ACCEPTED if IP addr IP client addr equals10 10 10 10 poolmy pool TMOSCMD TCP TMOSCMD TCP TMOSCMD TCP TMOSCMD TCP whenSERVER CONNECTED peer TCP collect4 whenCLIENT DATA if TCP payload starts with EHLO TCP respond 5005 3 3Unrecognizedcommand r n TCP payloadreplace0 TCP payloadlength TCP release TMOSCMD HTTP TMOSCMD HTTP Header TMOSCMD HTTP Header TMOSCMD HTTP Header TMOSCMD HTTP Cookie TMOSCMD HTTP Cookie TMOSCMD HTTP Cookie TMOSCMD HTTP TMOSCMD HTTP whenHTTP REQUEST set

展开阅读全文
相关资源
相关搜索

当前位置:首页 > IT计算机/网络 > 计算机应用/办公自动化

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号