Description | This article describes how to add bulk MAC address objects via a script. |
Scope | FortiGate. |
Solution |
A list of MAC addresses is quintessential. For this article, the following MAC addresses will be used:
Make sure there are no duplicate entries. Use Microsoft Excel to remove them: Technical Tip: Creation and addition of bulk IP address objects)
Use any text editor such as Notepad++ that is capable of doing text searches using regular expressions. Paste all the MAC addresses in the text editor. andbring the replace window (Ctrl+H) Under 'Find what' use regex without quotes:
For 'Replace with': edit MACaddr-$1\n set type mac\n set mac $1\nnext\n
Either select 'Replace' or 'Replace All' (Ctrl+a) to change all the MAC addresses:
edit MACaddr-00:1A:2B:3C:4D:5E
edit MACaddr-1A:2B:3C:4D:5E:6F
edit MACaddr-3C:4D:5E:6F:7A:8B
edit MACaddr-7A:8B:9C:1D:2E:3F
edit MACaddr-9C:1D:2E:3F:4A:5B
edit MACaddr-5E:6F:7A:8B:9C:1D
edit MACaddr-A1:B2:C3:D4:E5:F6
edit MACaddr-D4:E5:F6:A1:B2:C3
edit MACaddr-56:34:12:98:67:EF
edit MACaddr-34:56:78:90:AB:CD
Note:
config vdom edit <vdom_name> config firewall address
Adding these MACs to the FortiGate can be done in two ways:
|