Quote from: Monviech (Cedrik) on July 23, 2025, 06:17:31 AMhttps://docs.opnsense.org/manual/firewall_automation.html#processing-orderagain, thx a lot for your helps for saving my time. this topic is SOVLED
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts MenuQuote from: Monviech (Cedrik) on July 23, 2025, 06:17:31 AMhttps://docs.opnsense.org/manual/firewall_automation.html#processing-orderagain, thx a lot for your helps for saving my time. this topic is SOVLED
Quote from: Monviech (Cedrik) on July 22, 2025, 07:08:32 PMDid you look at Firewall - Automation - Filter and select the OpenVPN Group?Yes but I didn't see there are different groups. and yes, all my customs rules are here.
def add_firewall_rules(cn):
payload = {
"rule":{
"interface": "openvpn",
"type": "pass",
"direction": "in",
"quick": "1",
"ipprotocol": "inet",
"protocol": "TCP/UDP",
"source": {
"address": cn + "_net"
},
"enabled": "1",
"destination": {
"address": cn + "_openvpn_host",
"port": cn + '_port',
},
"description": cn + 'fw1'
}
}
result=add_firewall_rules(cn)
print(result)
'result': 'saved', 'uuid': 'f2d28fb8-84a8-4f9c-a049-6f0ee2755e9c'}
that's fine. But, the added rule is not visible on GUI interface. I'm looking for it for hours but it's invisible.Quote from: meyergru on July 18, 2025, 09:43:35 AMWhen you try to enter that in the web UI, you will get an error, too. When you expand the text in the content box, you see that a correct list will be showing every port on its own line. In the JSON, you need to have a string like "8\n18".
Quote from: meyergru on July 17, 2025, 06:43:30 PMFrom what that shows, the listed ports are transmitted one per line, separated by a newline character, not by a comma. A range would probably be given by 1:18, not 1-18.Yeah, you right. a port range is more like 1:18. but I don't understand what you mean by " separated by a newline character". "content": "8,18" is not supposed to put 8,18 in content ?
def add_client_dstport_alias(cn, cn_ports):
payload = {
"alias": {
"type": "port",
"enabled": "1",
"name": cn + '_port',
"description": cn,
"content": "8,18",
"proto": "",
"updatefreq": "",
"counters": "0",
"categories": ""
}
}
return api_post('/api/firewall/alias/addItem', payload)
and I got en error: