Setting Up Wireguard on Baremetal

/Home /Journal /Services /Projects

Setting up Wireguard on Baremetal (more specifically almalinux 9), most of these tools are made with the containers in mind, sometimes there’s a need to run them on baremetal.

Step 1 - Install needed packages

In my case because i’m using Almalinux most packages were installed either via dnf or yum:

yum install wireguard-tools dumb-init git
yum module install nodejs@20
curl -fsSL https://get.pnpm.io/install.sh | sh -

Step 2 - clone repository

git clone https://github.com/wg-easy/wg-easy/ wg-easy

Step 3 - Setup

mv wg-easy/src /app
pnpm install
pnpm run build

After this you can run /usr/bin/node /app/.output/server/index.mjs after setting the environment variables such as described in the documentation like HOST and PORT.

I created a service under /etc/systemd/system/wg-easy.service with the following:

[Unit]
Description=WG-Easy Service
After=network.target

[Service]
ExecStart=/usr/bin/node .output/server/index.mjs
WorkingDirectory=/app
Restart=always
User=root
Group=root
Environment=PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=nodejs-server

Environment="DEBUG=Server,WireGuard,Database,CMD"
Environment="PORT=51821"
Environment="HOST=0.0.0.0"
Environment="INSECURE=true"
Environment="INIT_ENABLED=false"
Environment="DISABLE_IPV6=true"
[Install]
WantedBy=multi-user.target

which after enabling and start, maintains the service automatically:

systemctl enable wg-easy
systemctl start wg-easy

Last Notes