Skip to content

Commit e701c11

Browse files
use manual instead of wg-quick
1 parent 07cdf68 commit e701c11

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

init-wireguard.sh

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,10 @@ if [ -z "$NODE_PRIV_KEY" ] || [ -z "$NODE_WG_IP" ] || [ -z "$SERVER_PUB_KEY" ] |
5353
exit 1
5454
fi
5555

56-
# Write wg0.conf
56+
# Write config to file
5757
mkdir -p /wireguard/config
58-
WG_CONFIG="/wireguard/config/wg0.conf"
58+
IFACE=wg0
59+
WG_CONFIG="/wireguard/config/$IFACE.conf"
5960
echo "[WIREGUARD] Writing WireGuard config to $WG_CONFIG ..."
6061
cat <<EOF > $WG_CONFIG
6162
[Interface]
@@ -72,9 +73,15 @@ chmod 600 $WG_CONFIG
7273

7374
# Start WireGuard
7475
echo "[WIREGUARD] Starting WireGuard with $WG_CONFIG ..."
75-
wg-quick up $WG_CONFIG
76+
# wg-quick up $WG_CONFIG
77+
ip link add dev $IFACE type wireguard
78+
ip address add dev $IFACE $NODE_WG_IP/30
79+
wg set $IFACE private-key $NODE_PRIV_KEY
80+
wg set $IFACE listen-port $SERVER_PORT
81+
ip link set up dev $IFACE
82+
wg set $IFACE peer $SERVER_PUB_KEY endpoint $SERVER_PUB_IP:$SERVER_PORT allowed-ips $SERVER_WG_IP/32 persistent-keepalive 25
7683
if [ $? -ne 0 ]; then
77-
echo "[WIREGUARD] Failed to bring up WireGuard interface wg0. Exiting."
84+
echo "[WIREGUARD] Failed to bring up WireGuard interface $IFACE. Exiting."
7885
exit 1
7986
fi
8087
echo "[WIREGUARD] WireGuard started successfully!"

0 commit comments

Comments
 (0)