透明模式注意事项与排错

注意事项

  1. 默认情况下全新FortiGate不转发BPDU报文,这样可能会导致STP问题从而引起网络出现二层环路,可以登陆到全新FortiGate命令行下,进入到接口编辑下面,执行命令启用BPDU转发:set stpforward enable。

     FGT # config system interface
     FGT (interface) #edit port1   
     FGT (port1) #set stpforwad enable        #默认为关闭
     FGT (port1) #next
     然后依次进入各接口启用stpforward功能
    
  2. 可以使用forward domain来控制指定的接口间数据转发,具有相同的forward domain号不同的接口间数据包可转发。

    FGT # config system interface
    FGT (interface) # edit wan1
    FGT (wan1) # set forward-domain 10
    FGT (wan1) # next
    FGT (interface) # edit wan2
    FGT (wan2) # set forward-domain 10
    FGT (wan2) # end
    
    说明:forward-domain无需提前定义,直接配置生效;forward-domain如同转发域的概念,广播包只会在同个转发域进行广播。
  3. 只有Ethernet II类型帧可以被转发,在默认的配置下,所有的其他类型的二层协议都不能被转发。需要转发这些帧请在接口下面启用l2forward功能。

    FGT # config system interface
    FGT (interface) #edit port1 
    FGT (port1) #set l2forward enable       #默认为关闭
    FGT (port1) #next
    然后依次登陆各接口启用l2forward功能
    
  4. 多播包默认情况下是转发的,所以如果部署透明模式的防火墙接入到多播环境中如果不通,要注意下面的两个参数值,默认是转发的状态。

    FGT # config system settings
    FGT (settings)set multicast-skip-policy disable   #默认为关闭 
    FGT (settings)end
    
    另外多播策略存在一条默认的any到any的全通策略:
    config firewall multicast-policy
        edit 1
            set srcintf "any"
            set dstintf "any"
            set srcaddr "all"
            set dstaddr "all"
        next
    end
    
  5. 缺省情况下广播是不受策略控制的,除了ARP广播是允许的,其他的广播流量全部是被禁止转发的,看默认配置如下,如需开启广播转发需要在接口开启broadcast-forward。

    config system interface
        edit "port1"
            set allowaccess ping https ssh http fgfm
            set broadcast-forward enable   //默认为关闭
        next
    end
    然后依次进入各接口启用broadcast-forward功能
    
  6. 如果明确需要带外管理功能的话,请设置多VDOM,其中VDOM root仅用来管理其他相关的透明VDOM使用。

    FortiGate_Transparent # config system global
    FortiGate_Transparent (global) # set vdom-mode
    no-vdom       Disable split/multiple VDOMs mode.
    split-vdom    Enable split VDOMs mode.
    multi-vdom    Enable multiple VDOMs mode.
    FortiGate_Transparent (global) # set vdom-mode multi-vdom    //开启多VDOM模式
    FortiGate_Transparent (global) # end
    You will be logged out for the operation to take effect.
    Do you want to continue? (y/n)y
    exit
    FortiGate_Transparent login: admin
    Password:
    Welcome !
    
  7. 如果部署透明模式的全新FortiGate到路由器和主机直连的时候,请注意在这段线路中是否会出现相同的源目的IP地址数据流在防火墙不同方向上时的MAC地址不一致的情况,简单的应用如VRRP之类的主机路由备份协议,这种流量的数据流源目MAC,正向和反向是不一样的,这种情况下请尽量在防火墙上面设置静态IP/MAC以告诉全新FortiGate指定的虚拟MAC地址属于某个VRRP组。

    注意,一个forward_domain里面只能指定一个相同MAC地址对。
  8. 透明模式下查查看MAC表,使用diag netlink brctl name host VDOM_name.b查看,以下以root的vdom为例:

    FGT# diag netlink brctl name host root.b
    show bridge control interface root.b host.
    fdb: size=256, used=6, num=7, depth=2, simple=no
    Bridge root.b host table
    port no device devname mac addr ttl attributes
    2 7 wan2 02:09:0f:78:69:00 0 Local Static
    5 6 trunk_1 02:09:0f:78:69:01 0 Local Static
    3 8 dmz 02:09:0f:78:69:01 0 Local Static
    4 9 internal 02:09:0f:78:69:02 0 Local Static
    3 8 dmz 00:80:c8:39:87:5a 194
    4 9 internal 02:09:0f:78:67:68 8
    1 3 wan1 00:09:0f:78:69:fe 0 Local Static
    
  9. 透明模式的功能限制:

    • 只支持策略模式的IPSec,支持用户认证。

    • 不支持接口模式IPSec,不支持SSL VPN,不支持动态路由和策略路由、不支持DHCP。

总结

透明模式的FortiGate其实默认只转发ARP广播和组播报文(默认存在一条全通的组播策略,如果删除了这条默认的组播全通策略,仍然会放通IPv6 ND的组播流量,而丢弃其他的组播流量),其他的流量通通会被丢弃。如果你想让防火墙更像一个SW一样的存在,那么在使用的二层接口下应该这样去修改。

config system interface
    edit "port1"
        set broadcast-forward enable    //开启广播转发
        set l2forward enable            //开启非IP流量转发
        set stpforward enable           //开启STP转发
    next
    edit "port2"
        set broadcast-forward enable
        set l2forward enable
        set stpforward enable
    next 
end

这样FortiGate对接入的网络环境影响应该来说是更小的,对于那种不是很清楚网络中有一些什么流量的环境,建议按照上述建议进行配置优化,让FortiGate更加接近于一个SW的存在。

特别注意:接口下的vlanforward保持为默认的disable,不要去动,不要去动,可能会引起环路!

最佳实践

  1. 不要将透明模式的两个物理接口连接到同一个VLAN或同一个SW/HUB(相同广播域),SW一旦检测到相同的MAC地址出现在不同的接口,大部分的二层交换机会出现MAC地址表翻转,会让网络非常的不稳定或环路。

  2. 如果网络中存在VLAN,需要在FGT上创建了多个VLAN,要确保给每一个VLAN-ID分配一个独立的Forwarding Domain ID确保广播在VLAN之间被隔离(透明模式下VLAN之间不隔离广播,Fortiward-Domain才隔离广播)。

    FortiGate_Transparent # config system interface
    FortiGate_Transparent (interface) # edit Inside_VLAN10
    FortiGate_Transparent (Inside_VLAN10) # set forward-domain 10
    FortiGate_Transparent (Inside_VLAN10) # next
    
  3. 在所有接口上开启 stpforward enable(开启二层转发的一些特性,防止误丢一些二层数据帧)。

    config system interface
        edit "portX"
            set broadcast-forward enable 
            set l2forward enable           
            set stpforward enable         
        next
    end
    
  4. 使用一个独立的透明模式的VDOM用来保护二层的业务流量,然后再使用一个独立管理VDOM(NAT路由模式)用于设备的管理和fortiguard升级等,利用VDOM功能将管理(NAT路由模式)和业务(透明模式)分离。

  5. 仅将用于生产的业务接口置于透明模式VDOM中。将所有其他接口置于NAT路由模式VDOM中,这可以防止潜在的第2层环路。

故障排错

  1. 先检查FortiGate的二层MAC地址表。注意,在透明模式下,FortiGate是根据二层转发数据库进行转发二层数据,该数据库只能在Global通过命令”diag netlink brctl name host root.b”进行导出,ARP表只能在有IP访问FortiGate的情况下出现。外部设备发送的ARP/GARP会映射到二层转发表,并且当MAC地址变更的时候会在会话同步更改目标MAC地址。下面的命令能导出每一个VDOM桥实例的二层转发表,在转发表里可以单独看到VLAN/VDOM里的MAC地址。

    diag netlink brctl list
    diag netlink brctl name host <VDOM_name>.b
    
    trans VDOM查看二层转发表的例子:
    diag netlink brctl name host trans.b
    
    输出如下:
    diagnose netlink brctl name host trans.b
    show bridge control interface trans.b host.
    fdb: size=2048, used=4, num=8, depth=3
    Bridge trans.b host table
    port no device  devname mac addr                ttl     attributes
      7     21      port3vlan200    00:50:79:66:68:01       0        Static
      1     3        port1   52:c9:fd:91:54:00       0       Local Static
      6     20      port2vlan200    52:c9:fd:91:54:01       0       Local Static
      3     17      port2vlan100    52:c9:fd:91:54:01       0       Local Static
      2     4        port2   52:c9:fd:91:54:01       0       Local Static
      8     5        port3   52:c9:fd:91:54:02       0       Local Static
      7     21      port3vlan200    52:c9:fd:91:54:02       0       Local Static
      5     19      port3vlan100    52:c9:fd:91:54:02       0       Local Static
    
  2. 使用sniffer验证数据包是否到达防火墙,通过以下命令使用sniffer抓取相应信息。同时通过使用ping在FortiGate两端进行测试可以初步分析问题。这个能看到在FortiGate上面流入以及流出的数据包。

    进行抓取目的地址是114.114.119.119的数据:
    diagnose sniffer packet any "host 114.114.119.119" 4 0 l    //按CTRL+C进行停止
    
    基于端口进行数所包抓取
    diagnose sniffer packet portA  "host 114.114.119.119" 4 0  l
    diagnose sniffer packet portB  "host 114.114.119.119" 4 0  l
    
    如有需要,可以通过每个vlan进行获取更明细内容
    diagnose sniffer packet <each_vlan_interface> "" 6 0 l
    
    参数4和6的区别(用于显示输出抓取数据参数):
    1: print header of packets (只有IP头部)
    2: print header and data from ip of packets (有ip头部和数据内容)
    3: print header and data from ethernet of packets  (if available)
    4: print header of packets with interface name (只有IP头部和端口)
    5: print header and data from ip of packets with interface name (有ip头部和数据内容以及端口)
    6: print header and data from ethernet of packets (if available) with intf name
    
    参数0的用处:输出个数
    
    参数l的用处(用于输出时候显示的时间格式):
    a:absolute UTC time, yyyy-mm-dd hh:mm:ss.ms
    l:absolute LOCAL time, yyyy-mm-dd hh:mm:ss.ms
    
  3. 使用debug flow验证数据包是否穿越防火墙(vlanforward无效)。在每一个VDOM使用"debug flow"命令进行跟踪流量,通过使用ping在FortiGate两端进行测试可以初步分析问题,这种排障的方法能够查看到流量是否因为某条策略导致数据包不通或者通过设备。

    以源地址为抓取条件
    ==================================================================
    diag debug flow filter add <IP_address_of_source_device>
    diag debug flow show function-name enable
    diag debug flow show console enable
    diag debug flow show iprope enable
    diag debug flow trace start 100
    diag debug enable
    ==================================================================
    如需要停止,可以敲"diag debug flow trace stop"
    
    以目标地址为抓取条件
    ==================================================================
    diag debug flow filter add <IP_address_of_destination_device>
    diag debug flow show function-name enable
    diag debug flow show console enable
    diag debug flow show iprope enable
    diag debug flow trace start 100
    diag debug enable
    ==================================================================
    如需要停止,可以敲"diag debug flow trace stop"
    
    当有触发排障的流,输出如下:
    id=20085 trace_id=113 msg="vd-tp_mode received a packet(proto=6,10.160.0.160:4370->10.160.0.152:23) from internal."
    id=20085 trace_id=113 msg="Find an existing session, id-00000a40, original direction"
    id=20085 trace_id=113 msg="enter fast path"
    id=20085 trace_id=113 msg="send out via dev-dmz1, dst-mac-00:01:02:03:04:05"
    
  4. 查看数据包在防火墙上创建的session。在每一个VDOM使用"diag sys session"命令进行防火墙会话检查,通过使用ping在FortiGate两端进行测试可以初步分析问题,这种排障的方法能够查看防火墙是否会为流量创建会话,以及是否硬件加速以及命中哪一条策略。

    以源地址为抓取条件(单播)
    ==================================================================
    diag sys session filter src <IP_address_of_source_device>
    diag sys session list
    ==================================================================
    当有触发排障的会话,输出如下:
    session info: proto=1 proto_state=00 duration=2 expire=58 timeout=0 flags=00000000 sockflag=00000000 sockport=0 av_idx=0 use=4
    origin-shaper=
    reply-shaper=
    per_ip_shaper=
    class_id=0 ha_id=0 policy_dir=0 tunnel=/ vlan_cos=0/0
    state=may_dirty br
    statistic(bytes/packets/allow_err): org=500/5/1 reply=500/5/1 tuples=2
    tx speed(Bps/kbps): 248/1 rx speed(Bps/kbps): 248/1
    orgin->sink: org pre->post, reply pre->post dev=9->10/10->9 gwy=0.0.0.0/0.0.0.0
    hook=pre dir=org act=noop 192.168.1.1:64->192.168.2.1:8(0.0.0.0:0)
    hook=post dir=reply act=noop 192.168.2.1:64->192.168.1.1:0(0.0.0.0:0)
    misc=0 policy_id=4 auth_info=0 chk_client_info=0 vd=1
    serial=00000512 tos=ff/ff app_list=0 app=0 url_cat=0
    rpdb_link_id = 00000000
    vlanid=100 dd_type=0 dd_mode=0
    total session 1
    
    以源地址为抓取条件(多播)
    ==================================================================
    diagnose sys mcast-session list
    ==================================================================
    当有触发排障的会话,输出如下:
    session info: id=123 vf=1 proto=112 192.168.1.2.0->224.0.0.18.0
    used=2 path=1 duration=1353 expire=179 indev=10 pkts=1360 bytes=54400
    state=00000002:tp
    path: policy=0, outdev=9
    
    session info: id=124 vf=1 proto=112 192.168.2.99.0->224.0.0.18.0
    used=2 path=1 duration=1353 expire=179 indev=10 pkts=1360 bytes=54400
    state=00000002:tp
    path: policy=0, outdev=9
    Total 2 sessions
    

参考文档


https://community.fortinet.com/t5/FortiGate/Technical-Tip-Troubleshoot-and-verify-if-traffic-is-hitting-a/ta-p/197261

https://community.fortinet.com/t5/FortiGate/Troubleshooting-Tip-First-steps-to-troubleshoot-connectivity/ta-p/192560

https://community.fortinet.com/t5/FortiGate/Troubleshooting-Tip-FortiGate-session-table-information/ta-p/196988

https://community.fortinet.com/t5/FortiGate/Technical-Tip-Configuring-a-FortiGate-in-Transparent-mode-to/ta-p/197611

https://community.fortinet.com/t5/FortiGate/Technical-Note-FortiGate-and-Gratuitous-ARP-GARP/ta-p/192962

Copyright © 2023 Fortinet Inc. All rights reserved. Powered by Fortinet TAC Team.
📲扫描下方二维码分享此页面👇
该页面修订于: 2023-09-12 15:24:08

results matching ""

    No results matching ""