Skip to content

Instantly share code, notes, and snippets.

@artizirk
Last active October 27, 2024 07:36
Show Gist options
  • Save artizirk/5bc87e345f850a8a0724929e0436ef84 to your computer and use it in GitHub Desktop.
Save artizirk/5bc87e345f850a8a0724929e0436ef84 to your computer and use it in GitHub Desktop.
Debug WireGuard Linux kernel module

This uses Linux kernel dyamic debug features

https://www.kernel.org/doc/html/latest/admin-guide/dynamic-debug-howto.html

This asumes that debugfs is mounted under /sys/kernel/debug

Enable WireGuard debug

echo 'module wireguard +p' | sudo tee /sys/kernel/debug/dynamic_debug/control

Disable WireGuard debug

echo 'module wireguard -p' | sudo tee /sys/kernel/debug/dynamic_debug/control

View Logs

dmesg

or

sudo journalctl -f

Example output

[431032.581466] wireguard: wg0: Sending keepalive packet to peer 1 (10.0.0.1:51820)
[431032.581524] wireguard: wg0: Sending handshake initiation to peer 1 (10.0.0.1:51820)
[431032.584389] wireguard: wg0: Receiving handshake response from peer 1 (10.0.0.1:51820)
[431032.584396] wireguard: wg0: Keypair 3435 destroyed for peer 1
[431032.584398] wireguard: wg0: Keypair 3437 created for peer 1
[431032.584402] wireguard: wg0: Sending keepalive packet to peer 1 (10.0.0.1:51820)
[431057.669188] wireguard: wg0: Sending keepalive packet to peer 1 (10.0.0.1:51820)
[431082.756942] wireguard: wg0: Sending keepalive packet to peer 1 (10.0.0.1:51820)

See also

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment