How To Install WireGuard on Fedora 45

Install WireGuard on Fedora 45

WireGuard is one of the most practical VPN technologies available on modern Linux systems. It is lightweight, fast, secure, and far easier to operate than legacy IPsec or OpenVPN deployments. On Fedora 45, the setup is particularly straightforward because WireGuard support is built into the Linux kernel; you mainly need the userspace tools, a valid configuration, and a firewall policy that matches your intended use case.

This guide walks through installing and configuring WireGuard on Fedora 45 for two common scenarios: a private peer-to-peer tunnel and a full VPN server that routes client traffic through a public Fedora host. It also covers key management, firewalld, systemd persistence, NAT, IPv6, troubleshooting, and performance tuning.

Why WireGuard on Fedora 45

Fedora 45 is a sensible platform for a WireGuard endpoint. The distribution ships a modern kernel, includes wireguard-tools in its repositories, and uses firewalld and NetworkManager by default. The official WireGuard installation instructions for Fedora specify dnf install wireguard-tools, which provides both wg and wg-quick.

WireGuard runs in the Linux kernel and uses UDP. Compared with many traditional VPN implementations, it has a smaller codebase, modern cryptographic primitives, and a configuration model that is easy to reason about: every peer has a public key, an allowed IP range, and optionally an endpoint.

That simplicity matters in production. A VPN that is difficult to audit tends to accumulate exceptions, stale rules, and undocumented workarounds. WireGuard reduces that operational surface. You can use it for:

  • Secure administrative access to servers.
  • Site-to-site connectivity between offices, cloud regions, or homelabs.
  • Remote access for developers and support staff.
  • Routing selected traffic through a trusted exit node.
  • Protecting internal services that should never be exposed directly to the internet.
  • Building a lightweight mesh-like topology using a central hub and multiple peers.

A common real-world example is a small company with a Fedora server in a data center and several laptops in different locations. Instead of exposing SSH, databases, monitoring dashboards, or internal APIs to the public internet, the administrator places those services behind a WireGuard tunnel. Only authenticated peers with the correct key material can reach them.

Prerequisites

Before starting, confirm the following:

  • A Fedora 45 system with root or sudo access.
  • A public IPv4 address, IPv6 address, or reachable hostname if you are building a server.
  • UDP port availability for WireGuard, commonly UDP 51820.
  • Basic familiarity with the terminal.
  • A second device or peer for testing.
  • Correct time synchronization, preferably through chronyd or systemd-timesyncd.

WireGuard itself does not require a certificate authority, but it does require careful handling of private keys. Treat a WireGuard private key with the same seriousness as an SSH private key. If it leaks, an attacker can impersonate that peer.

Check your Fedora version and kernel:

cat /etc/fedora-release
uname -r

Confirm that the WireGuard kernel module is available:

sudo modprobe wireguard
lsmod | grep wireguard

On a standard Fedora 45 installation, the module should load automatically when needed. If it is already loaded, lsmod will show it. If it is not loaded yet, that is not necessarily a problem; creating a WireGuard interface normally triggers module loading.

Install WireGuard Tools

Update the package metadata first. On a production system, avoid blindly upgrading every package during a maintenance window unless you have tested the change.

sudo dnf makecache
sudo dnf install -y wireguard-tools

Verify the installation:

wg --version
wg-quick --help | head -n 20

The wireguard-tools package provides:

  • wg: the configuration and status utility.
  • wg-quick: a helper that creates interfaces, applies addresses and routes, and manages the interface lifecycle.
  • wg-genkey, wg-pubkey, and wg-genpsk: convenience wrappers for key generation.

wg-quick reads configuration from /etc/wireguard/<interface>.conf, typically /etc/wireguard/wg0.conf. It handles address assignment, MTU, routes, and optional pre- and post-up scripts.

Understand the Topology

The most important decision is not the command syntax. It is the network design.

Peer-to-peer tunnel

Use this when two systems need to communicate securely, but neither needs to provide internet access for the other.

Example:

Fedora server: 10.10.0.1/24
Remote client: 10.10.0.2/24

Each side can reach the other through the tunnel, but internet-bound traffic continues through its normal default route.

VPN server with NAT

Use this when remote clients should use the Fedora server as their internet exit point.

Client -> WireGuard tunnel -> Fedora server -> Internet

This requires IP forwarding and a NAT rule. It is useful for remote workers, travel scenarios, and protecting traffic on untrusted Wi-Fi networks.

Site-to-site router

Use this when an entire remote network needs access to another network.

Office A subnet -> Fedora router -> WireGuard -> Office B subnet

This requires routes on both ends, IP forwarding, and careful firewall policy. Avoid broad AllowedIPs values unless you understand the routing consequences.

Generate Strong Keys

Generate keys on each peer. Do not reuse a key pair across multiple devices.

Set a restrictive umask before generating anything:

umask 077

Create the configuration directory if it does not exist:

sudo mkdir -p /etc/wireguard
sudo chmod 700 /etc/wireguard

Generate a server key pair:

cd /etc/wireguard
sudo sh -c 'umask 077; wg genkey | tee server_private.key | wg pubkey > server_public.key'

Generate a client key pair:

sudo sh -c 'umask 077; wg genkey | tee client1_private.key | wg pubkey > client1_public.key'

Generate a preshared key for the server-client pair:

sudo sh -c 'umask 077; wg genpsk > server-client1.psk'

The official WireGuard documentation recommends this key-generation pattern and notes that a preshared key is unique per peer pair.

Display the public keys when needed:

sudo cat /etc/wireguard/server_public.key
sudo cat /etc/wireguard/client1_public.key

Never paste a private key into a chat, ticket, screenshot, or configuration repository. If you must transfer configuration files, use an encrypted channel and delete temporary copies afterward.

Check permissions:

sudo ls -l /etc/wireguard

Expected permissions should look similar to this:

-rw------- root root server_private.key
-rw------- root root client1_private.key
-rw------- root root server-client1.psk
-rw-r--r-- root root server_public.key
-rw-r--r-- root root client1_public.key

Choose an Addressing Plan

WireGuard needs IP addresses for its virtual interface, but those addresses do not need to come from your physical LAN. Use a dedicated private range that does not overlap with existing networks.

Common choices include:

10.10.0.0/24
10.20.0.0/24
172.16.10.0/24
192.168.100.0/24

For this guide, use:

WireGuard subnet: 10.10.0.0/24
Fedora server:    10.10.0.1/24
Client:           10.10.0.2/24

Avoid overlapping ranges. This is one of the most common sources of confusing routing problems. If your office already uses 10.10.0.0/24, choose another range. If you plan to connect multiple sites, document the allocation before creating configurations.

A simple allocation table prevents future pain:

Peer WireGuard address Role
fedora-vpn 10.10.0.1/24 Server and optional NAT gateway
laptop-alice 10.10.0.2/32 Remote client
laptop-bob 10.10.0.3/32 Remote client
office-router 10.10.0.10/32 Site-to-site peer

Using /32 for individual clients is often cleaner than assigning each client a /24. The server interface can still hold 10.10.0.1/24, while each client receives a single address.

Create the Server Configuration

Create /etc/wireguard/wg0.conf on the Fedora server:

sudo nano /etc/wireguard/wg0.conf

Add the following configuration. Replace the placeholder values with your actual keys.

[Interface]
Address = 10.10.0.1/24
ListenPort = 51820
PrivateKey = SERVER_PRIVATE_KEY

[Peer]
PublicKey = CLIENT1_PUBLIC_KEY
PresharedKey = SERVER_CLIENT1_PRESHARED_KEY
AllowedIPs = 10.10.0.2/32

Explanation:

  • Address assigns the Fedora server an IP address on the wg0 interface.
  • ListenPort defines the UDP port WireGuard listens on.
  • PrivateKey must be the server private key.
  • PublicKey is the client public key, not the server public key.
  • AllowedIPs defines which source addresses the server accepts from that peer and which destination addresses it will route toward that peer.
  • PresharedKey adds an additional symmetric secret to the handshake.

A minimal server configuration does not need an Endpoint, because clients initiate the connection to the server. The server learns the client endpoint after a successful handshake.

Set restrictive permissions:

sudo chmod 600 /etc/wireguard/wg0.conf
sudo chown root:root /etc/wireguard/wg0.conf

Start the WireGuard Interface

Test the configuration manually before enabling it at boot:

sudo wg-quick up wg0

Check the interface:

ip addr show wg0

You should see something similar to:

wg0: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1420 qdisc noqueue state UNKNOWN group default qlen 1000
    link/none
    inet 10.10.0.1/24 scope global wg0

Inspect WireGuard status:

sudo wg

Or target a specific interface:

sudo wg show wg0

At this stage, the server may show no recent handshake because no client has connected yet. That is normal.

wg-quick up creates the interface, assigns the configured address, sets the MTU, and installs routes. wg-quick down removes it.

Configure the Fedora Firewall

Fedora uses firewalld by default. A WireGuard interface is not automatically trusted, and that is a good thing. You should explicitly decide what tunnel traffic may reach.

First, identify your active public interface:

ip route get 1.1.1.1

Example output:

1.1.1.1 via 192.168.1.1 dev enp1s0 src 192.168.1.50

Here, enp1s0 is the outbound interface. Your interface name may be ens3, eth0, wlp3s0, or something else.

Allow the WireGuard UDP port through the public zone:

sudo firewall-cmd --permanent --add-port=51820/udp
sudo firewall-cmd --reload

Confirm the rule:

sudo firewall-cmd --list-all

For a basic peer-to-peer setup, create a dedicated zone for WireGuard. This keeps tunnel policy separate from your public interface policy.

sudo firewall-cmd --permanent --new-zone=wireguard
sudo firewall-cmd --permanent --zone=wireguard --add-interface=wg0
sudo firewall-cmd --permanent --zone=wireguard --add-service=ssh
sudo firewall-cmd --reload

This allows SSH from WireGuard peers while keeping the public zone restrictive. Adjust the allowed services according to what the tunnel needs to reach.

To allow ICMP ping tests across the tunnel:

sudo firewall-cmd --permanent --zone=wireguard --add-service=icmp
sudo firewall-cmd --reload

Be deliberate here. Allowing ICMP is useful for diagnostics, but it is not required for WireGuard to function.

Configure the Client

On the client system, create /etc/wireguard/wg0.conf:

[Interface]
Address = 10.10.0.2/32
PrivateKey = CLIENT1_PRIVATE_KEY

[Peer]
PublicKey = SERVER_PUBLIC_KEY
PresharedKey = SERVER_CLIENT1_PRESHARED_KEY
Endpoint = SERVER_PUBLIC_IP_OR_HOSTNAME:51820
AllowedIPs = 10.10.0.1/32
PersistentKeepalive = 25

Explanation:

  • Address is the client address inside the tunnel.
  • PrivateKey is the client private key.
  • PublicKey is the server public key.
  • Endpoint is the public address or DNS hostname of the Fedora server.
  • AllowedIPs = 10.10.0.1/32 routes only traffic destined for the server through the tunnel.
  • PersistentKeepalive = 25 helps maintain NAT mappings when the client sits behind NAT.

The official WireGuard documentation describes persistent keepalive as useful when a peer behind NAT or a firewall needs to receive inbound packets after a period of silence. A 25-second interval is a sensible general-purpose value.

Start the tunnel on the client:

sudo wg-quick up wg0

Test connectivity:

ping -c 4 10.10.0.1

Check the handshake:

sudo wg

A successful connection should show a recent handshake and packet counters:

latest handshake: 12 seconds ago
transfer: 1.24 KiB received, 1.31 KiB sent

Enable WireGuard at Boot

Once the tunnel works, enable it through systemd:

sudo systemctl enable --now wg-quick@wg0

Check its status:

systemctl status wg-quick@wg0

To restart it after changing the configuration:

sudo wg-quick down wg0
sudo wg-quick up wg0

Or use systemd:

sudo systemctl restart wg-quick@wg0

Do not enable wg-quick@wg0 until you have tested the configuration. A broken VPN configuration that starts automatically can complicate remote access, particularly if you are working over SSH.

Route All Client Traffic Through Fedora

The previous configuration creates a split tunnel. Only traffic destined for 10.10.0.1 uses WireGuard. To send all client traffic through the Fedora server, change the client peer configuration:

[Peer]
PublicKey = SERVER_PUBLIC_KEY
PresharedKey = SERVER_CLIENT1_PRESHARED_KEY
Endpoint = SERVER_PUBLIC_IP_OR_HOSTNAME:51820
AllowedIPs = 0.0.0.0/0, ::/0
PersistentKeepalive = 25

AllowedIPs = 0.0.0.0/0, ::/0 makes WireGuard the default route for IPv4 and IPv6 traffic.

On the Fedora server, enable IP forwarding:

sudo tee /etc/sysctl.d/99-wireguard-forwarding.conf >/dev/null <<'EOF'
net.ipv4.ip_forward = 1
net.ipv6.conf.all.forwarding = 1
EOF

sudo sysctl --system

Verify:

sysctl net.ipv4.ip_forward
sysctl net.ipv6.conf.all.forwarding

Both values should return 1.

Configure NAT With firewalld

For a full-tunnel VPN, clients need NAT so their traffic can leave through the Fedora server’s public interface.

Identify the public interface again:

ip route get 1.1.1.1

Assume it is enp1s0. Enable masquerading on the public zone:

sudo firewall-cmd --permanent --zone=public --add-masquerade
sudo firewall-cmd --reload

Confirm:

sudo firewall-cmd --zone=public --query-masquerade

The command should return:

yes

If you use a dedicated external zone instead of public, apply masquerading there instead. Do not enable masquerading on the wireguard zone; it belongs on the interface that forwards traffic to the internet.

Add More Clients Safely

Each client needs its own key pair and its own peer block on the server. Do not share one client configuration among several devices.

Generate keys for a second client:

sudo sh -c 'umask 077; wg genkey | tee client2_private.key | wg pubkey > client2_public.key'
sudo sh -c 'umask 077; wg genpsk > server-client2.psk'

Append a peer block to the server configuration:

[Peer]
PublicKey = CLIENT2_PUBLIC_KEY
PresharedKey = SERVER_CLIENT2_PRESHARED_KEY
AllowedIPs = 10.10.0.3/32

Reload WireGuard:

sudo systemctl reload wg-quick@wg0

If reload does not apply the peer, restart the interface during a controlled maintenance window:

sudo systemctl restart wg-quick@wg0

For a small deployment, manually managing peer blocks is fine. Once you have more than a handful of peers, use a configuration management tool such as Ansible, or maintain a source-controlled template with secrets stored in a vault. Avoid putting private keys in Git, even in a private repository.

IPv6 Considerations

If your server has public IPv6 connectivity, supporting IPv6 through WireGuard is worthwhile. Many mobile and residential networks still behave unpredictably with IPv4-only tunnels.

Assign both IPv4 and IPv6 addresses to the server interface:

[Interface]
Address = 10.10.0.1/24, fd00:10:10::1/64
ListenPort = 51820
PrivateKey = SERVER_PRIVATE_KEY

For a client:

[Interface]
Address = 10.10.0.2/32, fd00:10:10::2/64
PrivateKey = CLIENT1_PRIVATE_KEY

Use a unique local address such as fd00::/8 for tunnel-only addressing, or use globally routable IPv6 space if you operate a production network and have proper allocations.

For a full IPv6 tunnel, set:

AllowedIPs = 0.0.0.0/0, ::/0

on the client and ensure IPv6 forwarding and NAT or appropriate routing are configured on the server.

Troubleshooting WireGuard on Fedora 45

Most WireGuard problems fall into a small set of categories: keys, endpoints, routing, firewall policy, MTU, or DNS.

No handshake

Run:

sudo wg

If latest handshake never appears, start with the basics.

Check that the server port is reachable:

sudo ss -lunp | grep 51820

From an external system, test UDP connectivity. nc can help, though UDP testing is not always conclusive:

nc -vzu SERVER_PUBLIC_IP 51820

Check firewall rules:

sudo firewall-cmd --list-all
sudo nft list ruleset | grep -i 51820

Confirm that the client has the correct server public key and endpoint. A common mistake is placing the server public key in the server configuration instead of the client configuration.

Handshake succeeds but no traffic flows

A handshake proves cryptographic connectivity. It does not prove that routing or firewall policy is correct.

Check addresses:

ip addr show wg0
ip route show table all | grep wg0

Check that the server accepts traffic from the client:

sudo tcpdump -ni wg0

If packets arrive but do not leave the server, inspect forwarding:

sudo sysctl net.ipv4.ip_forward
sudo nft list ruleset | grep -i forward

For full-tunnel use, confirm masquerading:

sudo firewall-cmd --zone=public --query-masquerade

Client cannot resolve DNS

A full tunnel can break DNS if the client still uses a local resolver that is unreachable through the tunnel.

Add DNS servers to the client interface:

[Interface]
Address = 10.10.0.2/32
PrivateKey = CLIENT1_PRIVATE_KEY
DNS = 1.1.1.1, 1.0.0.1

For a private network, use an internal resolver only if it is reachable through the tunnel:

DNS = 10.10.0.53

Test resolution:

resolvectl status
dig example.com

Connection works briefly, then stops

This often occurs behind NAT. Enable persistent keepalive on the client:

PersistentKeepalive = 25

Also check for ISP-level UDP timeouts, aggressive stateful firewalls, or overlapping AllowedIPs between peers.

MTU problems

Symptoms include:

  • Small pings work, but large transfers stall.
  • Websites load partially.
  • SSH connects but hangs during authentication.
  • TLS handshakes fail intermittently.

WireGuard commonly uses an MTU of 1420 because of UDP and encryption overhead. wg-quick sets this automatically, but some networks require a lower value.

Try:

[Interface]
MTU = 1380

Then restart the interface:

sudo systemctl restart wg-quick@wg0

Test path MTU:

ping -M do -s 1372 -c 4 10.10.0.1

Reduce the payload size until you find a stable value. Do not set an excessively low MTU unless testing proves it necessary; it wastes capacity and can reduce throughput.

Interface exists but has no IP address

Check the configuration file:

sudo wg showconf wg0
sudo journalctl -u wg-quick@wg0 -b --no-pager

Common causes include an invalid Address line, duplicate address assignment, or a configuration file with incorrect permissions.

Service fails at boot

Inspect logs:

sudo journalctl -u wg-quick@wg0 -b --no-pager

Look for messages about missing keys, invalid syntax, unavailable interfaces, or routing conflicts.

A frequent issue is enabling the service before the network interface is ready. wg-quick@wg0 generally works well with systemd’s network dependencies, but complex server environments may need a custom systemd drop-in or a delayed start. Prefer fixing the underlying dependency rather than adding arbitrary sleep timers.

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.

Related Posts