Skip to content

Instantly share code, notes, and snippets.

@jesserockz
Last active July 10, 2025 20:27
Show Gist options
  • Save jesserockz/f6e7dc277c8f850dd3d353d41138bb4b to your computer and use it in GitHub Desktop.
Save jesserockz/f6e7dc277c8f850dd3d353d41138bb4b to your computer and use it in GitHub Desktop.
Tailscale script for GL-iNet Beryl AX side switch

Tailscale script for GL-iNet Beryl AX side switch

This script allows you to toggle tailscale settings using the physical side switch on the GL-iNet Beryl AX.

To install, copy the below file to /etc/gl-switch.d/tailscale.sh and replace the exit_node_ip value with your exit node ip address.

Make sure to set the execute bit on the new file: chmod +x /etc/gl-switch.d/tailscale.sh

Then go to System -> Toggle Button Settings and choose Tailscale (On/Off) in the dropdown and Apply

#!/bin/sh
action=$1
if [ "$action" = "on" ];then
enabled=true
lan_enabled=false
wan_enabled=true
exit_node_ip="{{ REPLACE WITH YOUR EXIT NODE IP }}"
elif [ "$action" = "off" ];then
enabled=true
lan_enabled=false
wan_enabled=true
exit_node_ip=""
else
echo "Usage: $0 [on|off]"
exit 1
fi
curl -H 'glinet: 1' -s -k http://127.0.0.1/rpc -d "{\"jsonrpc\":\"2.0\",\"method\":\"call\",\"params\":[\"\",\"tailscale\",\"set_config\",{\"enabled\":$enabled,\"lan_enabled\":$lan_enabled,\"wan_enabled\":$wan_enabled,\"exit_node_ip\":\"$exit_node_ip\"}],\"id\":1}"
sleep 5
@rdgerken
Copy link

Thanks for posting this! I modified it to turn Tailscale completely off or on (with an exit node). A few things:

  • For some reason, the GUI hides the WAN/LAN enable setting when custom exit node is enabled. This seems like a bug in the GUI maybe? I notice that if they are enabled/applied, and THEN you configure a custom exit node, they would remain on the last configured state - so I don't know why the GUI is hiding those options. I think a long time ago, when using an exit node, the WAN/LAN settings did not apply on the Tailscale side of things, but to my knowledge, the functionality to expose at least the LAN side optionally when using an exit node was added to the Tailscale feature set
  • Be sure to set execute rights on the tailscale.sh file after copying to the router

@lucfig
Copy link

lucfig commented Mar 6, 2025

Thanks for posting this! I modified it to turn Tailscale completely off or on (with an exit node). A few things:

  • For some reason, the GUI hides the WAN/LAN enable setting when custom exit node is enabled. This seems like a bug in the GUI maybe? I notice that if they are enabled/applied, and THEN you configure a custom exit node, they would remain on the last configured state - so I don't know why the GUI is hiding those options. I think a long time ago, when using an exit node, the WAN/LAN settings did not apply on the Tailscale side of things, but to my knowledge, the functionality to expose at least the LAN side optionally when using an exit node was added to the Tailscale feature set
  • Be sure to set execute rights on the tailscale.sh file after copying to the router

Mind sharing your script?

@MrKaiba
Copy link

MrKaiba commented Mar 18, 2025

I tried using this on the Slate-AXT 1800 but didnt seem to work, should this work across all GLiNET units with the toggle switch or do they have different saving of files for the toggle switch?

@DougS026
Copy link

DougS026 commented May 17, 2025

Mind sharing your script?

Here is what I'm using, and I believe it addresses @lucfig's question. It differs from the original by: a) It turns Tailscale completely off or on (with an exit node) as @rdgerken mentions, and b) This script switches what side is on and off from the factory. Below will turn off Tailscale when the switch is to the left and turn it on when the switch is to the right (the side with the dot). This makes more sense to me.

#!/bin/sh

action=$1

if [ "$action" = "off" ]; then  # Switched the logic so "off" now enables Tailscale
  enabled=true
  lan_enabled=false
  wan_enabled=true
  exit_node_ip="{{ REPLACE WITH YOUR EXIT NODE IP }}"
elif [ "$action" = "on" ]; then  # "On" now fully disables Tailscale
  enabled=false
  lan_enabled=false
  wan_enabled=false
  exit_node_ip=""
else
  echo "Usage: $0 [on|off]"
  exit 1
fi

curl -H 'glinet: 1' -s -k http://127.0.0.1/rpc -d "{\"jsonrpc\":\"2.0\",\"method\":\"call\",\"params\":[\"\",\"tailscale\",\"set_config\",{\"enabled\":$enabled,\"lan_enabled\":$lan_enabled,\"wan_enabled\":$wan_enabled,\"exit_node_ip\":\"$exit_node_ip\"}],\"id\":1}"

sleep 5

As noted, be sure to set execute rights on the tailscale.sh file after copying to the router.

@smolz
Copy link

smolz commented Jul 2, 2025

Any idea if this would work for the Slate 7?

@DougS026
Copy link

DougS026 commented Jul 2, 2025

Sorry, no idea.

@jesserockz
Copy link
Author

I never expected people to actually find and use this 🙈
I more put it here for my own reference for when an upgrade wiped it out..haha

Good to see it has been helpful though

@smolz
Copy link

smolz commented Jul 10, 2025

Used @DougS026 script and it works a treat.

@DougS026
Copy link

@smolz, I assume you mean on the Slate 7? Thanks for letting us know!

@smolz
Copy link

smolz commented Jul 10, 2025

@smolz, I assume you mean on the Slate 7? Thanks for letting us know!

yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment