NOTE:This article applies to firmware version prior to SonicOS 5.8.2.0
This article illustrates how to create address objects and address groups using the Command Line Interface (CLI) of the SonicWall
Address Objects
Address Groups
Creating Address Objects in bulk
Procedure:
Login to the SonicWall CLI using either SSH or Serial connection. For more information on how to login to the CLI, please refer KB ID 170505641032025
Enter the administrator username and password.
You will be presented with the root prompt of the CLI.
Enter "configure" <enter> to enter the device configuration mode.
Address Objects
address-object <name for address object> <Enter>
network 192.168.100.0 255.255.255.0 <Enter>
zone LAN <Enter>
exit <Enter>
Creating Address Object of type Range address-object <name for address object> <Enter>
range 192.168.168.100 192.168.168.200 <Enter>
zone DMZ <Enter>
exit <Enter>
address-object <name for address object> <Enter>
host 192.168.168.112 <Enter>
zone DMZ <Enter>
exit <Enter>
For 6.2.7.1 firmware typeconfig()# address-object ipv4 test host 1.1.1.1 zone LAN
For 5.9.1.8 firmware type
config(0017C55C9E22)# address-object ipv4 test1
(add-ipv4-address-object[test1])# host 1.1.1.1
(add-ipv4-address-object[test1])# zone WAN
address-object <name of a previously created address object> <Enter>
zone LAN <Enter>
exit <Enter>
no address-object <name of a previously created address object> <Enter>
exit <Enter>
show address-object <name of a previously created address object> <Enter>
show address-object <Enter>
address-group <name for the address group> <Enter>
The following commands are available in the address-group prompt
address-group <name for the address group> <Enter>
address-object <name of a previously created address object> <Enter>
exit <Enter>
address-group <name of a previously created address group > <Enter>
address-group <name of a previously created address group> <Enter>
exit <Enter>
Editing Address Groups address-group <name of a previously created address group > <Enter>
no address-object <name of a previously created address object> <Enter>
no address-group <name of a previously created address group> <Enter>
exit <Enter>
Deleting an Address Group no address-group <name of a previously created address group > <Enter>
exit <Enter>
In scenarios where large number of address objects are required to be created, SonicWall CLI has no direct method of creating such large number of address objects. However, if the objects to be created are less than hundred, the workaround would be to use the SonicWall GUI. In NSA firmwares, the Add Address Object window does not auto-close after creating an object. This speeds-up creation of the next object where only the name and IP address has to be changed.
If the objects to be created number in the hundreds or thousands, a better method would be to Copy and Paste the commands from a text file. The text file contents would be similar to this
address-object test1
host 19.168.168.1
zone DMZ
exit
address-object test2
host 19.168.168.2
zone DMZ
exit
address-object test3
host 19.168.168.3
zone DMZ
exit
address-object test4
host 19.168.168.4
zone DMZ
exit
address-object test5
host 19.168.168.5
zone DMZ
exit
address-object test6
host 19.168.168.6
zone DMZ
exit
address-object test7
host 19.168.168.7
zone DMZ
exit
address-object test8
host 19.168.168.8
zone DMZ
exit
address-object test9
host 19.168.168.9
zone DMZ
exit
address-object test10
host 19.168.168.10
zone DMZ
exit
To create a script as above for hundreds of address objects, use a similar script as the following: @Echo Off
Set Count=1
:LOOP
echo address-object Host-%count%
echo host 10.10.10.%count%
echo zone LAN
echo exit
Set /A Count=%Count%+1
If %Count% lss 100 GoTo :LOOP
Set Count=
exit
Save the above script as a batch file (. bat) and run it with a redirection to a file. For example: Address.bat>file.txt
The above command will create a file called file.txt with the following output:
address-object Host-1
host 10.10.10.1
zone LAN
exit
address-object Host-2
host 10.10.10.2
zone LAN
exit
address-object Host-3
host 10.10.10.3
zone LAN
exit
....................upto 10.10.10.100
Copy the contents of file.txt
Login to the CLI and navigate to the Config prompt.
Paste the contents of file.txt.