Web Analytics

openwrt-configurator

⭐ 89 stars French by jasrusable

OpenWrt Configurator

OpenWrt Configurator est un outil CLI et un fichier de configuration JSON correspondant qui vous permet de spécifier l'état complet de votre réseau, y compris la configuration UCI, les paquets et les versions du firmware dans un seul fichier de configuration JSON de type UCI pouvant être déployé sur vos appareils OpenWrt à l'aide d'OpenWrt Configurator.

$ openwrt-configurator provision ./network-config.json

Le fichier de configuration JSON peut être composé de manière conditionnelle avec les clés .if et/ou .overrides, et implémente de légères abstractions sur les ports Ethernet des appareils et les radios Wi-Fi pour prendre en charge de manière transparente la configuration de plusieurs appareils, différents modèles/types d'appareils, ainsi que différents rôles d'appareils (routeur, commutateur, point d'accès dump, etc.) à partir d'un seul fichier de configuration JSON.

  "interface": [
    {
      ".if": "device.tag.role == 'router'", // Apply the pppoe interface to only the router.
      ".name": "wan",
      "device": "eth0",
      "proto": "pppoe",
      "username": "me@pppoe.com",
      "password": "123"
    },
    {
      ".name": "lan",
      "device": "br-lan.1",
      ".overrides": [
        {
          ".if": "device.tag.role == 'router'", // Apply a static ip to only the router.
          "override": {
            "proto": "static",
            "ipaddr": "10.0.0.1",
            "netmask": "255.255.0.0"
          }
        },
        {
          ".if": "device.tag.role != 'router'", // Apply dhcp to all non-router devices.
          "override": {
            "proto": "dhcp"
          }
        }
      ]
    },
  ]

Fonctionnalités

Pour commencer

$ openwrt-configurator print-uci-commands ./network-config.json

device my-ap

apk del --rdepends firewall firewall4 uci set system.system0=system uci set system.system0.hostname='my-ap' uci set system.system0.timezone='Africa/Johannesburg' uci set network.switch0=switch uci set network.switch0.name='switch0' uci set network.switch0.reset='1' uci set network.switch0.enable_vlan='1' ...

Remarque : Pour que cette commande fonctionne, les détails SSH doivent être correctement configurés dans les sections provisioning_config pour chacun de vos appareils.

$ openwrt-configurator provision ./network-config.json
Provisioning device "my-ap" @ root@10.0.0.218
Connecting over SSH...
Connected.
Verifying device...
Verified.
Setting configuration...
Configuration set.
Provisioning completed.
...

Remarque : Pour que cette commande fonctionne, les détails SSH doivent être correctement configurés dans les sections provisioning_config pour chacun de vos appareils.

Comment ça fonctionne

  "devices": [
    {
      "model_id": "ubnt,edgerouter-x",
      "ipaddr": "10.0.0.1",
      "tags": { "role": "router" }, // Give the Edgerouter a tag with role of "router".
      "hostname": "my-router",
      "provisioning_config": {
        "ssh_auth": {
          "username": "root",
          "password": "123"
        }
      }
    },
    {
      "model_id": "tplink,eap245-v3",
      "ipaddr": "10.0.0.218",
      "tags": { "role": "ap" }, // Give the EAP245 a tag with role of "ap".
      "hostname": "my-ap",
      "provisioning_config": {
        "ssh_auth": {
          "username": "root",
          "password": "123"
        }
      }
    }
  ],

  "package_profiles": [
    {
      ".if": "device.tag.role == 'router'", // Install sqm and https-dns-proxy on the router.
      "packages": [
        "sqm-scripts",
        "luci-app-sqm",
        "https-dns-proxy",
        "luci-app-https-dns-proxy"
      ]
    },
    {
      ".if": "device.tag.role == 'ap'", // Uninstall firewall packages from ap's.
      "packages": ["-firewall", "-firewall4"]
    }
  ],
  "config": {
    "dropbear": {
      "dropbear": [
        {
          "PasswordAuth": "on",
          "RootPasswordAuth": "on",
          "Port": 22,
          "BannerFile": "/etc/banner"
        }
      ]
    },
    "system": {
      "system": [
        {
          "timezone": "Africa/Johannesburg"
        }
      ]
    },
    "interface": [
      {
        ".name": "loopback",
        "device": "lo",
        "proto": "static",
        "ipaddr": "127.0.0.1",
        "netmask": "255.0.0.0"
      },
      {
        ".if": "device.tag.role == 'router'", // Apply the pppoe interface to only the router.
        ".name": "wan",
        "device": "eth0",
        "proto": "pppoe",
        "username": "me@pppoe.com",
        "password": "123"
      },
      {
        ".name": "lan",
        "device": "br-lan.1",
        ".overrides": [
          {
            ".if": "device.tag.role == 'router'", // Apply a static ip to only the router.
            "override": {
              "proto": "static",
              "ipaddr": "10.0.0.1",
              "netmask": "255.255.0.0"
            }
          },
          {
            ".if": "device.tag.role != 'router'", // Apply dhcp to all non-router devices.
            "override": {
              "proto": "dhcp"
            }
          }
        ]
      }
    ],
    "wireless": {
      ".if": "device.tag.role == 'ap'", // Applies the entire "wireless" object to only devices with the "ap" tag set.
      "wifi-device": [
        {
          ".name": "radio0",
          "band": "2g"
        },
        {
          ".name": "radio1",
          "band": "5g"
        }
      ],
      "wifi-iface": [
        {
          "mode": "ap",
          "device": ["radio0", "radio1"],
          "network": "lan",
          "ssid": "my-ssid",
          "encryption": "psk2",
          "key": "123456789"
        },
        {
          "mode": "ap",
          "device": ["radio0", "radio1"],
          "network": "guest",
          "ssid": "my-ssid-guest",
          "encryption": "none"
        }
      ]
    }
  }

Feuille de route

Court terme

Long terme

--- Tranlated By Open Ai Tx | Last indexed: 2026-05-05 ---