Importing objects
WARNING
Folder administrators whose read access privileges are restricted to certain folders on SMC cannot perform this operation. For more information, refer to the section Restricting folder administrators' access privileges.
To quickly import a large number of existing objects on SNS firewalls or to easily create objects, you can use a CSV file and import it on the SMC server from the web interface or command line interface.
With the help of such files, you can specify the firewalls on which each object is to be deployed, among other functions.
An example of a CSV file "example-import-objects.csv" is available on the server, in the folder /opt/stormshield/examples/csv/.
You can either export existing objects from a firewall or create a new CSV file.
To export the CSV file from a firewall:
- Connect to the firewall,
- Go to Objects > Objects,
- Click on Export.
This file contains all the network objects and groups on your firewall.
IMPORTANT
If you are modifying a CSV file that was exported from a firewall, check that the editing software has not modified the contents of the file, in which case the file may not be imported on the SMC server.
To create a new CSV file, and to find out details about header lines and the parameters to specify according to the object's category, you may:
- Choose to export objects from a firewall,
- Look up the example given on the SMC server as indicated above.
Specifying firewalls on which objects are to be deployed
By default, objects are deployed only on the firewalls that use them. However, in the CSV file, you may indicate the firewalls on which deployment will be forced using the #deployment column.
Example of a Host object being created:
- Enter the following parameters in the columns of the file header:
#type,#name,#ip,#ipv6,#resolve,#mac,#deployment,#comment
- Enter the values corresponding to the parameters in the lines after the header for each Host object to be imported (example):
host,dns1.google.com,8.8.8.8,2001:4860:4860::8888,,,ALL,"Google Public DNS Server"
The prescribed values of the #resolve parameter are "dynamic" and "static".
The #deployment parameter may take on any of the following values:
- Empty or DEFAULT: this is its default behavior - the object is deployed only on the firewalls that use it.
- ALL: the object is deployed on all firewalls.
- "Firewall 1,Firewall 2": list of firewall names between quotation marks and separated by commas. The object is deployed on these firewalls as well as the firewalls that use it.
To import objects from the web interface:
- In the Objects menu, click on the icon.
- Select Import.
- Select the CSV file to import.
- If necessary, select the option that allows you to update existing objects by replacing them with objects found in the file.
In case of error, refer to the import summary.
No other actions can be performed on the server while objects are being imported.
- Start by copying the CSV file on the SMC server using the SSH protocol in the /tmp folder for example.
- Log in to the SMC server via the console of your hypervisor or in SSH.
- To import all object types, enter the command:
smc-import-objects --csv-file /tmp/file.csv
. - To view imported objects in the SMC web interface, refresh the page or log off and log on again.
Whether each object or group has been imported will be indicated, as well as a summary when the import is complete.
You can also choose the types of objects to import.
EXAMPLE
To import only Host and IP address range objects from a CSV file, enter the command:smc-import-objects --csv-file /tmp/file.csv --host --range
The commands to be entered according to the type of object are:
Object type | Command |
---|---|
Host | --host |
DNS name (FQDN) | --fqdn |
Network | --network |
IP address range | --range |
Router | --router |
SLA | --sla |
Group 1 | --group |
IP protocol | --protocol |
Service (port) | --service |
Port group | --servicegroup |
Time | --time |
Customized variables such as %CUSTOM_X% can be used instead of IPv4 or IPv6 address values in Host, Network and IP address range objects. These customized variables are defined in the Customized variables tab in the Edit firewall panel accessible by double clicking on the line of a firewall in monitoring view.
If an imported object already existed in SMC, an error will appear. You may use the --update
option to overwrite the existing object with the one indicated in the CSV file.