- CheckMates
- :
- Products
- :
- Developers
- :
- API / CLI Discussion
- :
- Python script to install access rules on check poi...
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Are you a member of CheckMates?
×- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Python script to install access rules on check point R80.40 - add multiple ports
Hi there,
Making use of cpapi, I can write some python scripts to add access rules from an excel file into a check point firewall R80.40
This is the youtube link that I demo the process.
https://www.youtube.com/watch?v=8D4XJ3Bwtrk
One of the limitations of the python scripts is that I can only add a single source IP address, a single destination address and a single port for a given row (or a given single rule number).
But in my work environment, a single rule number most likely contains multiple source IP addresses, multiple destination addresses and multiple ports, such as the sample excel that I upload in this post (ADD_RULES_real_world.xlsx).
It would be great if you could shed some light.
(You can see or download my source code from the youtube link as the file .py is not supported here.)
Thank you.
Marty
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm not able to download the code. From the video, it looks like when you're creating the objects, you set obj_src and obj_dst to be equal to a given name, rather than appending the name to a list. Thus, when you use obj_src and obj_dst later to make the API call to create the rule, they only contain one thing each.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm not able to download the code. From the video, it looks like when you're creating the objects, you set obj_src and obj_dst to be equal to a given name, rather than appending the name to a list. Thus, when you use obj_src and obj_dst later to make the API call to create the rule, they only contain one thing each.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bob,
Thank you for giving me some directions. Will try to work on it about using list.
Already fixed the link on youtube and the source code is zipped here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bob, _Val_ and everyone,
Thanks Bob for providing me a direction on using list. It works like a charm. Another questions are:
1. how to add groups (grouping of different subnets), what is the parameters or keyword I should use in the python script ?
2. how to add port range eg: tcp port 1000-200 ? Again I don't know the parameter of keywords.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Zip and share python code here please.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You may download the source code as below link:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks great demo.
just a question, when I run the script a second time, does it create the objects like host ... again ?
