List firewall rules using UBUS

Hi,

I'm using uci to manage my firewall rules,
I wanna know is there any way to get firewall rules or a set of firewall rules to show on web by calling UBUS from web into JSON format?

for example, I have got this rule:
firewall.@rule[7]=rule
firewall.@rule[7].name='Allow-IPSec-ESP'
firewall.@rule[7].src='wan'
firewall.@rule[7].dest='lan'
firewall.@rule[7].proto='esp'
firewall.@rule[7].target='ACCEPT'
firewall.@rule[8]=rule
firewall.@rule[8].name='Allow-ISAKMP'
firewall.@rule[8].src='wan'
firewall.@rule[8].dest='lan'
firewall.@rule[8].dest_port='500'
firewall.@rule[8].proto='udp'
firewall.@rule[8].target='ACCEPT'

Is it possible to have them in JSON format via UBUS?
I just want to show them on a web page

ubus call uci get '{ "config": "firewall", "type": "rule" }'

2 Likes

thank you so much,
is it possible to have query for specific rule ?
for example get rule[8] ?

Yes, ubus call uci get '{ "config": "firewall", "section": "@rule[8]" }'

2 Likes

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.