配置Session TTL
2025/10/29大约 2 分钟
配置Session TTL
功能介绍
- 会话生存时间,即会话建立后无任何数据传送情况下的存活时间,默认为3600秒,当该会话在超时之前有任何数据匹配该会话,则该会话ttl计时器复位到该数值,如3600秒。有的服务如数据库。需要长连接,尽可能能将其TCP的会话超时时间设置得较大。
- session-ttl配置有4种不同的类型,分为全局session-ttl 、全局自定义的session-ttl、策略session-ttl 、服务对象session-ttl。session-ttl必须在CLI下配置。
重要
配置session-ttl时间只对状态为“已建立”的会话TTL时间生效。
配置方法
配置全局session-ttl。
config system session-ttl set default 3600 //TCP会话的老化时间,300-2764800秒(最大为32天),默认为3600s end config system global set udp-idle-timer 180 //UDP会话的老化时间,1-86400秒(最大为1天),默认为180s end全局自定义session-ttl,可自由定义协议、端口与会话超时时间。
config system session-ttl config port edit 1 set protocol 6 set timeout 86400 set start-port 5000 set end-port 5000 next edit 2 set protocol 17 set timeout 360 set start-port 4500 set end-port 4500 next edit 3 set protocol 1 set timeout 60 next end end基于策略的session-ttl,针对匹配该策略的所有协议的会话生效。
config firewall policy edit 1 set srcintf lan set dstintf wan1 set srcaddr all set dstaddr all set action accept set schedule always set service ANY set session-ttl 604800 //针对匹配该策略的所有协议/端口的会话生效 set nat enable next end基于服务对象的session-ttl,定义不同的对象,虽然同为23端口,可以配置指定不同协议的session-ttl时间,被策略引用后才会生效。
config firewall service custom edit telnet set protocol TCP set tcp-portrange 23 set session-ttl 7200 next edit "telnetnew" set protocol UDP set tcp-portrange 23 set session-ttl 3600 next end
Session TTL优先级
全局session-ttl(低)< 全局自定义session-ttl < 策略session-ttl < 被策略引用的服务对象session-ttl(高)。优先级高的session-ttl优先被使用。