Skip to content

Commit

Permalink
Merge 7c8e27b into a37cdea
Browse files Browse the repository at this point in the history
  • Loading branch information
edoput committed Jul 20, 2017
2 parents a37cdea + 7c8e27b commit 728b1b8
Show file tree
Hide file tree
Showing 32 changed files with 3,492 additions and 3 deletions.
7 changes: 4 additions & 3 deletions bin/netjsonconfig
Expand Up @@ -56,10 +56,10 @@ output = parser.add_argument_group('output')

output.add_argument('--backend', '-b',
required=True,
choices=['openwrt', 'openwisp', 'openvpn'],
choices=['openwrt', 'openwisp', 'openvpn', 'airos'],
action='store',
type=str,
help='Configuration backend')
help='Configuration backend: openwrt, openwisp or airos')

output.add_argument('--method', '-m',
required=True,
Expand Down Expand Up @@ -169,7 +169,8 @@ method_arguments = parse_method_arguments(args.args)
backends = {
'openwrt': netjsonconfig.OpenWrt,
'openwisp': netjsonconfig.OpenWisp,
'openvpn': netjsonconfig.OpenVpn
'openvpn': netjsonconfig.OpenVpn,
'airos': netjsonconfig.AirOs,
}

backend_class = backends[args.backend]
Expand Down
213 changes: 213 additions & 0 deletions docs/source/backends/airos.rst
@@ -0,0 +1,213 @@
=============
AirOS Backend
=============

.. include:: ../_github.rst

The ``AirOS`` backend allows to generate AirOS v8.3 compatible configurations.

Initialization
--------------

.. automethod:: netjsonconfig.AirOS.__init__

Initialization example:

.. code-block:: python
from netjsonconfig import AirOS
router = AirOS({
"general": {
"hostname": "MasterAntenna"
}
})
If you are unsure about the meaning of the initalization parameters,
read about the following basic concepts:

* :ref:`configuration_dictionary`
* :ref:`template`
* :ref:`context`

Render method
-------------

.. automethod:: netjsonconfig.AirOS.render

Generate method
---------------

.. automethod:: netjsonconfig.AirOS.generate


Write method
------------

.. automethod:: netjsonconfig.AirOS.write


JSON method
-----------

.. automethod:: netjsonconfig.AirOS.json


General settings
----------------

Network interface
-----------------

From the ``interfaces`` key we can configure the device network interfaces.

AirOS supports the following types of interfaces

* **network interfaces**: may be of type ``ethernet``
* **wirelesss interfaces**: must be of type ``wireless``
* **bridge interfaces**: must be of type ``bridge``

A network interface can be designed to be the management interfaces by setting the ``managed`` key to ``True`` on the address chosen.

As an example here is a snippet that set the vlan ``eth0.2`` to be the management interface on the address ``192.168.1.20``

.. code-block:: json
{
"interfaces": [
{
"name": "eth0.2",
"type": "ethernet",
"addresses": [
{
"address": "192.168.1.20",
"family": "ipv4",
"managed": true,
"mask": 24,
"proto": "static"
}
]
}
]
}
DNS servers
-----------


GUI
---

As an extension to `NetJSON <http://netjson.org/rfc.html>` you can use the ``gui`` key to set the language of the interface and show the advanced network configuration option.

The default values for this key are as reported below

.. code-block:: json
{
"gui": {
"language": "en_US",
"advanced": true
}
}
Netmode
-------

AirOS v8.3 can operate in ``bridge`` and ``router`` mode (but defaults to ``bridge``) and this can be specified with the ``netmode`` property

.. code-block:: json
{
"netmode": "bridge"
}
NTP servers
-----------

This is an extension to the `NetJSON` specification.

By setting the key ``ntp_servers`` in your input you can provide a list of ntp servers to use.

.. code-block:: json
{
"type": "DeviceConfiguration",
...
"ntp_servers": [
"0.ubnt.pool.ntp.org"
]
}
Users
-----

We can specify the user password as a blob divided into ``salt`` and ``hash``.

From the antenna configuration take the user section.

.. code-block:: ini
users.status=enabled
users.1.status=enabled
users.1.name=ubnt
users.1.password=$1$yRo1tmtC$EcdoRX.JnD4VaEYgghgWg1
I the line ``users.1.password=$1$yRo1tmtC$EcdoRX.JnD4VaEYgghgWg1`` there are both the salt and the password hash in the format ``$ algorithm $ salt $ hash $``, e.g in the previous block ``algorithm=1``, ``salt=yRo1tmtC`` and ``hash=EcdoRX.JnD4VaEYgghgWg1``.

To specify the password in NetJSON use the ``user`` property.

.. code-block:: json
{
"type": "DeviceConfiguration",
"user": {
"name": "ubnt",
"passsword": "EcdoRX.JnD4VaEYgghgWg1",
"salt": "yRo1tmtC"
}
}
WPA2
----

AirOS v8.3 supports both WPA2 personal (PSK+CCMP) and WPA2 enterprise (EAP+CCMP) as an authentication protocol. The only ciphers available is CCMP.

As an antenna only has one wireless network available only the first wireless interface will be used during the generation.

As an example here is a snippet that set the authentication protocol to WPA2 personal

.. code-block:: json
{
"interfaces": [
{
"name": "wlan0",
"type": "wireless",
"encryption": {
"protocol": "wpa2_personal",
"key": "changeme"
}
}
]
}
And another that set the authentication protocol to WPA2 enterprise, but this is still not supported by netjsonconfig

.. code-block:: json
{
"interfaces": [
{
"name": "wlan0",
"type": "wireless",
"encryption": {
"protocol": "wpa2_enterprise",
"key": "changeme"
}
}
]
}
Leaving the `NetJSON Encryption object <http://netjson.org/rfc.html#rfc.section.5.4.2.1>` empty defaults to no encryption at all.

0 comments on commit 728b1b8

Please sign in to comment.