会话参数分析
会话参数分析
FortiGate # diagnose sys session list
session info: proto=6 proto_state=01 duration=2 expire=3597 timeout=3600 flags=00000000 socktype=0 sockport=0 av_idx=0 use=3
origin-shaper=
reply-shaper=
per_ip_shaper=
class_id=0 ha_id=0 policy_dir=0 tunnel=/ vlan_cos=0/255
state=may_dirty npu
statistic(bytes/packets/allow_err): org=112/2/1 reply=60/1/1 tuples=2
tx speed(Bps/kbps): 0/0 rx speed(Bps/kbps): 0/0
orgin->sink: org pre->post, reply pre->post dev=13->14/14->13 gwy=192.168.2.10/192.168.1.10
hook=pre dir=org act=noop 192.168.1.10:44610->192.168.2.10:22(0.0.0.0:0)
hook=post dir=reply act=noop 192.168.2.10:22->192.168.1.10:44610(0.0.0.0:0)
pos/(before,after) 0/(0,0), 0/(0,0)
misc=0 policy_id=8 pol_uuid_idx=520 auth_info=0 chk_client_info=0 vd=0
serial=000c48ed tos=ff/ff app_list=0 app=0 url_cat=0
rpdb_link_id=00000000 ngfwid=n/a
npu_state=0x4000c00 ofld-O ofld-R
npu info: flag=0x81/0x81, offload=8/8, ips_offload=0/0, epid=158/156, ipid=156/158, vlan=0x0000/0x0000
vlifid=156/158, vtag_in=0x0000/0x0000 in_npu=1/1, out_npu=1/1, fwd_en=0/0, qid=5/5proto:协议号,ICMP:1,TCP:6,UDP:17。更多请参考:https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml 。proto_state:会话状态,跟协议相关。ICMP:ICMP 没有状态,一直显示 proto_state = 00。
UDP:UDP 是无状态的协议,但 FortiGate 仍会跟踪两种状态。
- proto_state = 00:表示没有收到 reply 方向的 UDP 报文。
- proto_state = 01:表示已收到 reply 方向的 UDP 报文。
TCP:TCP 是有状态的协议,proto_state = xy。
- x 与服务器的状态相关,当没有开启 UTM 或者 Proxy 时,x 一直为 0。
- y 与客户端的状态相关联,当 FortiGate 收到 syn 时,y 的值为 2;收到 syn/ack 时,y 的值为 3;收到 ack 时,即完成三次握手,y 的值为 1。
State Value NONE 0 ESTABLISHED 1 SYN_SENT 2 SYN & SYN/ACK 3 FIN_WAIT 4 TIME_WAIT 5 CLOSE 6 CLOSE_WAIT 7 LAST_ACK 8 LISTEN 9 TCP 超时时间可在
config system global和config firewall service custom中调整。SCTP(proto 132):
State Value Expire Timer(默认) SCTP_S_NONE 0 60 s SCTP_S_ESTABLISHED 1 3600 s SCTP_S_CLOSED 2 10 s SCTP_S_COOKIE_WAIT 3 5 s SCTP_S_COOKIE_ECHOED 4 10 s SCTP_S_SHUTDOWN_SENT 5 30 s SCTP_S_SHUTDOWN_RECD 6 30 s SCTP_S_SHUTDOWN_ACK_SENT 7 3 s SCTP_S_MAX 8 n/a
duration:会话存在的时间。expire:从会话经过最后一个包开始,从 timeout 时间开始倒计时。timeout:会话在当前状态下的超时时间(TCP 会话各状态超时时间,非特殊情况不要修改,请参考策略与对象 → 配置 Session TTL 章节)。origin-shaper:会话发起方流量匹配的 traffic shaper 策略。reply-shaper:会话反向流量匹配的 traffic shaper 策略。per_ip_shaper:会话匹配的 per-ip 策略。tunnel:隧道的名称。state:会话状态标志。会话状态 状态说明 may-dirty 会话参数允许被修改。 dirty 会话参数已被修改(需要先有 may-dirty 标志)。 npu 会话通过硬件加速芯片(ASIC)转发。 npd 会话被拒绝进行硬件加速。 npr 会话具备硬件加速资格(可通过 npu info: offload = x/y 查看详情)。 rem 当内存不足时,该会话允许被强制删除。 eph 会话处于临时(ephemeral)状态。 oe 会话属于 IPsec 隧道流量(发起方)。 re 会话属于 IPsec 隧道流量(响应方)。 local 会话与 FortiGate 本地 IP 协议栈关联(本机流量)。 br 会话处于桥接模式(VDOM 为透明模式)。 redir 会话被重定向至 FortiGate 内部代理处理。 wccp 会话被 WCCP 进程拦截处理。 nlb 会话来自负载均衡 VIP。 log 会话正在记录日志。 os 会话在发起方向上做了流量整形。 rs 会话在响应方向上做了流量整形。 ndr 会话正在被 IPS 特征检测。 nds 会话正在被 IPS 异常检测。 auth 会话需要通过认证。 block 会话被重新评估后判定为阻断(策略发生变更)。 ext (已废弃)会话由 session helper 处理。 app_ntf 会话匹配了包含 set block-notification enable的策略。f00 在策略中启用流量日志后,会话将具有此标志。 pol_sniff 在策略中启用抓包功能后,会话将具有此标志。 log-start 会话建立时同样记录日志(一条会话产生两条日志:开始和结束)。 rst_tcp 防火墙策略中启用了 timeout-send-rst时可见。synced 会话已同步至 HA 对端(HA 主设备上可见,需开启 session-pickup)。 syn_ses 会话已从主设备同步至本设备(HA 备设备上可见,需开启 session-pickup)。 need_sync 会话将在存活 30 秒后同步到 HA 对端。 complex 会话由 session helper 处理。 app_valid 应用控制已识别出该会话的应用(会话中会出现 app=字段)。intree 该会话为子会话(由 SCTP、RPC、SIP、FTP 等 session helper 创建)。子会话的 serial 与父会话相同;父会话删除时,关联子会话同时删除。 hlife 流量匹配了配置有 set schedule-timeout enable的策略,到达计划结束时间后会话将被关闭。dev:FortiGate 接口索引 index,可以通过diagnose netlink interface list查看。dev=13->14/14->13表示数据流发起方从 port5 到 port6,数据流的响应方从 port6 到 port5。FortiGate# diagnose netlink interface list | grep 13 if=port5 family=00 type=1 index=13 mtu=1500 link=0 master=0 FortiGate# diagnose netlink interface list | grep 14 if=port6 family=00 type=1 index=14 mtu=1500 link=0 master=0hook/dir:会话方向与 NAT 动作。dir=org:发起方向,源 IP → 目的 IP,括号内为 NAT 后的地址(0.0.0.0:0表示无 NAT)。dir=reply:响应方向,源 IP → 目的 IP,与发起方相反。做 SNAT 时,NAT 地址覆盖源 IP: 端口;做 DNAT 时,NAT 地址覆盖目的 IP: 端口。格式为
<源IP>:<源端口>-><目的IP>:<目的端口>(<NAT后IP>:<NAT后端口>),同时做 SNAT 和 DNAT 的会话示例如下:hook=pre dir=org act=dnat 120.5.195.158:48186->20.5.194.12:5364(10.25.165.2:5364) hook=post dir=org act=snat 120.5.195.158:48186->10.25.165.2:5364(10.3.33.11:48186) hook=pre dir=reply act=dnat 10.25.165.2:5364->10.3.33.11:48186(120.5.195.158:48186) hook=post dir=reply act=snat 10.25.165.2:5364->120.5.195.158:48186(20.5.194.12:5364)
policy_id:匹配的策略 ID。vd:VDOM 的索引 index,root vdom 的索引是 0,通过diagnose sys vd list查看。FortiGate # diagnose sys vd list name=root/root index=0 enabled fib_ver=136 rpdb_ver=0 use=172 rt_num=35 asym_rt=0 sip_helper=0, sip_nat_trace=1, mc_fwd=0, mc_ttl_nc=0, tpmc_sk_pl=0配置了多 VRF 时,vd 字段格式为
vdom_index:vrf_id,例如vd=0:20表示 VDOM index 为 0,VRF ID 为 20。serial:会话 ID。子会话(expectation session)与其父会话共享相同的 serial。app:应用 ID。可通过以下命令查看应用详情。FortiGate # get application name status | grep "17678" -B 1 -A 11 app-name: "FortiClient" id: 17678 category: "Update" cat-id: 17 popularity: 4.low risk: 1.mediumurl_cat:URL 分类 ID。常见分类对照如下。ID 分类 ID 分类 0 Unrated 17 Advertising 1 Drug Abuse 18 Brokerage and Trading 3 Hacking 19 Freeware and Software Downloads 4 Illegal or Unethical 20 Games 5 Discrimination 23 Web-based Email 6 Explicit Violence 24 File Sharing and Storage 25 Streaming Media and Download 28 Entertainment 29 Arts and Culture 30 Education 31 Finance and Banking 33 Health and Wellness 34 Job Search 35 Medicine 36 News and Media 37 Social Networking 38 Political Organizations 39 Reference 40 Global Religion 41 Search Engines and Portals 42 Shopping 43 General Organizations 44 Society and Lifestyles 46 Sports 47 Travel 48 Personal Vehicles 49 Business 50 Information and Computer Security 51 Government and Legal Organizations 52 Information Technology 53 Armed Forces 54 Dynamic Content 55 Meaningless Content 56 Web Hosting 58 Folklore 59 Proxy Avoidance 62 Plagiarism 68 Web Chat 69 Instant Messaging 70 Newsgroups and Message Boards 72 Peer-to-peer File Sharing 75 Internet Radio and TV 76 Internet Telephony 77 Child Education 78 Real Estate 79 Restaurant and Dining 80 Personal Websites and Blogs 81 Secure Websites 82 Content Servers 83 Child Abuse 84 Web-based Applications 85 Domain Parking 87 Personal Privacy 89 Auction 92 Charitable Organizations 93 Remote Access 94 Web Analytics 95 Online Meeting 140 custom1 141 custom2 offload:NP 硬件加速卸载状态(发起方向/响应方向)。- 0:会话未卸载到 NP。
- 8:会话已卸载到 NP6。
- 9:会话已卸载到 NP7。
offload=8/8:表示发起方向和响应方向流量均已卸载到 NP6。offload=9/9:表示发起方向和响应方向流量均已卸载到 NP7。