halmartin / meraki-builder

Scripts and tools to assemble firmware images for various Meraki MS switches and MX routers
GNU General Public License v3.0
70 stars 16 forks source link

add initial config daemon script #18

Closed hall closed 1 year ago

hall commented 2 years ago

Initial shell script daemon to poll /etc/switch.json for changes. Intended to manage the config describe in #2 and eventually be the backend for #3.

Currently, only PoE enable/disable is implemented as a proof of concept.

The following steps should work for testing.

  1. generate the switch.json file:
    switch_status | jq > /etc/switch.json
  2. execute the script: ./configd (first time will take a minute, depending on number of ports)
  3. edit /etc/switch.json
  4. wait up to 10s for change to be made

Implemented:

hall commented 2 years ago

Added functionality to set the pvid and allowed_vlans. Is there any documentation on this /click filesystem interface? Just sort of poking through what you already have to see what works. For example, I'm not sure which file to write to enable/disable a port.

halmartin commented 2 years ago

Added functionality to set the pvid and allowed_vlans. Is there any documentation on this /click filesystem interface? Just sort of poking through what you already have to see what works. For example, I'm not sure which file to write to enable/disable a port.

The click project exists, but I think it has diverged significantly from what Cisco use on their devices.

I am not aware of any public documentation for the click filesystem.

I'm not sure how to disable a port, that's never been a use case I tested.

Here are some failed attempts:

echo "PORT 2, ALLOWED_VLANS 1, ALLOW_TAGGED_IN 0, ALLOW_UNTAGGED_IN 0, PVID 1, UNTAGGED_VID 1" > /click/switch_port_table/set_vlan_allports_conf
echo "PORT 2, MODE forced, FORCE_SPEED 0" > /click/switch_port_table/set_port_phy_cfgs
halmartin commented 2 years ago

Alright, using another Meraki switch with stock firmware (but with root access) I've figured out how to disable a port:

echo "PORT 1, MODE off" > /click/switch_port_table/set_port_phy_cfgs

To reenable the port, do the following:

echo "PORT 1, MODE aneg" > /click/switch_port_table/set_port_phy_cfgs

You can also force the port speed with the following:

echo "PORT 5, MODE forced, FORCE_SPEED 100fdx" > /click/switch_port_table/set_port_phy_cfgs
hall commented 2 years ago

Nice find! I would never have guessed aneg (even though that's what's shown in /click/switch_port_table/dump_port_phy_cfgs).

I added port enable/disable functionality and a forced link speed setting (where 0 reverts to auto-negotiated).

hall commented 1 year ago

Closing in favor of #29.