7877 questions

9301 answers

14976 comments

12781 members

0 votes
95 views 2 comments
by
Hello,

Is it somehow possible to get firewall rules in a json format? Device is RUT955.  Have bunch of them and would like to some scripting on them. json would be good format to work with. I know, that I can do "uci show firewall", but have not managed to put that into a json-rpc query.
by
What is the firmware on the device ?

Did you tried on latest if it works ?

https://wiki.teltonika-networks.com/view/RUT955_Firmware_Downloads

3 Answers

+1 vote
by

Figured it out. If somebody else needs:

curl -d "{\"jsonrpc\":\"2.0\", \"id\":1, \"method\":\"call\", \"params\":[\"a74c8e07646f0da2bfddce35bf3de1f3\", \"uci\", \"get\", { \"config\":\"firewall\", \"type\":\"rule\" } ] }" https://192.168.1.1/ubus

It is "get" not "show" and type should be rule.

Best answer
0 votes
by
by

Yes I did.  I got the rules with curl -d "{\"jsonrpc\": \"2.0\", \"id\": 1, \"method\": \"call\", \"params\": [\"a74c8e07646f0da2bfddce35bf3de1f3\", \"file\", \"exec\", {\"command\":\"cat\", \"params\": [\"/etc/config/firewall\"] } ] }" http://192.168.1.1/ubus

but I was hoping to get a prettier json

If I do something like:

curl -d "{\"jsonrpc\":\"2.0\", \"id\":1, \"method\":\"call\", \"params\":[\"a74c8e07646f0da2bfddce35bf3de1f3\", \"uci\", \"show\", { \"config\":\"firewall\" } ] }" https://192.168.1.1/ubus

I get :

{

  "jsonrpc": "2.0",

  "id": 1,

  "result": [

    3

  ]

}

I think I'm missing some parameters
0 votes
by
Tried with 6.6.1 and 5.3.3. Stll the same results.  I am not willing to update software, as we have some stability issues with latest firmware