edoput / netjsonconfig

Network configuration management library based on NetJSON DeviceConfiguration
http://netjsonconfig.openwisp.org/
Other
1 stars 0 forks source link

Investigate command line tools on airos #25

Open edoput opened 7 years ago

edoput commented 7 years ago

The system configuration is kept in /tmp/system.cfg. Well, it's not really kept in there, it is stored in NVRAM and read into there on boot. There are command line tools for maniuplating this. They are all bound up in a multi-call binary called ubntbox, evidently a nod to busybox. The main interesting one is,

cfgmtd -- read and write the config to the NVRAM

So, for example, one thing that one might do is

vi /tmp/system.cfg
cfgmtd -w

to edit the config, and then write it to NVRAM

Once you have saved it you can reboot by issuing the “reboot” command or you can do a soft apply:

/usr/etc/rc.d/rc.softrestart save
edoput commented 7 years ago

Unfortunately it does still cut the user out of the antenna but it leaves a wonderful ouput

WA.v8.1.4# /usr/etc/rc.d/rc.do.softrestart save
--- /tmp/.running.cfg.2728
+++ /tmp/.system.cfg.2728
@@ -1,98 +1,74 @@
+
+aaa.status=disabled
+bridge.1.comment=
 bridge.1.devname=br0
-bridge.1.fd=1
-bridge.1.port.1.devname=eth0
-bridge.1.port.2.devname=ath0
-bridge.1.port.3.devname=eth1
+bridge.1.port.1.devname=wlan0
+bridge.1.port.1.status=enabled
+bridge.1.port.2.devname=eth0
+bridge.1.port.2.status=enabled
+bridge.1.status=enabled
+bridge.1.stp.status=enabled
 bridge.status=enabled
-dhcpc.1.devname=br0
-dhcpc.1.status=enabled
-dhcpc.status=disabled
-dhcpd.1.status=disabled
-dhcpd.status=disabled
-ebtables.status=enabled
-ebtables.sys.arpnat.1.devname=ath0
-ebtables.sys.arpnat.1.status=enabled
-ebtables.sys.arpnat.status=enabled
-ebtables.sys.eap.1.devname=ath0
-ebtables.sys.eap.1.status=enabled
-ebtables.sys.eap.status=disabled
-ebtables.sys.status=enabled
-gui.language=en_US
+discovery.cdp.status=enabled
+discovery.status=enabled
+dyndns.status=disabled
 httpd.https.port=443
 httpd.https.status=enabled
+httpd.port=80
+httpd.session.timeout=900
 httpd.status=enabled
 netconf.1.devname=eth0
-netconf.1.flowcontrol.rx.status=enabled
-netconf.1.flowcontrol.tx.status=enabled
-netconf.1.ip=0.0.0.0
-netconf.1.netmask=255.255.255.0
-netconf.1.promisc=enabled
+netconf.1.ip=192.168.1.20
+netconf.1.mut=1500
+netconf.1.netmask=24
 netconf.1.status=enabled
 netconf.1.up=enabled
-netconf.2.allmulti=enabled
-netconf.2.devname=ath0
-netconf.2.ip=0.0.0.0
-netconf.2.netmask=255.255.255.0
-netconf.2.promisc=enabled
-netconf.2.status=enabled
-netconf.2.up=enabled
-netconf.3.autoip.status=enabled
-netconf.3.devname=br0
-netconf.3.ip=192.168.1.20
-netconf.3.netmask=255.255.255.0
-netconf.3.role=mlan
-netconf.3.status=enabled
-netconf.3.up=enabled
-netconf.4.devname=eth1
-netconf.4.flowcontrol.rx.status=enabled
-netconf.4.flowcontrol.tx.status=enabled
-netconf.4.ip=0.0.0.0
-netconf.4.netmask=255.255.255.0
-netconf.4.promisc=enabled
-netconf.4.status=enabled
-netconf.4.up=enabled
 netconf.status=enabled
-netmode=bridge
-radio.1.ack.auto=enabled
-radio.1.ackdistance=600
-radio.1.acktimeout=31
-radio.1.countrycode=380
-radio.1.cwm.enable=0
-radio.1.cwm.mode=1
-radio.1.devname=ath0
-radio.1.dfs.status=enabled
-radio.1.ieee_mode=auto
-radio.1.low_txpower_mode=disabled
-radio.1.mode=Managed
-radio.1.obey=enabled
-radio.1.polling=enabled
-radio.1.pollingnoack=0
-radio.1.pollingpri=
-radio.1.ptpmode=1
-radio.1.reg_obey=enabled
-radio.1.status=enabled
-radio.1.subsystemid=0xe7f5
-radio.1.txpower=28
-radio.countrycode=380
-radio.status=enabled
-route.1.devname=br0
-route.1.gateway=192.168.1.1
-route.1.ip=0.0.0.0
-route.1.netmask=0
-route.1.status=enabled
-route.status=enabled
+netmode.status=enabled
+ntpclient.status=disabled
+pwdog.delay=300
+pwdog.period=300
+pwdog.retry=3
+pwdog.status=enabled
+resolv.host.1.name=
+resolv.nameserver.1.ip=192.168.18.30
+resolv.nameserver.1.status=enabled
+resolv.nameserver.2.ip=192.168.18.40
+resolv.nameserver.2.status=enabled
+resolv.status=enabled
+snmp.community=public
+snmp.contact=
+snmp.location=
+snmp.status=enabled
+sshd.auth.passwd=enabled
 sshd.port=22
 sshd.status=enabled
-syslog.status=enabled
-system.cfg.version=65547
+syslog.status=disabled
+system.external.reset=enabled
+telnetd.port=23
+telnetd.status=disabled
+update.check.status=enabled
 users.1.name=ubnt
 users.1.password=$1$tL963iDU$SXu0h02ZZYfnoZcPkIlK21
 users.1.status=enabled
-users.status=enabled
+users.status=disabled
+vlan.1.comment=
+vlan.1.devname=eth0
+vlan.1.id=1
+vlan.1.status=enabled
+vlan.status=enabled
 wireless.1.addmtikie=enabled
-wireless.1.devname=ath0
+wireless.1.devname=wlan0
 wireless.1.hide_ssid=disabled
 wireless.1.security.type=none
-wireless.1.ssid=ubnt
+wireless.1.signal_led1=75
+wireless.1.signal_led2=50
+wireless.1.signal_led3=25
+wireless.1.signal_led4=15
+wireless.1.signal_led_status=enabled
+wireless.1.ssid=test
 wireless.1.status=enabled
+wireless.1.wds.status=enabled
 wireless.status=enabled
+wpasupplicant.device.1.status=disabled
+wpasupplicant.profile.1.network.1.ssid=your-ssid-here
Fast system script build Success.
Fast syslog script build Success. Disabled plugin from startup list
Fast users script build Success.
Fast resolv script build Success.
Fast radio script build failed
Fixup Startup_list ...Done.
Connection to 192.168.1.20 closed by remote host.
Connection to 192.168.1.20 closed.

These are the changes applied to a factory-reset from the netjson

{
    "general":{},
    "interfaces": [
        {
            "name": "wlan0",
            "type": "wireless",
            "encryption": {
                "protocol": "none"
            },
            "wireless": {
                "radio": "ath0",
                "mode": "access_point",
                "ssid": "test"
            }
        },
        {
            "type":"ethernet",
            "name":"eth0",
            "addresses":[
                {
                    "address": "192.168.1.20",
                    "mask": 24,
                    "family": "ipv4",
                    "proto": "static"
                }
            ]
        },
        {
            "type":"ethernet",
            "name":"eth0.1"
        },
        {
            "name": "br0",
            "type":"bridge",
            "bridge_members":[ "wlan0", "eth0"]
        }
    ],
    "dns_servers": [
        "192.168.18.30",
        "192.168.18.40"
    ]

}