FOR TIPS, gUIDES & TUTORIALS

subscribe to our Youtube

GO TO YOUTUBE

14455 questions

17168 answers

28195 comments

0 members

We are migrating to our new platform at https://community.teltonika.lt. Moving forward, you can continue discussions on this new platform. This current platform will be temporarily maintained for reference purposes.
0 votes
347 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 anonymous
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 anonymous
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