An External Dynamic List is a text file that is hosted on an external web server so that the firewall can import objects — IP addresses, URLs, domains — included in the list and enforce policy. To enforce policy on the entries included in the external dynamic list, you must reference the list in a supported policy rule or profile. As you modify the list, the firewall dynamically imports the list at the configured interval and enforces policy without the need to make a configuration change or a commit on the firewall. If the web server is unreachable, the firewall uses the last successfully retrieved list for enforcing policy until the connection is restored with the web server.
EDL format txt
examples:
EDL format json
examples:
The EDL feature is not present in the Huawei USG firewall, so it is implemented using API Restconf. An example of how EDL works is taken from the firewall vendor Palo Alto. For work EDL, a separate dedicated Linux station is required, on which the operations of accessing to the EDL web host and installing the EDL on the firewall will take place.
- Firewall objects based on host and network IP addresses
- Firewall objects based on URLs
- Firewall objects based on domains
- EDL format
txt
- EDL format
json
- Firewall Huawei HiSecEngine USG6600E Series
- python3 version >= 3.8 on Linux station
- Сorrectly configured time on Linux station
- Network connectivity between linux station and firewall
- Login to the web-interface of your firewall
- Go to the page
System -> Administrator -> Service Settings -> Northbound Interface Settings
, checkRESTCONF
and clickApply
- Go to the page
System -> Administrator -> Service Settings -> Administrator
, clickAdd
. Fill in theName
andPassword
fields. Select nothing in theRole
field. In theAdvanced Settings
check onlyAPI
. ClickOK
- Go to the page
Policy -> Security Policy -> Security Policy
, clickAdd
. Fill in theName
field. In the fieldSource Address/Region
select address of linux station. In the fieldDestination Zone
selectlocal
zone. In theService
selectTCP/8447
. ClickOK
note: setup example on Debian-family of Linux
-
Get root
sudo -i
-
Install
pip
apt update && apt install python3-pip -y
-
Change directory to script location
cd /usr/local/sbin
-
Clon a repository with script code
git clone https://github.com/Diyckstra/Huawei-USG-6XXXE-External-Dynamic-List.git
-
[optional] Create user from which the script will be executed
useradd -c "Huawei Scripts" -M -r huawei-usg -s /bin/bash && chown -R huawei-usg Huawei-USG-6XXXE-External-Dynamic-List
-
Install script requirements
cd Huawei-USG-6XXXE-External-Dynamic-List && python3 -m pip install -r requirements.txt
-
[optional] Login with created user
su huawei-usg
-
Customize the script input data from the example
cp input.json.example input.json && nano input.json
-
Check the script
python3 edl_main.py
To periodically execute the script, you need to add its execution to the crontab
task scheduler
-
Launch task scheduler
crontab
crontab -e
-
Add a script launch entry to the end of the file, where you can specify the launch time parameters yourself
note: For convenience, use the resource crontab.guru
0 5 */3 * * (cd /usr/local/sbin/Huawei-USG-6XXXE-External-Dynamic-List; python3 edl_main.py >/dev/null 2>&1)
To debug script execution using crontab
, you need to configure crontab
logging in rsyslog
-
Get root (exit from created user to root)
exit
-
Open rsyslog configuration file
nano /etc/rsyslog.conf
-
Add to the end of the file
cron.* /var/log/cron.log
-
Restart the service
systemctl restart rsyslog.service
By default, the rotation is set to 100 MB. If necessary, you can set other values for the rotation parameter, which are defined here.
- Open a file in which log rotation is configured
nano /usr/local/sbin/Huawei-USG-6XXXE-External-Dynamic-List/__init__.py
- In line
logger.add("EDL.log", format="{time:HH:mm:ss DD.MM.YYYY} {level} {message}", rotation="100 MB")
we set the parameterrotation="{paremeter}"
less /usr/local/sbin/Huawei-USG-6XXXE-External-Dynamic-List/EDL.log
less /var/log/cron.log
- USG6630E V600R007C20SPC500
- USG6655E V600R007C20SPC600
- Ubuntu 18.04.6 LTS
- Ubuntu 20.04.6 LTS
- Ubuntu 22.04.2 LTS
- Debian 10
Co-authored-by: Dima Ozolin