A lightweight Wake on LAN server that can be installed on Raspberry Pi or other lightweight Linux devices.
- Simple REST API for sending Wake on LAN packets
- JWT authentication for security
- Small memory footprint
- Systemd service for automatic startup
- CORS configuration for connecting from web applications
- Device management with persistent storage
- Network scanning capabilities
- Raspberry Pi Zero 2W/3/4/5 or other lightweight Linux devices
- Node.js 12.x or higher
- Internet connection for installation
- The server must be on the same network as the devices you want to wake
Download and run the installer script from the latest release:
# Download the installer from the latest release
wget https://github.com/yourusername/wol-server/releases/latest/download/install.sh
chmod +x install.sh
./install.sh
# Replace v1.0.0 with your desired version
wget https://github.com/yourusername/wol-server/releases/download/v1.0.0/install.sh
chmod +x install.sh
./install.sh
If you prefer to install manually:
- Install Node.js (if not already installed):
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs
- Install arp-scan:
sudo apt-get update
sudo apt-get install -y arp-scan
- Create installation directory:
sudo mkdir -p /opt/wol-server
cd /opt/wol-server
- Download files from the latest release:
# Replace v1.0.0 with the latest version
RELEASE_URL="https://github.com/yourusername/wol-server/releases/download/v1.0.0"
sudo wget "$RELEASE_URL/wol-server.js"
sudo wget "$RELEASE_URL/package.json"
sudo wget "$RELEASE_URL/.env.example" -O .env
- Set permissions and install dependencies:
sudo chown -R $USER:$USER /opt/wol-server
npm install --production
- Create systemd service:
sudo tee /etc/systemd/system/wol-server.service > /dev/null << EOL
[Unit]
Description=Wake on LAN Server
After=network.target
[Service]
Type=simple
User=$USER
WorkingDirectory=/opt/wol-server
ExecStart=/usr/bin/node /opt/wol-server/wol-server.js
Restart=always
Environment=NODE_ENV=production
[Install]
WantedBy=multi-user.target
EOL
- Enable and start the service:
sudo systemctl daemon-reload
sudo systemctl enable wol-server
sudo systemctl start wol-server
After installation, edit the configuration file:
sudo nano /opt/wol-server/.env
Set your JWT_SECRET and ALLOWED_ORIGINS:
PORT=8080
JWT_SECRET=your_very_secure_jwt_secret_here
ALLOWED_ORIGINS=http://localhost:3000,https://yourdomain.com
All endpoints except /api/status
require JWT authentication. Include the token in the Authorization header:
Authorization: Bearer your_jwt_token_here
GET /api/status
Returns the server status and version.
GET /api/devices
POST /api/devices
Content-Type: application/json
{
"name": "My Computer",
"macAddress": "00:11:22:33:44:55",
"ipAddress": "192.168.1.100",
"tags": ["desktop", "work"]
}
PATCH /api/devices/{id}
Content-Type: application/json
{
"name": "Updated Name"
}
DELETE /api/devices/{id}
POST /api/wake
Content-Type: application/json
{
"macAddress": "00:11:22:33:44:55",
"broadcastAddress": "255.255.255.255",
"port": 9
}
POST /api/devices/{id}/wake
GET /api/network/scan
Scans the local network for devices and returns their IP and MAC addresses.
To use this WOL server with a web application:
- Configure ALLOWED_ORIGINS in the .env file to include your web app's domain
- Generate JWT tokens using the same JWT_SECRET
- Make API calls to the server endpoints with proper authentication
Example JavaScript usage:
// Wake a device
const response = await fetch('http://your-pi-ip:8080/api/wake', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer your_jwt_token'
},
body: JSON.stringify({
macAddress: '00:11:22:33:44:55'
})
});
const result = await response.json();
console.log(result.message);
sudo systemctl status wol-server
sudo journalctl -u wol-server -f
# Check status
curl -X GET http://localhost:8080/api/status
# Test with authentication (replace YOUR_JWT_TOKEN)
curl -X POST http://localhost:8080/api/wake \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-d '{"macAddress": "00:11:22:33:44:55"}'
- Service won't start: Check Node.js installation and file permissions
- Authentication errors: Verify JWT_SECRET is set and tokens are valid
- CORS errors: Add your domain to ALLOWED_ORIGINS in .env
- Network scan fails: Ensure arp-scan is installed and user has proper permissions
To update to a new version:
- Stop the service:
sudo systemctl stop wol-server
- Download and run the new installer
- The installer will preserve your .env configuration
npm install # Include dev dependencies
npm run dev # Uses nodemon for auto-restart
wol-server/
├── wol-server.js # Main server application
├── package.json # Dependencies and scripts
├── .env.example # Environment variables template
├── devices.json # Device storage (created automatically)
└── README.md # This file
MIT License - see the full license in the repository.