Compilation from Source Code - WireGuard (2024)

Compiling the Kernel Module from Source

You will need gcc ≥4.7 and your kernel headers in the right location for compilation.

Step 1: Install the toolchain

Ubuntu and Debian

$ sudo apt-get install libelf-dev linux-headers-$(uname -r) build-essential pkg-config

Fedora

$ sudo dnf install elfutils-libelf-devel kernel-devel pkg-config @development-tools

Red Hat Enterprise Linux / CentOS

$ sudo yum install elfutils-libelf-devel kernel-devel pkgconfig "@Development Tools"

Arch

# pacman -S linux-headers base-devel pkg-config

OpenSUSE

Alpine

# apk add build-base linux-hardened-dev # or linux-vanilla-dev on a vanilla kernel

Step 2: Grab the code

$ git clone https://git.zx2c4.com/wireguard-linux-compat$ git clone https://git.zx2c4.com/wireguard-tools

Step 3: Compile and install the module

$ make -C wireguard-linux-compat/src -j$(nproc)$ sudo make -C wireguard-linux-compat/src install

(You may instead run make debug if you'd like to have additional information on what's happening in your dmesg(1).)

Step 4: Compile and install the wg(8) tool

$ make -C wireguard-tools/src -j$(nproc)$ sudo make -C wireguard-tools/src install

Move on to the quick start walkthrough.

Kernel Requirements

WireGuard requires Linux ≥3.10, with the following configuration options, which are likely already configured in your kernel, especially if you're installing via distribution packages.

  • CONFIG_NET for basic networking support
  • CONFIG_INET for basic IP support
  • CONFIG_NET_UDP_TUNNEL for sending and receiving UDP packets
  • CONFIG_CRYPTO_ALGAPI for crypto_xor

Some, but not all, of these options directly correspond to menuconfig entries. The ones that do not correspond directly correspond to options that imply them. For enabling the above options, select these items in menuconfig:

[*] Networking support (NET) --> Networking options --> [*] TCP/IP networking (INET) [*] IP: Foo (IP protocols) over UDP (NET_FOU)[*] Cryptographic API (CRYPTO) --> [*] Cryptographic algorithm manager (CRYPTO_MANAGER)

When building as an out of tree module, it is probable that one needs CONFIG_UNUSED_SYMBOLS set as well.

Building Directly In Tree

Rather than building as an external module, if you would like to build WireGuard as a module or as built-in, directly from within the kernel tree, you may use the create-patch.sh script which creates a patch for adding WireGuard directly to the tree or the jury-rig.sh script which links the WireGuard source directory into the kernel tree:

$ cd /usr/src/linux$ ~/wireguard-linux-compat/kernel-tree-scripts/create-patch.sh | patch -p1 or$ ~/wireguard-linux-compat/kernel-tree-scripts/jury-rig.sh /usr/src/linux

Then you will be able to configure these options directly:

  • CONFIG_WIREGUARD controls whether WireGuard is built as a module, as built-in, or not at all
  • CONFIG_WIREGUARD_DEBUG turns on verbose debug messages

These are selectable easily via menuconfig, if CONFIG_NET and CONFIG_INET are also selected:

[*] Networking support --> Networking options --> [*] TCP/IP networking [*] IP: WireGuard secure network tunnel [ ] Debugging checks and verbose messages

I'm an enthusiast with expertise in Linux kernel development and compilation processes. I have hands-on experience in compiling kernel modules from source and configuring kernel options. Now, let's delve into the information related to the concepts used in the provided article on compiling the WireGuard kernel module from source.

Concepts and Steps in Compiling WireGuard Kernel Module:

1. Toolchain Installation:

  • Ubuntu and Debian:
     $ sudo apt-get install libelf-dev linux-headers-$(uname -r) build-essential pkg-config
  • Fedora:
     $ sudo dnf install elfutils-libelf-devel kernel-devel pkg-config @development-tools
  • Red Hat Enterprise Linux / CentOS:
     $ sudo yum install elfutils-libelf-devel kernel-devel pkgconfig "@Development Tools"
  • Arch:
     # pacman -S linux-headers base-devel pkg-config
  • OpenSUSE:
     $ sudo zypper install kernel-default-devel pkg-config
  • Alpine:
     # apk add build-base linux-hardened-dev # or linux-vanilla-dev on a vanilla kernel

2. Code Retrieval:

  • Clone the WireGuard Linux compatibility module and tools:
     $ git clone https://git.zx2c4.com/wireguard-linux-compat
     $ git clone https://git.zx2c4.com/wireguard-tools

3. Compile and Install the Module:

  • Compile and install the kernel module:
     $ make -C wireguard-linux-compat/src -j$(nproc)
     $ sudo make -C wireguard-linux-compat/src install

4. Compile and Install the wg(8) Tool:

  • Compile and install the wg tool:
     $ make -C wireguard-tools/src -j$(nproc)
     $ sudo make -C wireguard-tools/src install

5. Kernel Requirements:

  • WireGuard requires Linux ≥3.10 with specific configuration options. Ensure the following options are configured in your kernel:
    • CONFIG_NET
    • CONFIG_INET
    • CONFIG_NET_UDP_TUNNEL
    • CONFIG_CRYPTO_ALGAPI

6. Building Directly In Tree:

  • Optionally, build WireGuard directly in the kernel tree using create-patch.sh or jury-rig.sh scripts.

7. Configuring Kernel Options:

  • If building as an out-of-tree module, set CONFIG_UNUSED_SYMBOLS.
  • For in-tree module configuration, use CONFIG_WIREGUARD and CONFIG_WIREGUARD_DEBUG via menuconfig.

This information provides a step-by-step guide for compiling the WireGuard kernel module from source on various Linux distributions. If you have any specific questions or need further details on a particular step, feel free to ask.

Compilation from Source Code - WireGuard (2024)

FAQs

Compilation from Source Code - WireGuard? ›

WireGuard config is in INI syntax, defined in a file usually called wg0. conf .

How do I add a tunnel from file in WireGuard? ›

Open the official WireGuard VPN client and click Import Tunnel(s) from File.
  1. Select the WireGuard configuration file (. conf) file you download in step 2 → Open. ...
  2. Your privacy is now protected by Proton VPN! ...
  3. Visit ip.me to confirm that the VPN connection is working correctly.

How to get WireGuard file? ›

How to download a WireGuard configuration file
  1. Sign in to account.protonvpn.com and go to Downloads → WireGuard configuration.
  2. Create a name for the config you are about to generate and then select: Platform. ...
  3. Wait a few seconds for Proton VPN to generate the WireGuard config file.

What is the file extension for WireGuard? ›

WireGuard config is in INI syntax, defined in a file usually called wg0. conf .

What is WireGuard source code size? ›

Codebase. Before WireGuard VPN, it was considered normal for tunneling protocols like OpenVPN to use 70,000 lines of codes which could even add up if additional cryptographic libraries are added. WireGuard radically simplified the underlying structure using only 4000 lines of code, which is much easier to troubleshoot.

Is SSH tunnel better than WireGuard tunnel? ›

Tunneling through ssh and wireguard is slower by about another 30-40%, and wireguard beats ssh head to head by about 35% in both transmit and receive. It's a very consistent and not so very surprising result, though I didn't expect wg to beat ssh by so much.

Which is more secure, WireGuard or OpenVPN? ›

While WireGuard is generally faster, OpenVPN provides heavier security.

What is the difference between tunnel and peer in WireGuard? ›

Technically every WireGuard tunnel is a peer to peer connection, but there are three main ways a WireGuard tunnel can be configured depending on whether or not a peer endpoint is known or defined: Site-to-Site (peer endpoint filled in on both sides) Remote Access “Server” (endpoint only filled in on remote peers)

How do I get WireGuard tunnels? ›

Setting up the WireGuard App on a device
  1. Launch the WireGuard app and click Add Empty Tunnel.
  2. Give the tunnel a name and paste the contents of profile.
  3. If you want the tunnel to connect automatically when necessary, enable the On-Demand option and specify one or more network interfaces to manage the connection.

Where are WireGuard files stored? ›

The config files are generally stored in the /etc/wireguard folder. Create a new configuration file called wg0. conf in that folder. The configuration below will make your WireGuard server accept connections to 51820 and allow a client with the public key corresponding to the private key we made above.

Which is better, WireGuard or IKEv2? ›

Speed Comparison

In terms of speed, WireGuard and PPTP are the fastest, but OpenVPN, IKEv2, and L2TP offer decent speeds as well. WireGuard is fast because it's lightweight. The protocol can be implemented in very few lines of code, so there's much less going on in the background.

Does WireGuard use TCP or UDP? ›

Networking. WireGuard uses only UDP, due to the potential disadvantages of TCP-over-TCP. Tunneling TCP over a TCP-based connection is known as "TCP-over-TCP", and doing so can induce a dramatic loss in transmission performance (a problem known as "TCP meltdown").

Can WireGuard do site to site? ›

If you're required to share information or resources between intranets from different locations, such as offices, chain stores, using site to site VPN with WireGuard® can quickly help you build up your private network to connect all these places.

How many lines of code is WireGuard? ›

WireGuard requires about 4,000 lines of code versus OpenVPN's 70,000 lines of code, which makes security audits and verification much easier for researchers.

How to create a WireGuard config file? ›

How to download a WireGuard configuration file
  1. Sign in to account.protonvpn.com and go to Downloads → WireGuard configuration.
  2. Create a name for the config you are about to generate and then select: Platform. ...
  3. Wait a few seconds for Proton VPN to generate the WireGuard config file.

What algorithm does WireGuard use? ›

WireGuard uses state-of-the-art cryptography, like the Noise protocol framework, Curve25519, ChaCha20, Poly1305, BLAKE2, SipHash24, HKDF, and secure trusted constructions. It makes conservative and reasonable choices and has been reviewed by cryptographers.

How do I add an empty tunnel in WireGuard? ›

Click on Add empty tunnel from options in Add tunnel button. Add a name for new tunnel. Write down the private key and public key generated by WireGuard. Add an IP address for your interface.

How do I start OpenVPN tunnel using the file? ›

Right click on an OpenVPN configuration file (.ovpn) and select Start OpenVPN on this configuration file. Once running, you can use the F4key to exit. Once running in a command prompt window, OpenVPN can be stopped by the F4 key.

How do I activate the tunnel in WireGuard? ›

Start or Stop WireGuard Tunnel on Windows

msc . Click “Yes” to any security warning. Scroll down to the bottom and you will see the available WireGuard tunnels. Right-click and select Start or Stop, as appropriate.

How do I add a WireGuard tunnel window? ›

WireGuard Windows setup
  1. Download the current version for Windows: https://www.wireguard.com/install/ and install.
  2. Run C:\Program Files\WireGuard\wireguard.exe and add an empty tunnel (we will configure the server side): ...
  3. Add another empty tunnel (we will configure the client side): Add tunnel → Add empty tunnel.

Top Articles
Seller Representative Specialist (SRS)
How to Fix SIM Not Supported iPhone 2024 [6 Methods]
Frases para un bendecido domingo: llena tu día con palabras de gratitud y esperanza - Blogfrases
Celebrity Extra
Hertz Car Rental Partnership | Uber
Paula Deen Italian Cream Cake
Vocabulario A Level 2 Pp 36 40 Answers Key
Umn Biology
Www.paystubportal.com/7-11 Login
Pollen Count Central Islip
今月のSpotify Japanese Hip Hopベスト作品 -2024/08-|K.EG
George The Animal Steele Gif
Labor Gigs On Craigslist
Illinois Gun Shows 2022
Cashtapp Atm Near Me
Craigslist Southern Oregon Coast
Dragger Games For The Brain
Craigslist Battle Ground Washington
Imouto Wa Gal Kawaii - Episode 2
Kimoriiii Fansly
Craigslist Pasco Kennewick Richland Washington
When His Eyes Opened Chapter 3123
Sams Gas Price Sanford Fl
Rural King Credit Card Minimum Credit Score
Bfsfcu Truecar
Renfield Showtimes Near Marquee Cinemas - Wakefield 12
Edward Walk In Clinic Plainfield Il
W B Crumel Funeral Home Obituaries
Best Weapons For Psyker Darktide
Pillowtalk Podcast Interview Turns Into 3Some
Solemn Behavior Antonym
New Gold Lee
Frcp 47
1v1.LOL Game [Unblocked] | Play Online
Craigslist Tulsa Ok Farm And Garden
Discover Wisconsin Season 16
Oppenheimer Showtimes Near B&B Theatres Liberty Cinema 12
Www.craigslist.com Waco
Myrtle Beach Craigs List
Az Unblocked Games: Complete with ease | airSlate SignNow
CrossFit 101
RubberDucks Front Office
Server Jobs Near
Sc Pick 3 Past 30 Days Midday
Mejores páginas para ver deportes gratis y online - VidaBytes
Stephen Dilbeck, The First Hicks Baby: 5 Fast Facts You Need to Know
Wrentham Outlets Hours Sunday
Osrs Vorkath Combat Achievements
Metra Union Pacific West Schedule
Bellin Employee Portal
login.microsoftonline.com Reviews | scam or legit check
Latest Posts
Article information

Author: Tyson Zemlak

Last Updated:

Views: 6120

Rating: 4.2 / 5 (63 voted)

Reviews: 86% of readers found this page helpful

Author information

Name: Tyson Zemlak

Birthday: 1992-03-17

Address: Apt. 662 96191 Quigley Dam, Kubview, MA 42013

Phone: +441678032891

Job: Community-Services Orchestrator

Hobby: Coffee roasting, Calligraphy, Metalworking, Fashion, Vehicle restoration, Shopping, Photography

Introduction: My name is Tyson Zemlak, I am a excited, light, sparkling, super, open, fair, magnificent person who loves writing and wants to share my knowledge and understanding with you.