opnsense-cli icon indicating copy to clipboard operation
opnsense-cli copied to clipboard

Possible to view / edit interface configuration?

Open dbjungle opened this issue 1 year ago • 7 comments

I've noticed when I try to view a specific interface it seems to have no effect. I receive more details if I output to yaml, but I'm still unable to do a specific interface. Further more changing one of these aspects (dhcphostname on wan for example) seems to have no effect.

root@DE1FW01:~ # opnsense show interfaces 
   opnsense: {
       interfaces: {
           wan: {…}
           lan: {…}
           lo0: {…}
       }
   }

root@DE1FW01:~ # opnsense show interfaces wan
   opnsense: {
       interfaces: {
           wan: {…}
           lan: {…}
           lo0: {…}
       }
   }

root@DE1FW01:~ # opnsense -y show interfaces wan
opnsense:
    interfaces:
        lan:
            enable: "1"
            if: vtnet1
            ipaddr: 10.1.4.2
            ipaddrv6: track6
            media: ""
            mediaopt: ""
            subnet: "24"
            subnetv6: "64"
            track6-interface: wan
            track6-prefix-id: "0"
        lo0:
            descr: Loopback
            enable: "1"
            if: lo0
            internal_dynamic: "1"
            ipaddr: 127.0.0.1
            ipaddrv6: ::1
            subnet: "8"
            subnetv6: "128"
            type: none
            virtual: "1"
        wan:
            dhcp6-ia-pd-len: "0"
            dhcphostname: DE1FW01
            enable: "1"
            gateway: WAN_GW
            if: vtnet0
            ipaddr: dhcp
            ipaddrv6: dhcp6
            media: ""
            mediaopt: ""

root@DE1FW01:~ # 

Is there something I'm doing wrong?

dbjungle avatar Jul 14 '24 12:07 dbjungle

looks like your conf/config.xml has something oddly encoded for interfaces branch. Can you check the XML output of opnsense CLI for interfaces branch, and compare it with your actual interfaces branch in conf/config.xml?

My expectation is that these two won't match - that the parser in opnsense CLI doesn't understand something you have in config.xml.

mihakralj avatar Jul 16 '24 00:07 mihakralj

btw, I am really delighted that you discovered this project and actually gave it a try; I abandoned further development of CLI when there was zero traction/interest to get opnsense CLI tool to manage the firewall.

mihakralj avatar Jul 16 '24 00:07 mihakralj

btw, I am really delighted that you discovered this project and actually gave it a try; I abandoned further development of CLI when there was zero traction/interest to get opnsense CLI tool to manage the firewall.

Is the project completely abandoned? I'm thinking about writing some extensions, in order to build a bridge for ansible automation. I've actually written a small patch to save the JSON output in the file - are you interested in merging it it?

Thanks!

rhaido avatar Jul 17 '24 08:07 rhaido

Sure, happy to contribute. This project might get more attention this summer again - my vacation tinkering. 😊

mihakralj avatar Jul 17 '24 17:07 mihakralj

Sure, happy to contribute. This project might get more attention this summer again - my vacation tinkering. 😊

I've just opened a merge request, as discussed.

rhaido avatar Jul 18 '24 14:07 rhaido

looks like your conf/config.xml has something oddly encoded for interfaces branch. Can you check the XML output of opnsense CLI for interfaces branch, and compare it with your actual interfaces branch in conf/config.xml?

My expectation is that these two won't match - that the parser in opnsense CLI doesn't understand something you have in config.xml.

Sorry for the late response. I have been quite busy with work lately. The interfaces look normal in the XML and it matches the yaml output. Everything looks correct in the XML output of the opnsense CLI as well, but it just can't display any further than the top level of interfaces.

dbjungle avatar Jul 19 '24 06:07 dbjungle

btw, I am really delighted that you discovered this project and actually gave it a try; I abandoned further development of CLI when there was zero traction/interest to get opnsense CLI tool to manage the firewall.

I saw on reddit there were a lot of CLI tools so i tried the best looking one (this one). Then I tried the others. I'm guessing most people just modify the XML directly or have gotten used to the FreeBSD commands.

dbjungle avatar Jul 19 '24 06:07 dbjungle