How to Fix Issue with Raspberry Pi that Can't Get Out to the Internet After Recent Changes Related to Wireguard/VPN

Abstract: Resolve Raspberry Pi internet loss after WireGuard setup by removing the default route 0.0.0.0/0 from AllowedIPs to prevent full tunneling conflicts.

Created: 2026-10-05 by
The Raspberry Pi loses internet connectivity after configuring WireGuard because the VPN client often installs a default route that directs all traffic through the tunnel interface. If the tunnel drops or misconfigures, this primary route prevents the device from reaching public IP addresses. You can resolve this by adjusting the routing table to ensure only specific traffic uses the VPN while general internet access remains via your standard gateway.

Understanding the Routing Conflict

When you start a WireGuard service, it typically adds a rule to the kernel’s routing table. By default, many configurations set AllowedIPs = 0.0.0.0/0, which tells the operating system to send every single packet destined for the internet through the virtual network interface, usually named wg0. This is known as "split tunneling" in reverse, or full tunneling. While useful for privacy, it creates a critical dependency: if the WireGuard connection fails, or if the local network interface changes its default gateway, the Pi no longer knows how to reach the outside world because it is still trying to send packets into the void of the disconnected tunnel. This issue is particularly common on Raspberry Pi OS, which relies on NetworkManager or systemd-networkd depending on the version. Unlike traditional desktop Linux setups, embedded systems often have less robust fallback mechanisms for dynamic interfaces. When the VPN link goes down, the static route pointing to the VPN peer persists until the service stops, leaving the system with a broken path to the internet. To fix this, we must either remove the default route or configure the system to use multiple routes intelligently.

Step 1: Verify Current Routing State

Before making changes, you need to see exactly what the kernel is doing with your network packets. Open a terminal on your Raspberry Pi and run the following command to display the current IPv4 routing table:
ip route show
You will likely see an output similar to this:
default via 192.168.1.1 dev eth0 proto dhcp
10.0.0.0/24 dev wg0 proto kernel scope link src 10.0.0.5
default via 10.0.0.1 dev wg0 proto static metric 202
Notice the two lines starting with default. The first one points to your local router (e.g., 192.168.1.1) via your Ethernet or Wi-Fi interface (eth0 or wlan0). The second line points to the WireGuard gateway (10.0.0.1) via the wg0 interface. In Linux, when there are multiple default routes, the system uses the one with the lowest metric (priority). If the WireGuard route has a lower or equal metric, it takes precedence. If the tunnel is down, packets sent to this route are dropped, causing the "no internet" symptom. For more detailed diagnostics on why a specific host might be unreachable during such failures, refer to Troubleshooting Linux Device Not Reachable During Network (Ping).

Step 2: Fix the WireGuard Configuration

The most effective long-term solution is to prevent WireGuard from taking over the entire internet route unless absolutely necessary. Edit your WireGuard configuration file, which is typically located at /etc/wireguard/wg0.conf. Look for the [Peer] section where your remote server is defined. Find the line that starts with AllowedIPs. If it currently says:
AllowedIPs = 0.0.0.0/0
Change it to specify only the private networks you actually want to access through the VPN. For example, if you only want to access a home LAN behind the VPN, you might use:
AllowedIPs = 192.168.100.0/24
By removing 0.0.0.0/0, WireGuard will no longer install a default route for all internet traffic. Instead, it will only route traffic destined for specific subnets through the tunnel. All other traffic will continue to flow through your normal ISP connection via the original default gateway. After editing the file, restart the service using:
sudo systemctl restart wg-quick@wg0
If you are experiencing issues with internal communication between clients behind the same VPN, check Troubleshooting WireGuard Client-to-Client Communication Issues to ensure your peer settings allow proper forwarding.

Step 3: Use Policy Routing for Advanced Control

If you require full tunneling but want to avoid losing internet access when the VPN disconnects, you should implement policy-based routing. This technique allows you to keep the default route intact for general use while directing specific applications or traffic types through the VPN. However, for most users simply wanting their Pi back online, the split-tunnel approach in Step 2 is sufficient. Another common point of failure is DNS resolution. Even if routing works, incorrect DNS settings can make it seem like there is no internet. Ensure your /etc/resolv.conf is managed correctly by your network manager rather than being manually overwritten. On modern Raspberry Pi OS, /etc/resolv.conf is often a symlink to a file managed by systemd-resolved or dhcpcd. Manually editing it can lead to conflicts where changes are wiped out on reboot or network restart. To verify your DNS is working, try pinging a public DNS server directly:
ping 8.8.8.8
If this succeeds but ping google.com fails, your routing is fine, but your DNS is broken. In this case, check your DHCP settings or ensure your WireGuard config includes valid DNS servers in the DNS = 1.1.1.1, 8.8.8.8 line within the [Interface] section. For broader guidance on diagnosing connection failures, see Troubleshooting: Cannot Connect to the Internet.

Step 4: Restore Connectivity Temporarily

If you are currently locked out and cannot edit files remotely, you may need to access the Pi locally via HDMI and keyboard. Once logged in, you can temporarily flush the problematic route to restore internet access without rebooting. Run:
sudo ip route del default dev wg0
This removes the default route associated with the WireGuard interface. Your Pi should immediately regain internet access via its primary interface. Note that this change is not persistent across reboots; you must still correct the configuration file as described in Step 2 to prevent recurrence.

Frequently Asked Questions

Why does my Pi lose internet even though Wi-Fi is connected?

The Wi-Fi connection itself is active, but the operating system is sending data packets to the wrong destination. A misconfigured default route forces traffic into the VPN tunnel instead of your local router. Since the tunnel is broken, the packets disappear, resulting in no internet despite a healthy physical link.

Is it safe to expose ports on my Raspberry Pi for testing?

Exposing ports directly to the internet carries significant security risks if not properly secured. Always ensure you understand the implications of opening firewalls and services. For context on port exposure safety, review Is it safe to expose a port opened from netcat?.

Can I use iptables to fix the routing issue?

While iptables can manipulate packet flow, it is generally more complex and error-prone than adjusting the routing table or WireGuard config. For simple routing fixes, modifying AllowedIPs or using ip route commands is safer and easier to maintain than writing custom firewall rules.

What happens if I delete the default route manually?

Deleting the default route temporarily restores connectivity by forcing the system to fall back to other available default gateways, such as your local Wi-Fi or Ethernet router. However, this is a temporary workaround. You must update the persistent configuration to prevent the issue from returning after a reboot.

How do I know if my DNS is failing versus routing?

Test connectivity by pinging an IP address like 8.8.8.8. If the ping succeeds, your routing is correct and the issue is likely DNS-related. If the ping fails, your routing table is blocking traffic, indicating a problem with your default gateway or VPN configuration.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More