File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -53,9 +53,10 @@ if [ -z "$NODE_PRIV_KEY" ] || [ -z "$NODE_WG_IP" ] || [ -z "$SERVER_PUB_KEY" ] |
5353 exit 1
5454fi
5555
56- # Write wg0.conf
56+ # Write config to file
5757mkdir -p /wireguard/config
58- WG_CONFIG=" /wireguard/config/wg0.conf"
58+ IFACE=wg0
59+ WG_CONFIG=" /wireguard/config/$IFACE .conf"
5960echo " [WIREGUARD] Writing WireGuard config to $WG_CONFIG ..."
6061cat << EOF > $WG_CONFIG
6162[Interface]
@@ -72,9 +73,15 @@ chmod 600 $WG_CONFIG
7273
7374# Start WireGuard
7475echo " [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
7683if [ $? -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
7986fi
8087echo " [WIREGUARD] WireGuard started successfully!"
You can’t perform that action at this time.
0 commit comments