WireGuard server on ns0.mcwai.net with laptop client
user: next on our new primary nameserver ns0.mcwai.net we will install wireguard server and configure wireguard client on my laptop which already has the client installed. Just needs to be reconfigured.
we will use 10.3.3.0/24 /32 ip address scheme with its ipv6 counterpart
our MTU for the VPN shall be set at 1272
assistant: Got it Captain ⚓️ — fresh WireGuard server on **ns0.mcwai.net** as primary, with your laptop reconfigured as the client.
We’ll use **10.3.3.0/24 (IPv4)** and the **/32 assignment per peer** with its IPv6 counterpart, and set **MTU=1272** across the tunnel.
Here’s a clean rollout plan:
---
## 1. Server-side (ns0.mcwai.net)
```bash
sudo apt update
sudo apt install -y wireguard
```
Generate keypair:
```bash
wg genkey | tee ~/wg0-server.key | wg pubkey > ~/wg0-server.pub
```
Lock down permissions:
```bash
chmod 600 ~/wg0-server.key
```
Create interface config:
```bash
sudo nano /etc/wireguard/wg0.conf
```
Content:
```ini
[Interface]
Address = 10.3.3.1/24, fd10:3:3::1/64
ListenPort = 51820
PrivateKey = <server_private_key>
MTU = 1272
# Client peer (laptop)
[Peer]
PublicKey = <client_public_key>
AllowedIPs = 10.3.3.2/32, fd10:3:3::2/128
```
Enable IP forwarding:
```bash
echo "net.ipv4.ip_forward=1" | sudo tee -a /etc/sysctl.conf
echo "net.ipv6.conf.all.forwarding=1" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
```
Start and enable:
```bash
sudo systemctl enable wg-quick@wg0 --now
```
---
## 2. Client-side (Laptop)
Generate keypair (if redoing):
```bash
wg genkey | tee ~/wg0-client.key | wg pubkey > ~/wg0-client.pub
chmod 600 ~/wg0-client.key
```
Config file:
```bash
sudo nano /etc/wireguard/wg0.conf
```
Content:
```ini
[Interface]
Address = 10.3.3.2/32, fd10:3:3::2/128
PrivateKey = <client_private_key>
MTU = 1272
[Peer]
PublicKey = <server_public_key>
Endpoint = ns0.mcwai.net:51820
AllowedIPs = 10.3.3.0/24, fd10:3:3::/64
PersistentKeepalive = 25
```
Bring it up:
```bash
sudo systemctl enable wg-quick@wg0 --now
```
---
## 3. Firewall (if UFW enabled on ns0)
```bash
sudo ufw allow 51820/udp
```
---
## 4. Verification
On ns0:
```bash
sudo wg show
```
On laptop:
```bash
ping -c3 10.3.3.1
ping6 -c3 fd10:3:3::1
```
---
✅ At this point you’ll have a working WireGuard tunnel with MTU fixed at 1272, server at `10.3.3.1`/`fd10:3:3::1`, an…
user: server first and then handle my laptop config manually. just go step by step
assistant: Roger that, Captain. We’ll do the **server first** on `ns0.mcwai.net`, then handle your laptop manually. Below is a single, safe script that:
- Installs WireGuard on Debian,
- Generates & stores server keys securely,
- Creates `/etc/wireguard/wg0.conf` with **10.3.3.1/24** and **fd10:3:3::1/64**, **MTU=1272**,
- Enables IPv4/IPv6 forwarding (persistent),
- Starts and enables `wg-quick@wg0`,
- Prints the **server public key** and status so you can use it when we do your laptop next.
It does **not** set up NAT or full-tunnel routing (as requested). It only brings up the private /32 peer model on **10.3.3.0/24** (+ ULA v6).
Run this **as your `adam` user**; the script uses `sudo` where required and keeps artifacts under `/home/adam/` (your preference).
---
### 0) Create–Make Executable–Run (your preferred one‑liner)
```bash
nano ~/wg-server-ns0.sh && chmod +x ~/wg-server-ns0.sh && ~/wg-server-ns0.sh
```
### Script content to paste into the editor
```bash
#!/usr/bin/env bash
set -euo pipefail
# 🔧 WireGuard server bootstrap for ns0.mcwai.net (Debian)
# - IPv4: 10.3.3.1/24 (per-peer /32 model)
# - IPv6: fd10:3:3::1/64
# - MTU: 1272
# - Port: 51820/udp
# - No NAT, no default-route push; pure private subnet connectivity
WG_IF="wg0"
WG_PORT="51820"
WG_MTU="1272"
WG_V4_ADDR="10.3.3.1/24"
WG_V6_ADDR="fd10:3:3::1/64"
KEY_DIR="/etc/wireguard/keys"
CONF="/etc/wireguard/${WG_IF}.conf"
SYSCTL_D="/etc/sysctl.d/99-wireguard-forwarding.conf"
say() { printf "%b\n" "$*"; }
say "🚀 Starting WireGuard server setup on ns0.mcwai.net"
say "📦 Installing packages…"
sudo apt-get update -y
sudo apt-get install -y wireguard wireguard-tools
say "🗝️ Preparing key directory: ${KEY_DIR}"
sudo install -d -m 0700 /etc/wireguard
sudo install -d -m 0700 "${KEY_DIR}"
if [[ ! -f "${KEY_DIR}/server_private.key" || ! -f "${KEY_DIR}/server_public.key" ]]; then
say "🔐 Generating server keypair…"
umask 077
sudo bash -c "wg genkey > '${KEY_DIR}/server_private.key'"
sudo bash -c "wg p…
user: its all green. next
assistant: Perfect, Captain ⚓️ — `ns0` is green, now let’s do the **laptop peer** setup step by step.
We’ll give the laptop:
- **10.3.3.2/32 (IPv4)**
- **fd10:3:3::2/128 (IPv6)**
- **MTU=1272**
---
## 1. On your laptop → generate keys
```bash
wg genkey | tee ~/wg0-client.key | wg pubkey > ~/wg0-client.pub
chmod 600 ~/wg0-client.key
```
- `wg0-client.key` → private (keep secret, stays on laptop).
- `wg0-client.pub` → public (we’ll copy to server).
---
## 2. On your laptop → create config
Edit:
```bash
sudo nano /etc/wireguard/wg0.conf
```
Content:
```ini
[Interface]
Address = 10.3.3.2/32, fd10:3:3::2/128
PrivateKey = <client_private_key>
MTU = 1272
[Peer]
PublicKey = <server_public_key>
Endpoint = ns0.mcwai.net:51820
AllowedIPs = 10.3.3.0/24, fd10:3:3::/64
PersistentKeepalive = 25
```
👉 Replace `<client_private_key>` with the contents of `~/wg0-client.key`.
👉 Replace `<server_public_key>` with the one printed at the end of the server script.
---
## 3. On server (ns0) → add laptop peer
Append this block to `/etc/wireguard/wg0.conf`:
```ini
[Peer]
PublicKey = <client_public_key>
AllowedIPs = 10.3.3.2/32, fd10:3:3::2/128
```
👉 Replace `<client_public_key>` with the contents of `wg0-client.pub` from your laptop.
Save, then reload:
```bash
sudo wg addconf wg0 <(wg-quick strip wg0)
```
(or just `sudo systemctl restart wg-quick@wg0` if you prefer a full restart).
---
## 4. On laptop → bring tunnel up
```bash
sudo systemctl enable wg-quick@wg0 --now
```
---
## 5. Test connectivity
From laptop:
```bash
ping -c3 10.3.3.1
ping6 -c3 fd10:3:3::1
```
From server:
```bash
ping -c3 10.3.3.2
ping6 -c3 fd10:3:3::2
```
Check tunnel status both sides:
```bash
sudo wg show
```
---
💡 If all tests pass, you’ll have a stable IPv4/IPv6 tunnel with MTU locked at **1272**.
Do you want me to give you a **ready-made laptop script** (similar style to the server script), or would you rather fill in the values manually and then we’ll verify together?
user: its failed, it looked like it tried. lets check the ports. you gotta open them
xenon@Latitude:~$ sudo systemctl enable wg-quick@wg0 --now
[sudo] password for xenon:
Created symlink /etc/systemd/system/multi-user.target.wants/wg-quick@wg0.service → /usr/lib/systemd/system/wg-quick@.service.
Job for wg-quick@wg0.service failed because the control process exited with error code.
See "systemctl status wg-quick@wg0.service" and "journalctl -xeu wg-quick@wg0.service" for details.
xenon@Latitude:~$ sudo wg show
adam@ns0:~$ sudo ufw status
Status: active
To Action From
-- ------ ----
53/tcp ALLOW Anywhere
53/udp ALLOW Anywhere
47122/tcp ALLOW Anywhere # SSH
80/tcp ALLOW Anywhere
443/tcp ALLOW Anywhere
53/tcp (v6) ALLOW Anywhere (v6)
53/udp (v6) ALLOW Anywhere (v6)
47122/tcp (v6) ALLOW Anywhere (v6) # SSH
80/tcp (v6) ALLOW Anywhere (v6)
443/tcp (v6) ALLOW Anywhere (v6)
adam@ns0:~$
xenon@Latitude:~$ sudo systemctl enable wg-quick@wg0 --now
[sudo] password for xenon:
Created symlink /etc/systemd/system/multi-user.target.wants/wg-quick@wg0.service → /usr/lib/systemd/system/wg-quick@.service.
Job for wg-quick@wg0.service failed because the control process exited with error code.
See "systemctl status wg-quick@wg0.service" and "journalctl -xeu wg-quick@wg0.service" for details.
xenon@Latitude:~$ sudo wg show
xenon@Latitude:~$ sudo journalctl -xeu wg-quick@wg0.service
Aug 21 03:33:38 Latitude wg-quick[125308]: [#] ip link delete dev wg0
Aug 21 03:33:38 Latitude systemd[1]: wg-quick@wg0.service: Main process exited,>
░░ Subject: Unit process exi…
assistant: Gotcha — two things in parallel:
1) **Open the WireGuard port on ns0 (UFW)**
2) **Surface the *real* error on the laptop** (your journal snippet cut off the useful part)
Follow me step‑by‑step:
---
# A) Server: open the UDP port (IPv4 + IPv6) and verify
On **ns0**:
```bash
# 1) Allow WireGuard UDP/51820
sudo ufw allow 51820/udp
# 2) Verify rule is present (v4 + v6)
sudo ufw status | sed -n '1,/$/p' | grep -E '51820|Status'
# 3) Confirm the daemon is listening on 51820/udp
sudo systemctl restart wg-quick@wg0
ss -ulnp | grep 51820 || sudo ss -ulnp | grep wg0
```
Expected:
- `ufw status` should list `51820/udp` (and the v6 variant).
- `ss -ulnp` should show a listener bound to `:51820` (program `wireguard`/`wg`).
If `ss` shows nothing, also run:
```bash
sudo wg show
sudo journalctl -xeu wg-quick@wg0.service -n 80
```
---
# B) Laptop: get the *full* failure reason (then fix)
Your previous journal shows only the tail. Let’s grab the actionable lines:
```bash
# 1) Show detailed service status with last 200 lines
sudo systemctl status wg-quick@wg0 -n 200
# 2) Show journal with context (200 lines)
sudo journalctl -xeu wg-quick@wg0.service -n 200
# 3) Try bringing it up *manually* to see immediate stderr:
sudo wg-quick down wg0 2>/dev/null || true
sudo wg-quick up wg0
```
Look for one of these common causes:
- **PrivateKey missing/placeholder**
Fix: ensure `[Interface]` has `PrivateKey = <exact contents of ~/wg0-client.key>` (single line, no quotes/spaces).
- **Address missing/invalid**
Must be **exactly**:
`Address = 10.3.3.2/32, fd10:3:3::2/128`
- **Bad MTU line**
Leave as `MTU = 1272` (works with wg-quick). If error mentions MTU, temporarily comment it to test.
- **Peer PublicKey/Endpoint typo**
`PublicKey = <server_public_key_from_ns0>` and `Endpoint = ns0.mcwai.net:51820`
- **Syntax issues**
No stray quotes/backticks; each key on its own line; no trailing commas.
- **Module/permissions** (rare)
Check `modprobe wireguard` (m…
user: xenon@Latitude:~$ # 1) Show detailed service status with last 200 lines
sudo systemctl status wg-quick@wg0 -n 200
× wg-quick@wg0.service - WireGuard via wg-quick(8) for wg0
Loaded: loaded (/usr/lib/systemd/system/wg-quick@.service; enabled; preset>
Active: failed (Result: exit-code) since Thu 2025-08-21 03:33:38 EDT; 16mi>
Docs: man:wg-quick(8)
man:wg(8)
https://www.wireguard.com/
https://www.wireguard.com/quickstart/
https://git.zx2c4.com/wireguard-tools/about/src/man/wg-quick.8
https://git.zx2c4.com/wireguard-tools/about/src/man/wg.8
Process: 125308 ExecStart=/usr/bin/wg-quick up wg0 (code=exited, status=2)
Main PID: 125308 (code=exited, status=2)
CPU: 38ms
Aug 21 03:33:37 Latitude systemd[1]: Starting wg-quick@wg0.service - WireGuard >
Aug 21 03:33:37 Latitude wg-quick[125308]: [#] ip link add wg0 type wireguard
Aug 21 03:33:37 Latitude wg-quick[125308]: [#] wg setconf wg0 /dev/fd/63
Aug 21 03:33:38 Latitude wg-quick[125308]: [#] ip -4 address add 10.3.3.2/32 de>
Aug 21 03:33:38 Latitude wg-quick[125308]: [#] ip -6 address add fd10:3:3::2/12>
Aug 21 03:33:38 Latitude wg-quick[125308]: [#] ip link set mtu 1272 up dev wg0
Aug 21 03:33:38 Latitude wg-quick[125308]: [#] ip -6 route add fd10:3:3::/64 de>
Aug 21 03:33:38 Latitude wg-quick[125347]: RTNETLINK answers: No such device
Aug 21 03:33:38 Latitude wg-quick[125308]: [#] ip link delete dev wg0
Aug 21 03:33:38 Latitude systemd[1]: wg-quick@wg0.service: Main process exited,>
Aug 21 03:33:38 Latitude systemd[1]: wg-quick@wg0.service: Failed with result '>
Aug 21 03:33:38 Latitude systemd[1]: Failed to start wg-quick@wg0.service - Wir>
xenon@Latitude:~$ # 2) Show journal with context (200 lines)
sudo journalctl -xeu wg-quick@wg0.service -n 200
Aug 21 03:33:38 Latitude wg-quick[125308]: [#] ip link delete dev wg0
Aug 21 03:33:38 Latitude systemd[1]: wg-quick@wg0.service: Main process exited,>
░░ Subject: Unit process exi…
assistant: Nice catch. Your laptop’s failure is happening right at:
```
ip -6 route add fd10:3:3::/64 dev wg0
RTNETLINK answers: No such device
```
We’ll get you online in two quick passes: first bring up **IPv4-only** (to confirm keys + handshake), then add **IPv6** cleanly.
---
# 1) ns0 is already listening ✅
You’ve opened `51820/udp` (v4+v6) and `ss` shows the listener. Good.
---
# 2) Laptop — bring up IPv4‑only first
Edit your laptop config:
```bash
sudo nano /etc/wireguard/wg0.conf
```
Make it **exactly** this for now (remove IPv6 temporarily):
```ini
[Interface]
Address = 10.3.3.2/32
PrivateKey = <contents of ~/wg0-client.key>
MTU = 1272
[Peer]
PublicKey = <server_public_key_from_ns0>
Endpoint = ns0.mcwai.net:51820
AllowedIPs = 10.3.3.0/24
PersistentKeepalive = 25
```
Bring it up cleanly:
```bash
sudo wg-quick down wg0 2>/dev/null || true
sudo wg-quick up wg0
sudo wg show
```
Quick test:
```bash
ping -c3 10.3.3.1
```
On **ns0**, you should see a recent handshake:
```bash
sudo wg show
```
If that works, keys/endpoints are good. On to IPv6.
---
# 3) Laptop — add IPv6 step-by-step
With `wg0` **up**:
```bash
# give wg0 its IPv6 address (client)
sudo ip -6 addr add fd10:3:3::2/128 dev wg0 2>/dev/null || true
# add the IPv6 route for the /64 over wg0
sudo ip -6 route add fd10:3:3::/64 dev wg0
```
If those two commands **succeed**, test:
```bash
ping6 -c3 fd10:3:3::1
```
### If the manual `ip -6 route add …` still says “No such device”
Run these two for an immediate fix and try again:
```bash
# ensure the interface exists and is up
ip -d link show wg0
# (rare) make sure IPv6 is not disabled on the box
sysctl net.ipv6.conf.all.disable_ipv6
# if it prints 1, enable it:
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=0
```
Then retry:
```bash
sudo ip -6 route add fd10:3:3::/64 dev wg0
ping6 -c3 fd10:3:3::1
```
---
# 4) Make IPv6 persistent in the config
Once the manual IPv6 test works, update `/etc/wireguard/wg0.conf` to make it permanent. Two safe o…
user: wierd, its looks like it working, but its not. im not passing though the vpn and I dont see a handshake like you said I would
xenon@Latitude:~$ sudo nano /etc/wireguard/wg0.conf
xenon@Latitude:~$ sudo wg-quick down wg0 2>/dev/null || true
sudo wg-quick up wg0
sudo wg show
[#] ip link add wg0 type wireguard
[#] wg setconf wg0 /dev/fd/63
[#] ip -4 address add 10.3.3.2/32 dev wg0
[#] ip link set mtu 1272 up dev wg0
[#] ip -4 route add 10.3.3.0/24 dev wg0
interface: wg0
public key: C6N0xiKMSCaMagm9kdZxcXWtcOJCbJ8oTPttOrzMbgA=
private key: (hidden)
listening port: 46503
peer: wpEsoYEQrTE+wxG2W26oz2GxbYKCjUhMvcGWmaMYgwY=
endpoint: [2a01:4ff:f0:6c4b::1]:51820
allowed ips: 10.3.3.0/24
transfer: 0 B received, 148 B sent
persistent keepalive: every 25 seconds
xenon@Latitude:~$ ping 10.3.3.1
PING 10.3.3.1 (10.3.3.1) 56(84) bytes of data.
^C
--- 10.3.3.1 ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 2035ms
xenon@Latitude:~$ ping -c1 1.1.1.1
PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.
64 bytes from 1.1.1.1: icmp_seq=1 ttl=53 time=247 ms
--- 1.1.1.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 247.481/247.481/247.481/0.000 ms
xenon@Latitude:~$ ping -c1 10.3.3.2
PING 10.3.3.2 (10.3.3.2) 56(84) bytes of data.
64 bytes from 10.3.3.2: icmp_seq=1 ttl=64 time=0.021 ms
--- 10.3.3.2 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.021/0.021/0.021/0.000 ms
xenon@Latitude:~$
adam@ns0:~$ sudo wg show
interface: wg0
public key: wpEsoYEQrTE+wxG2W26oz2GxbYKCjUhMvcGWmaMYgwY=
private key: (hidden)
listening port: 51820
adam@ns0:~$
assistant: You’re super close—the issue is simply that **ns0 doesn’t have your laptop added as a peer yet**, so there’s no handshake.
Let’s add the peer on the server, persist it, and test.
---
# 1) On **ns0** — add the laptop as a peer
Use the **client public key** you saw on the laptop (`C6N0xiKMSCaMagm9kdZxcXWtcOJCbJ8oTPttOrzMbgA=`) and give it the /32s we planned:
```bash
# add peer live
sudo wg set wg0 peer C6N0xiKMSCaMagm9kdZxcXWtcOJCbJ8oTPttOrzMbgA= \
allowed-ips 10.3.3.2/32,fd10:3:3::2/128
# persist to /etc/wireguard/wg0.conf (we set SaveConfig=true earlier)
sudo wg-quick save wg0
# verify server side
sudo wg show
```
You should now see a `peer: C6N0x…` block under `interface: wg0`.
---
# 2) On **laptop** — make sure config is sane and tunnel is up
For now (IPv4 proven first), your `/etc/wireguard/wg0.conf` can be:
```ini
[Interface]
Address = 10.3.3.2/32
PrivateKey = <contents of ~/wg0-client.key>
MTU = 1272
[Peer]
PublicKey = wpEsoYEQrTE+wxG2W26oz2GxbYKCjUhMvcGWmaMYgwY=
Endpoint = ns0.mcwai.net:51820
AllowedIPs = 10.3.3.0/24
PersistentKeepalive = 25
```
Then bounce it:
```bash
sudo wg-quick down wg0 2>/dev/null || true
sudo wg-quick up wg0
sudo wg show
```
You should now see a **handshake time** and RX/TX counters ticking.
---
# 3) Ping tests
**From laptop:**
```bash
ping -c3 10.3.3.1
```
**From ns0:**
```bash
ping -c3 10.3.3.2
```
If those work, the tunnel is good.
---
# 4) (Optional, next) Add IPv6 back
Once IPv4 handshakes are confirmed, enable IPv6 in both configs:
**Laptop `/etc/wireguard/wg0.conf`:**
```ini
[Interface]
Address = 10.3.3.2/32, fd10:3:3::2/128
PrivateKey = <client private>
MTU = 1272
[Peer]
PublicKey = wpEsoYEQrTE+wxG2W26oz2GxbYKCjUhMvcGWmaMYgwY=
Endpoint = ns0.mcwai.net:51820
AllowedIPs = 10.3.3.0/24, fd10:3:3::/64
PersistentKeepalive = 25
```
Bounce:
```bash
sudo wg-quick down wg0 && sudo wg-quick up wg0
```
**Test IPv6:**
```bash
ping6 -c3 fd10:3:3::1
```
---
## If you still don’t see a handshake
Run these two an…
user: ok yes, i added your peer and then bounced it
xenon@Latitude:~$ sudo wg-quick down wg0 2>/dev/null || true
sudo wg-quick up wg0
sudo wg show
[#] ip link add wg0 type wireguard
[#] wg setconf wg0 /dev/fd/63
[#] ip -4 address add 10.3.3.2/32 dev wg0
[#] ip link set mtu 1272 up dev wg0
[#] ip -4 route add 10.3.3.0/24 dev wg0
interface: wg0
public key: C6N0xiKMSCaMagm9kdZxcXWtcOJCbJ8oTPttOrzMbgA=
private key: (hidden)
listening port: 54271
peer: wpEsoYEQrTE+wxG2W26oz2GxbYKCjUhMvcGWmaMYgwY=
endpoint: [2a01:4ff:f0:6c4b::1]:51820
allowed ips: 10.3.3.0/24
transfer: 0 B received, 148 B sent
persistent keepalive: every 25 seconds
xenon@Latitude:~$ ping -c3 10.3.3.1
PING 10.3.3.1 (10.3.3.1) 56(84) bytes of data.
64 bytes from 10.3.3.1: icmp_seq=1 ttl=64 time=341 ms
64 bytes from 10.3.3.1: icmp_seq=2 ttl=64 time=88.8 ms
64 bytes from 10.3.3.1: icmp_seq=3 ttl=64 time=285 ms
--- 10.3.3.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2004ms
rtt min/avg/max/mdev = 88.794/238.271/340.868/108.116 ms
xenon@Latitude:~$ ^C
xenon@Latitude:~$ ssh -p 47122 adam@10.3.3.1
The authenticity of host '[10.3.3.1]:47122 ([10.3.3.1]:47122)' can't be established.
ED25519 key fingerprint is SHA256:+W9KfN5M04eJcqrB2rm922ouAVB68P6CpbJffiIec1s.
This host key is known by the following other names/addresses:
~/.ssh/known_hosts:51: [hashed name]
~/.ssh/known_hosts:54: [hashed name]
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '[10.3.3.1]:47122' (ED25519) to the list of known hosts.
Linux ns0 6.12.41+deb13-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.12.41-1 (2025-08-12) x86_64
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Web console: https://ns0.mcwai.net:9090/ or…
assistant: 💯 That’s it Captain — tunnel’s alive. You can ping `10.3.3.1`, even SSH through it. The missing piece was exactly what we fixed: adding your laptop’s peer to **ns0**.
Now about IPv6:
Earlier troubleshooting likely had us disable or filter IPv6 on your laptop (or even system-wide), which explains why `wg-quick` kept choking on the `fd10:3:3::/64` route. Let’s clean that up and put it back to a healthy dual-stack state.
---
## 1. Check current IPv6 sysctl state (laptop)
Run:
```bash
sysctl net.ipv6.conf.all.disable_ipv6
sysctl net.ipv6.conf.default.disable_ipv6
```
- If you see `=1`, IPv6 is globally disabled.
- If you see `=0`, it’s enabled.
---
## 2. Re-enable IPv6 (if disabled)
To flip it back on permanently:
```bash
# enable live
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=0
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=0
# persist across reboots
echo "net.ipv6.conf.all.disable_ipv6=0" | sudo tee /etc/sysctl.d/10-ipv6.conf
echo "net.ipv6.conf.default.disable_ipv6=0" | sudo tee -a /etc/sysctl.d/10-ipv6.conf
sudo sysctl --system
```
---
## 3. Restore IPv6 to your WireGuard configs
### On laptop (`/etc/wireguard/wg0.conf`)
```ini
[Interface]
Address = 10.3.3.2/32, fd10:3:3::2/128
PrivateKey = <client private key>
MTU = 1272
[Peer]
PublicKey = <server public key>
Endpoint = ns0.mcwai.net:51820
AllowedIPs = 10.3.3.0/24, fd10:3:3::/64
PersistentKeepalive = 25
```
### On ns0 (`/etc/wireguard/wg0.conf`)
```ini
[Interface]
Address = 10.3.3.1/24, fd10:3:3::1/64
PrivateKey = <server private key>
ListenPort = 51820
MTU = 1272
[Peer]
PublicKey = <client public key>
AllowedIPs = 10.3.3.2/32, fd10:3:3::2/128
```
---
## 4. Bounce the interface
Laptop:
```bash
sudo wg-quick down wg0
sudo wg-quick up wg0
```
Server:
```bash
sudo systemctl restart wg-quick@wg0
```
---
## 5. Verify IPv6 tunnel connectivity
Laptop:
```bash
ping6 -c3 fd10:3:3::1
```
Server:
```bash
ping6 -c3 fd10:3:3::2
```
And confirm with:
```bash
sudo wg show
```
You should see T…
user: i got kicked out of the vpn tunnel after i did that
xenon@Latitude:~$ sudo wg-quick down wg0
sudo wg-quick up wg0
[sudo] password for xenon:
[#] ip link delete dev wg0
[#] ip link add wg0 type wireguard
[#] wg setconf wg0 /dev/fd/63
[#] ip -4 address add 10.3.3.2/32 dev wg0
[#] ip -6 address add fd10:3:3::2/128 dev wg0
[#] ip link set mtu 1272 up dev wg0
[#] ip -6 route add fd10:3:3::/64 dev wg0
RTNETLINK answers: No such device
[#] ip link delete dev wg0
xenon@Latitude:~$ ping -c3 10.3.3.1
PING 10.3.3.1 (10.3.3.1) 56(84) bytes of data.
^C
--- 10.3.3.1 ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 2068ms
xenon@Latitude:~$ ping6 -c3 fd10:3:3::1
PING fd10:3:3::1 (fd10:3:3::1) 56 data bytes
^C
--- fd10:3:3::1 ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 2053ms
xenon@Latitude:~$ sudo wg show
xenon@Latitude:~$
assistant: Alright—your laptop dropped because `wg-quick` died when it tried to add the **IPv6 /64 route**. We’ll get you back up on IPv4 immediately, then re‑enable IPv6 in a way that won’t trip that route error.
## Step 1 — Restore IPv4 now (laptop)
Edit and **temporarily remove IPv6** from the client:
```bash
sudo nano /etc/wireguard/wg0.conf
```
Make it:
```ini
[Interface]
Address = 10.3.3.2/32
PrivateKey = <client private>
MTU = 1272
[Peer]
PublicKey = <server public> # wpEso...gwA=
Endpoint = ns0.mcwai.net:51820
AllowedIPs = 10.3.3.0/24
PersistentKeepalive = 25
```
Bring it up:
```bash
sudo wg-quick down wg0 2>/dev/null || true
sudo wg-quick up wg0
sudo wg show
ping -c3 10.3.3.1
```
You should be **back online** via the tunnel.
---
## Step 2 — Check IPv6 toggles (laptop)
We need to make sure IPv6 isn’t disabled per‑interface:
```bash
sysctl net.ipv6.conf.all.disable_ipv6
sysctl net.ipv6.conf.default.disable_ipv6
# and check the wg0 setting after wg0 is up:
sysctl net.ipv6.conf.wg0.disable_ipv6 2>/dev/null || echo "wg0 not present yet"
```
- All three should be `=0`.
- If any is `=1`, run:
```bash
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=0
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=0
```
(Per‑interface `wg0` gets created on `wg-quick up`. We’ll force‑enable it below.)
---
## Step 3 — Safer dual‑stack config (no /64 route on client)
Instead of routing the whole `/64` on the **client**, we’ll route only the **server’s /128**. This avoids the failing `ip -6 route add fd10:3:3::/64 dev wg0`.
### 3A) Laptop config (add IPv6 back safely)
```bash
sudo nano /etc/wireguard/wg0.conf
```
Replace with:
```ini
[Interface]
Address = 10.3.3.2/32, fd10:3:3::2/128
PrivateKey = <client private>
MTU = 1272
# ensure IPv6 is enabled on this interface before routes
PreUp = sysctl -w net.ipv6.conf.%i.disable_ipv6=0
[Peer]
PublicKey = <server public> # wpEso...gwA=
Endpoint = ns0.mcwai.net:51820
AllowedIPs = 10.3.3.0/24, fd10:3:3::1/128
PersistentKeepalive …
user: its not working
adam@ns0:~$ sudo wg show
adam@ns0:~$ sudo wg set wg0 peer C6N0xiKMSCaMagm9kdZxcXWtcOJCbJ8oTPttOrzMbgA= allowed-ips 10.3.3.2/32,fd10:3:3::2/128
sudo wg-quick save wg0
sudo wg show
Unable to modify interface: No such device
wg-quick: `wg0' is not a WireGuard interface
adam@ns0:~$
xenon@Latitude:~$ sysctl net.ipv6.conf.all.disable_ipv6
sysctl net.ipv6.conf.default.disable_ipv6
# and check the wg0 setting after wg0 is up:
sysctl net.ipv6.conf.wg0.disable_ipv6 2>/dev/null || echo "wg0 not present yet"
net.ipv6.conf.all.disable_ipv6 = 0
net.ipv6.conf.default.disable_ipv6 = 0
wg0 not present yet
xenon@Latitude:~$ sudo nano /etc/wireguard/wg0.conf
xenon@Latitude:~$ sudo wg-quick down wg0
sudo wg-quick up wg0
sudo wg show
[#] ip link delete dev wg0
[#] sysctl -w net.ipv6.conf.wg0.disable_ipv6=0
sysctl: cannot stat /proc/sys/net/ipv6/conf/wg0/disable_ipv6: No such file or directory
Unable to access interface: No such device
[#] ip link delete dev wg0
Cannot find device "wg0"
xenon@Latitude:~$ ping -c3 10.3.3.1
ping6 -c3 fd10:3:3::1
PING 10.3.3.1 (10.3.3.1) 56(84) bytes of data.
^C
--- 10.3.3.1 ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 2034ms
PING fd10:3:3::1 (fd10:3:3::1) 56 data bytes
--- fd10:3:3::1 ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 2058ms
xenon@Latitude:~$ sysctl net.ipv6.conf.all.disable_ipv6
assistant: Got you, Captain — the server interface **wg0 disappeared** on ns0, so your client can’t handshake. We’ll **restore wg0 on ns0** first (with your laptop’s peer baked in), then bring the laptop back up (IPv4 first, then v6 if you want).
---
# A) Restore WireGuard on **ns0** (server)
### 1) Run this one‑liner (creates a safe repair script and executes it)
```bash
nano ~/wg0-recover.sh && chmod +x ~/wg0-recover.sh && sudo ~/wg0-recover.sh
```
### Paste this into the editor, save, exit:
```bash
#!/usr/bin/env bash
set -euo pipefail
WG_IF="wg0"
WG_PORT="51820"
WG_MTU="1272"
WG_V4_ADDR="10.3.3.1/24"
WG_V6_ADDR="fd10:3:3::1/64"
KEY_DIR="/etc/wireguard/keys"
CONF="/etc/wireguard/${WG_IF}.conf"
SYSCTL_D="/etc/sysctl.d/99-wireguard-forwarding.conf"
CLIENT_PUB="C6N0xiKMSCaMagm9kdZxcXWtcOJCbJ8oTPttOrzMbgA=" # laptop
echo "🧰 Ensuring packages…"
apt-get update -y
apt-get install -y wireguard wireguard-tools >/dev/null
echo "🔐 Ensuring key material exists…"
install -d -m 0700 /etc/wireguard
install -d -m 0700 "${KEY_DIR}"
if [[ ! -f "${KEY_DIR}/server_private.key" ]]; then
umask 077
wg genkey > "${KEY_DIR}/server_private.key"
wg pubkey < "${KEY_DIR}/server_private.key" > "${KEY_DIR}/server_public.key"
chmod 600 "${KEY_DIR}/server_private.key"
fi
SERVER_PRIV=$(cat "${KEY_DIR}/server_private.key")
SERVER_PUB=$(cat "${KEY_DIR}/server_public.key")
echo "🧩 Rebuilding ${CONF}"
if [[ -f "${CONF}" ]]; then
TS=$(date +%Y%m%d-%H%M%S)
install -d -m 0755 /home/adam/backups/wireguard
cp -a "${CONF}" "/home/adam/backups/wireguard/${WG_IF}.conf.bak-${TS}"
fi
cat > "${CONF}" <<EOF
[Interface]
Address = ${WG_V4_ADDR}, ${WG_V6_ADDR}
ListenPort = ${WG_PORT}
PrivateKey = ${SERVER_PRIV}
MTU = ${WG_MTU}
SaveConfig = true
# Laptop peer
[Peer]
PublicKey = ${CLIENT_PUB}
AllowedIPs = 10.3.3.2/32, fd10:3:3::2/128
EOF
chmod 600 "${CONF}"
echo "🌐 Enabling IP forwarding…"
cat > "${SYSCTL_D}" <<'EOF'
net.ipv4.ip_forward=1
net.ipv6.conf.all.forwarding=1
EOF
sysctl --system >/dev/null…
Showing first 18 of 18 messages. View the full conversation at https://mcwai.org/ai-conversation/wireguard-server-on-ns0-mcwai-net-with-laptop