【Fortigate】よく使用するCLIコマンド FortiOS6.4.3

FortiGate は、設定や稼働状態の確認のほとんどを GUI で行えます。一方で、GUI ではできない操作や、確認した結果をテキストのログとして残したいときは、CLI のほうが便利なことがあります。

この記事では、FortiGate を使ううえでよく使う CLI コマンドを、実際の出力とあわせて確認します。検証は AWS 上の FortiGate-VM(FortiOS 6.4.3)で行っています。

この記事でわかること
  1. CLI のコマンドの種類(config/show/get/diagnose/execute)と、設定の保存・破棄
  2. 設定の確認と、grep による絞り込み
  3. バージョン、性能、インターフェース、ARP、ルーティングの確認
  4. ping/traceroute、セッション、ログの確認と、再起動・停止

基本操作

コマンドの構造

ログインして ? を押すと、実行できるコマンドの一覧が表示されます。

FortiGate

FortiGate # 
config      Configure object.
get         Get dynamic and system information.
show        Show configuration.
diagnose    Diagnose facility.
execute     Execute static commands.
alias       Execute alias commands.
exit        Exit the CLI.
FortiGate #config設定を変更するend で保存abort で破棄show設定を表示するfull-configurationで初期値もget状態や情報を表示するsystem status などdiagnose詳細な情報や診断sys session list などexecute操作を実行するping/log displayreboot など
図1 CLI のコマンドの種類
コマンド使いどころ
config設定が入っている階層に移動し、設定を変更します。
show設定を表示します。
get状態や情報を表示します(設定の値を表示するときにも使います)。
diagnoseより詳細な情報の表示や、診断に使います。
executeping や再起動など、操作を実行します。

設定を保存する(end)と破棄する(abort)

config の階層で変更した設定は、end で保存して抜けます。保存せずに抜けるときは abort を使います。ここでは、コンソールのページングの設定で確認します。

初期設定では、CLI の出力が長いと途中で --More-- が表示され、キー操作で続きを表示します。ページングをせずに最後まで一度に表示するには、set output standard を設定します。

config system console に移動して show を実行すると、コンソールの設定を確認できます。この例では何も設定されていません(初期値のまま)。

FortiGate

FortiGate # config system console
FortiGate (console) # show
config system console
end
FortiGate (console) #

ページングを無効にします。

FortiGate

FortiGate # config system console  
FortiGate (console) #  set output standard   
FortiGate (console) #  end  

end を実行すると、設定が保存されます。もう一度確認します。

FortiGate

FortiGate # config system console
FortiGate (console) # show
config system console
    set output standard
end
FortiGate (console) #

ページングするように戻すには、set output more を設定します。

FortiGate

FortiGate # config system console 
FortiGate (console) # set output more 
FortiGate (console) # end 

設定が元に戻ったことを確認できます。

FortiGate

FortiGate #  config system console 
FortiGate (console) #  show 
config system console
end
FortiGate (console) #

もう一度 set output standard を設定してみます。今度は、設定を間違えたなどの理由で反映させたくないので、abort を実行します。

FortiGate

FortiGate #  config system console 
FortiGate (console) #  set output standard 
FortiGate (console) #  abort 

設定が反映されていないことを確認できます。

FortiGate

FortiGate #  config system console 
FortiGate (console) #  show 
config system console
end
FortiGate (console) #

設定の確認

設定全体を確認する(show/show full-configuration)

今の設定を確認するには、show を実行します。show は、初期値から変えた設定だけを表示します。

FortiGate(先頭部分)

FortiGate # show
#config-version=FGVMA6-6.4.3-FW-build1778-201021:opmode=1:vdom=0:user=admin
#conf_file_ver=1850439415272169
#buildno=1778
#global_vdom=1
config system global
    set allow-traffic-redirect disable
    set hostname "FortiGate"
    set language japanese
    set timezone 60
end

初期値も含めたすべての設定を表示するには、show full-configuration を実行します。

FortiGate(先頭部分)

FortiGate # show full-configuration 
#config-version=FGVMA6-6.4.3-FW-build1778-201021:opmode=1:vdom=0:user=admin
#conf_file_ver=1850439415272169
#buildno=1778
#global_vdom=1
config system global
    set admin-concurrent enable
    set admin-console-timeout 0
    set admin-hsts-max-age 15552000
    set admin-https-pki-required disable
    set admin-https-redirect enable
    set admin-https-ssl-versions tlsv1-1 tlsv1-2 tlsv1-3
    set admin-lockout-duration 60

同じ config system global でも、show full-configuration では admin-concurrent など、変更していない項目まで表示されています。

階層を絞って確認する

設定全体はとても長いので、確認したい階層だけを表示できます。たとえばインターフェースの設定だけを見るなら、config system interface に移動して show を実行します。

FortiGate(先頭部分)

FortiGate #  config system interface 
FortiGate (interface) #  show 
config system interface
    edit "port1"
        set vdom "root"
        set mode dhcp
        set allowaccess ping https ssh fgfm
        set type physical
        set alias "Internet"
        set snmp-index 1
        set dns-server-override disable
        set mtu-override enable
        set mtu 9001  

ポリシーの設定なら、config firewall policy に移動して show を実行します。

FortiGate(先頭部分)

FortiGate # config firewall policy
FortiGate (policy) # show
config firewall policy
    edit 1
        set name "Internet_to_LAN"
        set uuid a0bcf9c0-2198-51eb-31e7-0daada4bf22c
        set srcintf "port1"
        set dstintf "port2"
        set srcaddr "all"
        set dstaddr "DestNAT"
        set action accept
        set schedule "always"
        set service "PING" "RDP" "SSH"
        set logtraffic all
        set nat enable
    next

出力を絞り込む(grep)

| grep を付けると、特定のキーワードを含む行だけを表示できます。たとえば、設定の中で「Internet」を含む行だけを表示します。

FortiGate

FortiGate # show | grep Internet
        set alias "Internet"
    edit "Internet-Locator-Service"
    edit "AVG-Internet-Security-AV"
    edit "AVG-Internet-Security-FW"

「Internet」または「LAN」を含む行を表示するには、\| でつなぎます。

FortiGate

FortiGate # show | grep 'Internet\|LAN'
        set alias "Internet"
        set alias "LAN"
    edit "Internet-Locator-Service"
    edit "AVG-Internet-Security-AV"
    edit "AVG-Internet-Security-FW"

-f オプションを付けると、キーワードを含む行だけでなく、その行が属する設定のまとまり全体を表示します。キーワードを含む行には <--- が付きます。

FortiGate(先頭部分)

FortiGate # show | grep 'Internet\|LAN' -f
config system interface
    edit "port1"
        set vdom "root"
        set mode dhcp
        set allowaccess ping https ssh fgfm
        set type physical
        set alias "Internet" <---
        set snmp-index 1
        set dns-server-override disable
        set mtu-override enable
        set mtu 9001
    next

大文字と小文字を区別せずに探すときは、-i オプションを付けます。下の例では、小文字の lan を含む set language japanese も一致しています。

FortiGate(先頭部分)

FortiGate # show | grep 'Internet\|LAN' -f -i
config system global
    set alias "FortiGate-VM64-AWS"
    set allow-traffic-redirect disable
    set hostname "FortiGate"
    set language japanese <---
    set timezone 60
end
config system interface
    edit "port1"
        set vdom "root"
        set mode dhcp
        set allowaccess ping https ssh fgfm
        set type physical
        set alias "Internet" <---
        set snmp-index 1
        set dns-server-override disable
        set mtu-override enable
        set mtu 9001
    next
    edit "port2"
        set vdom “root"

バージョン情報(get system status)

OS のバージョンやシリアル番号などは、get system status で確認できます。

FortiGate

FortiGate # get system status 
Version: FortiGate-VM64-AWS v6.4.3,build1778,201021 (GA)
Virus-DB: 81.00984(2020-11-20 21:20)
Extended DB: 81.00984(2020-11-20 21:20)
Extreme DB: 1.00000(2018-04-09 18:07)
IPS-DB: 6.00741(2015-12-01 02:30)
IPS-ETDB: 16.00965(2020-11-19 01:14)
APP-DB: 16.00965(2020-11-19 01:14)
INDUSTRIAL-DB: 16.00965(2020-11-19 01:14)
Serial-Number: FGTXXXXXXXXXXXX
IPS Malicious URL Database: 2.00834(2020-11-20 05:27)
License Status: Valid
VM Resources: 4 CPU, 7653 MB RAM
VM Instance ID: (伏せています)
Log hard disk: Available
Hostname: FortiGate
Operation Mode: NAT
Current virtual domain: root
Max number of virtual domains: 1
Virtual domains status: 1 in NAT mode, 0 in TP mode
Virtual domain configuration: disable
FIPS-CC mode: disable
Current HA mode: standalone
Branch point: 1778
Release Version Information: GA
FortiOS x86-64: Yes
System time: Sun Nov 29 13:56:58 2020
表示意味
Version機種(ここでは AWS 用の VM)と FortiOS のバージョン、ビルド番号です。
Serial-Numberシリアル番号です(ここでは伏せられています)。
Current HA modeHA(冗長構成)の状態です。standalone は単体で動いていることを示します。

性能情報(get system performance status)

CPU やメモリの使用率は、get system performance status で確認できます。

FortiGate

FortiGate # get system performance status 
CPU states: 0% user 0% system 0% nice 100% idle 0% iowait 0% irq 0% softirq
CPU0 states: 0% user 0% system 0% nice 100% idle 0% iowait 0% irq 0% softirq
CPU1 states: 0% user 0% system 0% nice 100% idle 0% iowait 0% irq 0% softirq
CPU2 states: 0% user 0% system 0% nice 100% idle 0% iowait 0% irq 0% softirq
CPU3 states: 0% user 0% system 0% nice 100% idle 0% iowait 0% irq 0% softirq
Memory: 7837360k total, 1207584k used (15.4%), 6428976k free (82.0%), 200800k 
freeable (2.6%)
Average network usage: 12 / 13 kbps in 1 minute, 12 / 18 kbps in 10 minutes, 
17 / 47 kbps in 30 minutes
Average sessions: 31 sessions in 1 minute, 27 sessions in 10 minutes, 
25 sessions in 30 minutes
Average session setup rate: 1 sessions per second in last 1 minute, 
0 sessions per second in last 10 minutes, 0 sessions per second in last 30 minutes
Virus caught: 0 total in 1 minute
IPS attacks blocked: 0 total in 1 minute
Uptime: 0 days,  0 hours,  31 minutes

インターフェースの情報

get system interface physical

インターフェースの IP アドレス、状態、速度、デュプレックスを確認するには、get system interface physical を実行します。今回は仮想環境のため速度とデュプレックスが n/a になっていますが、物理アプライアンスでは表示されます。

FortiGate

FortiGate # get system interface physical 
== [onboard]
        ==[port1]
                mode: dhcp
                ip: 10.0.0.122 255.255.255.0
                ipv6: ::/0
                status: up
                speed: n/a (Duplex: n/a)
        ==[port2]
                mode: dhcp
                ip: 10.0.1.128 255.255.255.0
                ipv6: ::/0
                status: up
                speed: n/a (Duplex: n/a)

get hardware nic ポート名

ポートのカウンタ(送受信パケット数、エラー、ドロップなど)は、get hardware nic ポート名 で確認できます。

FortiGate

FortiGate # get hardware nic port1 
Name:            port1
Driver:          ena
Version:         2.1.1g
Bus:             0000:00:05.0
Hwaddr:          0a:2c:e0:22:63:fc
Permanent Hwaddr:0a:2c:e0:22:63:fc
State:           up
Link:            up
Mtu:             9001
RX Ring:                 1024
TX Ring:                 1024
Rx packets:              20520
Rx bytes:                4070485
Rx compressed:           0
Rx dropped:              0
Rx errors:               0
  Rx Length err:         0
  Rx Buf overflow:       0
  Rx Crc err:            0
  Rx Frame err:          0
  Rx Fifo overrun:       0
  Rx Missed packets:     0
Tx packets:              19542
Tx bytes:                11005199
Tx compressed:           0
Tx dropped:              0
Tx errors:               0
  Tx Aborted err:        0
  Tx Carrier err:        0
  Tx Fifo overrun:       0
  Tx Heartbeat err:      0
  Tx Window err:         0
Multicasts:              0
Collisions:              0

fnsysctl ifconfig/diagnose netlink interface list

fnsysctl ifconfig(内部コマンド)や diagnose netlink interface list name ポート名 でも、インターフェースの情報を確認できます。

FortiGate

FortiGate # fnsysctl ifconfig port1
port1   Link encap:Ethernet  HWaddr 0A:2C:E0:22:63:FC
        inet addr:10.0.0.122  Bcast:10.0.0.255  Mask:255.255.255.0
        UP BROADCAST RUNNING MULTICAST  MTU:9001  Metric:1
        RX packets:21333 errors:0 dropped:0 overruns:0 frame:0
        TX packets:20129 errors:0 dropped:0 overruns:0 carrier:0
        collisions:0 txqueuelen:1000 
        RX bytes:4221439 (4.0 MB)  TX bytes:11174082 (10.7 MB)

FortiGate

FortiGate # diagnose netlink interface list name port1

if=port1 family=00 type=1 index=3 mtu=9001 link=0 master=0
ref=50 state=start present fw_flags=0 flags=up broadcast run multicast 
Qdisc=mq hw_addr=0a:2c:e0:22:63:fc broadcast_addr=ff:ff:ff:ff:ff:ff
stat: rxp=22057 txp=20701 rxb=4375125 txb=11342128 
rxe=0 txe=0 rxd=0 txd=0 mc=0 collision=0
re: rxl=0 rxo=0 rxc=0 rxf=0 rxfi=0 rxm=0
te: txa=0 txc=0 txfi=0 txh=0 txw=0
misc rxc=0 txc=0
input_type=0 state=3 arp_entry=0 refcnt=50

ネットワークの情報

ARP テーブル(get system arp/diagnose ip arp list)

ARP テーブルは、get system arp で確認できます。

FortiGate

FortiGate # get system arp
Address           Age(min)   Hardware Addr      Interface
10.0.0.1          0          0a:34:d8:c4:fc:4c port1
10.0.1.1          1          0a:eb:80:77:4f:3c port2

より詳しい情報は、diagnose ip arp list で確認します。

FortiGate

FortiGate # diagnose ip arp list 
index=3 ifname=port1 10.0.0.1 0a:34:d8:c4:fc:4c state=00000002 use=44 
confirm=41 update=2505 ref=27
index=4 ifname=port2 10.0.1.1 0a:eb:80:77:4f:3c state=00000004 use=2527 
confirm=8527 update=2527 ref=0
index=5 ifname=root 0.0.0.0 00:00:00:00:00:00 state=00000040 use=2513 
confirm=44 update=196209 ref=2

ルーティングテーブル(get router info routing-table)

ルーティングテーブルは、get router info routing-table all で確認できます。

FortiGate

FortiGate # get router info routing-table all  
Codes: K - kernel, C - connected, S - static, R - RIP, B - BGP
       O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
       * - candidate default


Routing table for VRF=0
S*      0.0.0.0/0 [5/0] via 10.0.0.1, port1
C       10.0.0.0/24 is directly connected, port1
C       10.0.1.0/24 is directly connected, port2

特定のルートの詳細も確認できます。0.0.0.0/0 の詳細を確認するには、次のように実行します。

FortiGate

FortiGate # get router info routing-table details 0.0.0.0/0

Routing table for VRF=0
Routing entry for 0.0.0.0/0
  Known via "static", distance 5, metric 0, best
  * 10.0.0.1, via port1 distance 0

ルーティングテーブルにないネットワークを指定すると、% Network not in table と表示されます。

FortiGate

FortiGate # get router info routing-table details 172.31.0.0/16
% Network not in table

ネットワークの診断(execute ping/execute traceroute)

ping は execute ping で実行します。止めるときは Ctrl+C を押します。

FortiGate

FortiGate # execute ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: icmp_seq=0 ttl=104 time=1.5 ms
64 bytes from 8.8.8.8: icmp_seq=1 ttl=104 time=1.5 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=104 time=1.5 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=104 time=1.5 ms
^C
--- 8.8.8.8 ping statistics ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max = 1.5/1.5/1.5 ms

execute ping-options で、送信元のインターフェースやデータサイズなどのオプションを設定できます。

FortiGate

FortiGate # execute ping-options 
adaptive-ping     Adaptive ping .
data-size         Integer value to specify datagram size in bytes.
df-bit            Set DF bit in IP header yes | no.
interface         Auto | outgoing interface.
interval          Integer value to specify seconds between two pings.
pattern           Hex format of pattern, e.g. 00ffaabb.
repeat-count      Integer value to specify how many times to repeat PING.
reset             Reset settings.
source            Auto | source interface IP.
timeout           Integer value to specify timeout in seconds.
tos               IP type-of-service option.
ttl               Integer value to specify time-to-live.
use-sdwan         Use SD-WAN rules to get output interface yes | no.
validate-reply    Validate reply data yes | no.
view-settings     View the current settings for PING option.

ここでは、データサイズを 1000 バイトにして ping を実行します。

FortiGate

FortiGate # execute ping-options data-size 1000

FortiGate # execute ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 1000 data bytes
76 bytes from 8.8.8.8: icmp_seq=0 ttl=104 time=2.5 ms
76 bytes from 8.8.8.8: icmp_seq=1 ttl=104 time=2.5 ms
^C
--- 8.8.8.8 ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 2.5/2.5/2.5 ms

ping のオプションを初期値に戻すには、execute ping-options reset を実行します。CLI はコマンドを途中まで入力しても一意に決まれば実行できるので、下の例の execut でも動作しています。

FortiGate

FortiGate # execut ping-options reset

traceroute は execute traceroute で実行します。

FortiGate

FortiGate # execute traceroute 8.8.8.8
traceroute to 8.8.8.8 (8.8.8.8), 32 hops max, 3 probe packets per hop, 84 byte packets
 1  54.150.128.39   107.906 ms  51.061 ms  73.596 ms
 2  * * *
 3  * * *
 4  * * *
 5  * * *
 6  * * *
 7  100.65.11.1  0.217 ms  6.843 ms  11.893 ms
 8  52.93.73.223  2.859 ms  2.869 ms  3.140 ms
 9  52.93.72.191  3.417 ms  3.284 ms  3.321 ms
10  52.93.72.94  2.503 ms  2.523 ms  2.500 ms
11  100.91.137.16  3.036 ms  3.129 ms  3.491 ms
12  100.91.3.178  4.223 ms  3.984 ms  4.143 ms
13  100.91.147.21  3.486 ms  3.481 ms  3.434 ms
14  52.95.30.43  3.612 ms  5.829 ms  5.025 ms
15  54.239.53.243  3.494 ms  16.693 ms  6.130 ms
16  209.85.149.236  2.644 ms  2.535 ms  2.538 ms
17  108.170.226.179  2.544 ms  2.568 ms  2.574 ms
18  216.239.41.69  3.336 ms  3.338 ms  3.522 ms
19  8.8.8.8   2.525 ms  2.526 ms  2.565 ms

traceroute にもオプションがあり、ping と同じように execute traceroute-options で設定します。

FortiGate

FortiGate # execute traceroute-options 
device           Auto | ifname.
queries          Integer value to specify number of queries per hop.
source           Auto | source interface IP.
view-settings    View the current options of traceroute.

セッションの情報

get system session status

セッションの総数は、get system session status で確認できます。

FortiGate

FortiGate # get system session status  
The total number of IPv4 sessions for the current VDOM: 22

get system session list

セッションの一覧は、get system session list で確認できます。

FortiGate

FortiGate #  get system session list
PROTO   EXPIRE SOURCE           SOURCE-NAT       DESTINATION      DESTINATION-NAT 
tcp     3596   (伏せています):51029 -                10.0.0.122:443   -               
tcp     0      (伏せています):51013 -                10.0.0.122:443   -               
tcp     3595   (伏せています):51028 -                10.0.0.122:443   -               
tcp     0      (伏せています):51012 -                10.0.0.122:443   -               
udp     168    10.0.0.122:23608 -                96.45.33.65:8888 -               
udp     168    10.0.0.122:23608 -                96.45.33.66:8888 -               
udp     168    10.0.0.122:23608 -                96.45.33.64:8888 -               
tcp     3596   (伏せています):51027 -                10.0.0.122:443   -   

diagnose sys session list

セッションの詳しい情報は、diagnose sys session list で確認できます。

FortiGate(1セッション分)

FortiGate # diagnose sys session list 

session info: proto=17 proto_state=01 duration=1567 expire=172 timeout=0 
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=255/255
state=local nds 
statistic(bytes/packets/allow_err): org=1400/14/1 reply=1008/14/1 tuples=2
tx speed(Bps/kbps): 0/0 rx speed(Bps/kbps): 0/0
orgin->sink: org out->post, reply pre->in dev=0->3/3->5 gwy=0.0.0.0/10.0.0.122
hook=out dir=org act=noop 10.0.0.122:2743->12.34.97.72:8888(0.0.0.0:0)
hook=in dir=reply act=noop 12.34.97.72:8888->10.0.0.122:2743(0.0.0.0:0)
misc=0 policy_id=0 auth_info=0 chk_client_info=0 vd=0
serial=0000027b tos=ff/ff app_list=0 app=0 url_cat=0
sdwan_mbr_seq=0 sdwan_service_id=0
rpdb_link_id=00000000 rpdb_svc_id=0 ngfwid=n/a
npu_state=00000000

セッションが多いと出力が長くなるので、フィルタで条件に合うセッションだけを表示できます。条件は次のとおり設定できます。

FortiGate

FortiGate # diagnose sys session filter  
vd                Index of virtual domain. -1 matches all.
vd-name           Name of virtual domain. -1 or "any" matches all.
sintf             Source interface.
dintf             Destination interface.
src               Source IP address.
nsrc              NAT'd source ip address
dst               Destination IP address.
proto             Protocol number.
sport             Source port.
nport             NAT'd source port
dport             Destination port.
policy            Policy ID.
expire            expire
duration          duration
proto-state       Protocol state.
session-state1    Session state1.
session-state2    Session state2.
ext-src           Add a source address to the extended match list.
ext-dst           Add a destination address to the extended match list.
ext-src-negate    Add a source address to the negated extended match list.
ext-dst-negate    Add a destination address to the negated extended match list.
clear             Clear session filter.
negate            Inverse filter.

たとえば、宛先 IP アドレスが 10.0.0.122(FortiGate の port1)のセッションだけを表示します。まず、フィルタを初期化します。

FortiGate

FortiGate # diagnose sys session filter clear 

宛先 IP アドレスを 10.0.0.122 にしてフィルタを設定し、セッションを表示します。

FortiGate

FortiGate # diagnose sys session filter dst 10.0.0.122 
FortiGate # diagnose sys session list 

session info: proto=6 proto_state=01 duration=257 expire=3599 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/0
state=local may_dirty 
statistic(bytes/packets/allow_err): org=24763/330/1 reply=37049/202/1 tuples=2
tx speed(Bps/kbps): 79/0 rx speed(Bps/kbps): 165/1
orgin->sink: org pre->in, reply out->post dev=3->5/5->3 gwy=10.0.0.122/0.0.0.0
hook=pre dir=org act=noop (伏せています):54532->10.0.0.122:443(0.0.0.0:0)
hook=post dir=reply act=noop 10.0.0.122:443->(伏せています):54532(0.0.0.0:0)
pos/(before,after) 0/(0,0), 0/(0,0)
misc=0 policy_id=4294967295 auth_info=0 chk_client_info=0 vd=0
serial=0000062e tos=ff/ff app_list=0 app=0 url_cat=0
sdwan_mbr_seq=0 sdwan_service_id=0
rpdb_link_id=00000000 rpdb_svc_id=0 ngfwid=n/a
npu_state=00000000

FortiGate の port1 の 443 番(管理画面の HTTPS)に向かうセッションが表示されています。state=local は、FortiGate 自身が通信の端点になっているセッションであることを示します。

補足

セッションのフィルタは、設定したまま残ります。別の条件で調べるときは、先に diagnose sys session filter clear で初期化します。

ログの確認(execute log)

CLI で、カテゴリを指定してログを表示できます。カテゴリは次のとおりです。

FortiGate

FortiGate # execute log filter category 
Available categories:
 0: traffic
 1: event
 2: utm-virus
 3: utm-webfilter
 4: utm-ips
 5: utm-emailfilter
 7: utm-anomaly
 8: utm-voip
 9: utm-dlp
10: utm-app-ctrl
12: utm-waf
15: utm-dns
16: utm-ssh
17: utm-ssl
18: utm-cifs
19: utm-file-filter
20: utm-icap

フィルタを設定する前に、まずフィルタを初期化します。

FortiGate

FortiGate #  execute log filter reset 

トラフィックログを表示する

トラフィックログのカテゴリ番号は 0 です。カテゴリを設定して、execute log display で表示します。

FortiGate

FortiGate # execute log filter category 0 


FortiGate # execute log display  
541 logs found.
10 logs returned.
8.6% of logs has been searched.


1: date=2020-11-21 time=14:39:37 eventtime=1605937177415146788 tz="+0900" 
logid="0000000013" type="traffic" subtype="forward" level="notice" vd="root" srcip=10.0.1.26 
srcport=61468 srcintf="port2" srcintfrole="undefined" dstip=8.8.8.8 dstport=53 
dstintf="port1" dstintfrole="undefined" srccountry="Reserved" dstcountry="United States" 
sessionid=2012 proto=17 action="accept" policyid=2 policytype="policy" 
poluuid="5cdfb3ea-2199-51eb-a077-6fc45b024eb9" policyname="LAN_to_Internet" 
service="DNS" trandisp="snat" transip=10.0.0.200 
transport=61468 appid=16195 app="DNS" appcat="Network.Service" apprisk="elevated" 
applist="default" duration=180 sentbyte=82 rcvdbyte=157 sentpkt=1 rcvdpkt=1 
utmaction="allow" countdns=1 utmref=65535-6414


Web フィルタのログを表示する

Web フィルタのログのカテゴリ番号は 3 です。フィルタをいったん初期化してから、カテゴリ 3 を設定します。

FortiGate

FortiGate #  execute log filter reset  
FortiGate #  execute log filter category 3 
FortiGate #  execute log display  
22 logs found.
10 logs returned.
10.5% of logs has been searched.


1: date=2020-11-21 time=14:23:25 eventtime=1605936205378552169 tz="+0900" 
logid="0316013056" type="utm" subtype="webfilter" eventtype="ftgd_blk" 
level="warning" vd="root" policyid=2 sessionid=1760 srcip=10.0.1.26 srcport=49913 
srcintf="port2" srcintfrole="undefined" dstintf="port1" dstintfrole="undefined" proto=6 
service="HTTPS" 
hostname="www.youtube.com" profile="default" action="blocked" 
reqtype="direct" url="https://www.youtube.com/" sentbyte=204 rcvdbyte=0 
direction="outgoing" msg="URL belongs to a denied category in policy" 
method="domain" cat=25 catdesc=" ストリーミングメディア.ダウンロード"


表示する件数を変える

上の例のとおり、初期設定では 10 件だけ表示されます。件数を増やすには、execute log filter view-lines で変更します。次の例では 100 件にします。

FortiGate(1件目のみ)

FortiGate # execute log filter reset
FortiGate # execute log filter category 3
FortiGate # execute log filter view-lines 100


FortiGate # execute log display
209 logs found.
100 logs returned.

1: date=2020-11-21 time=14:23:25 eventtime=1605936205378499234 
tz="+0900" logid="0316013056" type="utm" subtype="webfilter" eventtype="ftgd_blk" 
level="warning" vd="root" policyid=2 sessionid=1761 srcip=10.0.1.26 srcport=49914 
srcintf="port2" srcintfrole="undefined" dstip=216.239.38.119 dstport=443 dstintf="port1" 
dstintfrole="undefined" proto=6 service="HTTPS" hostname="www.youtube.com" 
profile="default" action="blocked" reqtype="direct" url="https://www.youtube.com/" 
sentbyte=204 rcvdbyte=0 direction="outgoing" 
msg="URL belongs to a denied category in policy" method="domain" cat=25 
catdesc=" ストリーミングメディア.ダウンロード"

フィールドを指定して絞り込む

たとえば、送信元 IP アドレス(srcip)が 10.0.1.25 の Web フィルタのログだけを表示するには、execute log filter free-style で条件を指定します。

FortiGate

FortiGate # execute log filter reset 
FortiGate # execute log filter category 3
 
FortiGate # execute log filter free-style "srcip 10.0.1.25"


FortiGate # execute log display 
187 logs found.
10 logs returned.


1: date=2020-11-13 time=21:28:16 eventtime=1605270495993591440 
tz="+0900" logid="0316013056" 
type="utm" subtype="webfilter" eventtype="ftgd_blk" level="warning" 
vd="root" policyid=2 sessionid=421 srcip=10.0.1.25 srcport=49722 srcintf="port2" 
srcintfrole="undefined" dstip=172.217.25.78 dstport=443 dstintf="port1" dstintfrole="undefined" 
proto=6 service="HTTPS" hostname="www.youtube.com" profile="default" 
action="blocked" reqtype="direct" url="https://www.youtube.com/" sentbyte=204 rcvdbyte=0 
direction="outgoing" msg="URL belongs to a denied category in policy" method="domain" 
cat=25 catdesc=" ストリーミングメディア.ダウンロード"


再起動と停止

再起動するときは execute reboot、停止するときは execute shutdown を実行します。どちらも確認が表示されるので、y を入力します。

FortiGate

FortiGate #  execute reboot 
This operation will reboot the system !
Do you want to continue? (y/n) y

System is rebooting...

FortiGate

FortiGate # execute shutdown 
This operation will shutdown the system !
Do you want to continue? (y/n)y


System is shutting down...

まとめ

コマンド確認・操作できること
config / end / abort設定の変更/保存して抜ける/保存せずに抜ける
show / show full-configuration変更した設定/初期値を含むすべての設定
| grep -f -i出力の絞り込み(-f:設定のまとまりごと、-i:大文字小文字を区別しない)
get system statusバージョン、シリアル番号、HA の状態
get system performance statusCPU、メモリ、セッション数の推移
get system interface physicalインターフェースの IP、状態、速度
get hardware nic ポート名ポートのカウンタ(エラー、ドロップ)
get system arpARP テーブル
get router info routing-table allルーティングテーブル
execute ping / traceroute疎通と経路の確認(-options でオプション設定)
diagnose sys session filter / list条件で絞り込んだセッションの詳細
execute log filter / displayカテゴリや条件を指定したログの表示
execute reboot / shutdown再起動/停止

コメント