---
# System prepended metadata

title: fortiGate 批量匯入Address
tags: [客戶經驗, forti]

---

# fortiGate 批量匯入Address

## 1.準備腳本文件
```shell=
//import_addresses.txt

config firewall address
    edit "IP_Address_1"
        set subnet 192.168.1.1 255.255.255.255
    next
    edit "IP_Address_2"
        set subnet 192.168.1.2 255.255.255.255
    next
    ...
end
```

## 2.開啟TFTP並匯入腳本

### 在forti上執行CLI
```shell=
config system settings
    set allowaccess tftp
end

```

```shell
tftp <FortiGate_IP> put import_addresses.txt
```

## 3.執行腳本
### 透過CLI到腳本所在位置
通常腳本位置在root，可以透過以下指令確認位置:
```shell
execute list
:顯示root目錄中所有文件
```
執行腳本
```shell
execute batch-script <filename>
```

# 透過WEB執行腳本

右上方Configuration>>Script
![image](https://hackmd.io/_uploads/H1JbPg4hC.png)

點擊Run Script即可上傳，上傳成功後自動完成。
![image](https://hackmd.io/_uploads/rk-fPe43C.png)
