Set up your own WireGuard VPN for secure browsing on Android.

Last update: 3 April 2026
  • Setting up a WireGuard server and Android, Windows, and Linux clients allows you to create a secure private network under your control.
  • The official WireGuard app for Android imports configurations via QR code and easily manages multiple tunnels.
  • Tunnel security depends on well-managed keys, active IPv4 forwarding, and correct firewall rules on the server.
  • With the VPN active, your traffic goes out to the Internet with the server's IP address, is encrypted, and protects you against insecure networks and geographical restrictions.

WireGuard VPN for safe browsing

Browsing the internet on your Android phone using your own VPN has become almost essential if you're concerned about privacy, frequently connect to public Wi-Fi, or want to access your home or work resources from anywhere. Setting up your own VPN with WireGuard gives you complete control over the server, keys, clients, and traffic, without relying on third parties or paid services whose data usage is unclear.

If you already have a WireGuard server running on Linux (either installed traditionally or in a Docker container), the next logical step is learning how to use it from your mobile device. In this article, you'll see, step by step and in detail, how to configure a WireGuard client on Android , how to use QR codes to do it in seconds, what the most important parameters in the configuration file mean, and how to integrate it with other devices like Windows and Linux to create a complete private network.

What you need before setting up WireGuard on Android

To use WireGuard from Android, you must have previously installed a working and accessible WireGuard server from the internet. This server will typically be a Linux machine (a dedicated server, a VPS, a Raspberry Pi, or even a NAS) where you will have already created the interface. wg0, generated keys and opened the corresponding port on the router or firewall.

In many modern scenarios, containers are used, so you may already have WireGuard set up using Docker with a container called wire guard that listens in the port 51820/UDPThat container is usually configured with an environment variable of the type PEERS=2, indicating that two clients have already been created (for example, peer1 y peer2) with their configuration files and their respective QR codes ready to be used on different devices.

If you installed it with Docker, the persistent configuration is usually saved in a volume or folder like this: ~/services/wireguard/appdata/config, and in a classic Linux installation the files are usually located in /etc/wireguard or, if the server generates client-side configurations, in paths such as /etc/wireguard/configsWithin those routes, directories of the type are created peer1, peer2etc., where the key file resides: peer1.conf for the first client, peer2.conf for the second one, and so on.

In many automated deployments, in addition to the archive .conf An image is also generated PNG with QR code (for example, peer1.pngThis encodes the contents of the configuration file. This image, or its equivalent in ANSI text format from the terminal, allows the mobile client to import the configuration simply by pointing the camera, without having to manually copy the keys or IPs.

Install the WireGuard client on Android

The official WireGuard client for Android is completely free to download from the Google Play Store . On your Android device, open the app store, simply search for “WireGuard,” and make sure to select the application developed by the WireGuard Development Team , which is the official one and usually displays the same logo you see in the project documentation and many guides.

After tapping Install , the process is quick and requires no complicated configuration. Once the app is on your phone, you'll have everything you need to create, import, and manage VPN tunnels : you can activate or deactivate connections, examine traffic in real time, view statistics on bytes sent and received, and modify parameters for each tunnel if necessary.

In addition to direct installation from the store, the WireGuard Android app allows you to import configurations from .conf files stored on your device, as well as scan QR codes , which is the most convenient method if you already have the client running on the server. You'll find that, once you get used to it, creating new clients for different phones or tablets only takes a couple of minutes.

VPN works on Android
Related articles:
How to check if your VPN is working on Android in advance

Obtain client configuration from the WireGuard server

Before you start working on the Android app, you need to locate the client configuration on the server. If you're using Docker with a custom WireGuard image, this data is usually located in the directory ~/services/wireguard/appdata/config or the one you indicated as the volume in the docker-compose.ymlThere you will see subfolders like peer1 y peer2 with their corresponding files.

If your setup is conventional, the most common structure is for the main server file to be called wg0.conf and located in /etc/wireguard , while client profiles can be in /etc/wireguard/configs or another path you specify. In either case, the file you need for each client will be similar to peer1.conf , containing all the configuration for that device: address within the VPN, private key, server public key, destination IP address or domain, and routing rules.

If you configured WireGuard with a Docker image that includes specific utilities, you likely have a command to display the QR code directly in the terminal. A typical example would be running something like `docker exec -it wireguard /app/show-peer 1` from the machine where Docker is running . This command displays the QR code for client number 1 (peer1) using characters in the console, ready to be scanned by the Android app.

In other setups, instead of using a specific script, qrencode is used , a small tool that generates QR codes in text or image format. After installing it with a command like ` apt install qrencode` , simply run something like ` qrencode -t ansiutf8 < clientemovil.conf` on the server to print the QR code from the clientemovil.conf configuration file directly to the terminal, allowing you to point your phone at it and capture the data effortlessly.

Import WireGuard tunnel using QR code on Android

WireGuard VPN for safe browsing

Once you see the QR code associated with the client you want to use (whether peer1, peer2, or a custom name like mobileclient) in your SSH session, take your Android smartphone and open the WireGuard app. On the main screen, you'll see a floating button with a "+" symbol in the bottom right corner, which is used to add new tunnels.

When you tap the add button, a menu with several options will appear. On Android, one of the most convenient is "Scan from QR code" (or its equivalent in Spanish if you have the interface translated). Select this option, and the application will activate your phone's camera so you can scan the QR code you have open in the SSH terminal or in an exported PNG file.

By focusing on the QR code, the app will immediately read the complete configuration: [Interface] with the client's private key, their address in the VPN and their listening port (if any); and the [Peer] block , which contains the server's public key, the remote endpoint with its IP or domain and port (usually 51820/UDP) and the list of AllowedIPs that defines the traffic that is routed through the tunnel.

The next step is to enter a name to identify the tunnel in the app's interface: it can be something descriptive like "Home VPN," "WireGuard Office," or "VPS Server." After typing it, confirm with the creation button (for example, " Create Tunnel ") and almost instantly, you'll see your new VPN entry on the WireGuard for Android home screen, ready to connect whenever you need it.

Connect and use your WireGuard VPN from Android

 

With the tunnel added, the WireGuard app lists all available profiles with a switch on the right . To establish a connection with your VPN server, simply slide this switch to the "on" position. If everything is configured correctly (keys, IPs, open port, and traffic forwarding on the server), you will see the tunnel status as active within a few seconds.

Android also displays a VPN icon in the notification bar , usually in the upper right corner next to the signal strength, Wi-Fi, and battery indicators. This icon confirms that all traffic matching the AllowedIPs defined in the settings is being sent through the WireGuard tunnel to your remote server and, from there, out to the internet or your local network, depending on your configuration.

From this point forward, any mobile application that uses the network (browsers, email, banking apps, messaging, etc.) will see your VPN server's IP address as its outgoing IP , not the one assigned by your ISP or the public Wi-Fi network you're connected to. Furthermore, all this traffic is end-to-end encrypted between your Android device and the WireGuard server, protecting you from eavesdropping on untrusted networks and allowing you to bypass blocks or geographical restrictions as long as the server is located elsewhere.

If you ever want to stop using the VPN, simply return to the WireGuard app and turn off the tunnel switch. The connection will close, and Android will no longer display the VPN icon. It's an instant process and doesn't require restarting any apps, so you can connect and disconnect WireGuard as many times as you like throughout the day without any hassle.

How to integrate Android with other WireGuard clients (Windows and Linux)

Typically, you'll use a VPN not only with your mobile phone, but also with your desktop computer, laptop, or even a Raspberry Pi . WireGuard is available for virtually all platforms: Windows, Linux, macOS, iOS, and Android, allowing you to create a consistent private network where each device has its own key and IP address within the VPN.

On Windows, an official client is installed by downloading it from the project website in the section of desktop installersOnce you download the executable and run it with administrator privileges, the program automatically generates a key pair (public and private) and lets you create new tunnels either by entering the data manually or by importing the same file. peer1.conf that you use on other equipment for that specific client.

For Linux distributions that use apt as the package manager, installation is usually done with a command like `sudo apt install wireguard openresolv` . Then, you copy the client configuration file (for example, `peer1.conf` ) to a path like `/etc/wireguard/wg0.conf` using a command like ` sudo install -o root -g root -m 600 peer1.conf /etc/wireguard/wg0.conf` to ensure correct permissions, and start the interface with `sudo systemctl start wg-quick@wg0` . Optionally, you enable automatic startup with `sudo systemctl enable wg-quick@wg0`.

In all cases, Android is part of the whole just like the rest: each device is a peer which appears in the server configuration with its own public key and AllowedIPs rangeIf you add a block on the server [Peer] For each client (Windows, Linux, mobile, etc.), your tunnel will be able to accept and route traffic from all of them, provided you have the routing and firewall rules properly configured.

Keys, addresses, and key parameters in WireGuard

For everything to work securely and efficiently, each element of the WireGuard configuration has its purpose. First, there are the public and private keys for each device. The private key should never leave the device (mobile, PC, server), while the public key is shared with the other end so it can encrypt the communication. On Linux, for example, these are generated with a command like `wg genkey | tee private.key | wg pubkey > public.key` , and the Windows app does something similar when creating a new empty tunnel.

In the block [Interface] of each client, the field Address Define the internal IP address within the VPN network. A range like this is typically used. 10.0.0.0/24 o 10.6.0.0/24so that the server can be, for example, 10.0.0.1the first customer 10.0.0.2, the next 10.0.0.3and so on. On Android you don't usually see this file directly, but it's there internally and it's the one that's imported when you scan the QR code.

WireGuard's default port is 51820/UDP , although this can be changed if needed. The important thing is that this port is open on your router or firewall and correctly forwarded to the machine running the server. If you have a firewall like UFW on Linux, you would need to run rules like `ufw allow 51820/udp` , and if you're accessing via SSH, something like ` ufw allow 22/tcp` . Otherwise, your Android phone won't be able to establish the tunnel even if the app shows the profile as correctly configured.

Directives also typically appear on the server. PostUp y PostDown in the File wg0.confwhich are used to add or remove rules from iptables that allow traffic forwarding and NAT. A common example is something like this: PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -A FORWARD -o %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE, along with the corresponding PostDown which deletes those rules. Those lines are crucial if you want your Android to work. have internet access through the VPN.

Do not forget either the IPv4 packet forwarding in the system. In many distributions it is activated temporarily with sysctl -w net.ipv4.ip_forward = 1 and permanently editing files such as /etc/sysctl.d/99-sysctl.conf to uncomment the line net.ipv4.ip_forward=1Without that setting, even if the VPN is up and running and the tunnel is established between your Android and the server, you might still be unable to browse the internet from your mobile device via the VPN.

Management of multiple mobile clients (Android and iOS) and security

If you want to use the VPN with multiple smartphones or tablets, the most organized way is to create one folder specifically for mobile customers on the server, for example within /etc/wireguard with a name like mobile_clientsFrom there you generate the keys and configurations for each device you are going to register, using descriptive names like android_oficina, android_personal o iphone_trabajo.

The procedure usually involves generating a new key pair with a command similar to wg genkey | tee clientemovil_private.key | wg pubkey > clientemovil_public.key, create a configuration file like clientemovil.conf and edit it to include a block [Interface] with the mobile phone's private key, your Address (for example 10.0.0.4) and, if you like, your Listenport, and a block [Peer] with the server's public key, the line Endpoint = YOUR_PUBLIC_IP:51820, AllowedIPs = 0.0.0.0/0 (to route all traffic through the VPN) and a PersistentKeepAlive = 25 to keep the connection alive after long periods of inactivity.

a vpn for tv
Related articles:
How to use a VPN on your Android TV to watch all your content without limits

Once you have prepared the client configuration file, you must add your public key to the server within wg0.conf adding a new block [Peer] that includes PublicKey from the mobile, a Allowed IPs corresponding (for example 10.0.0.4/32) and, optionally, PersistentKeepAlive = 25Then you restart WireGuard on the server with commands like systemctl restart wg-quick@wg0 for the changes to take effect.

Regarding security, it's advisable to restrict permissions for private key files on the server so that only the root user can access them. Commands like `chmod 600` or using ` install -m 600` help reduce the risk that, if another system account is compromised, someone could copy keys and impersonate your clients. Although your Android device stores its own private key internally, protecting the server environment is equally important.

Verification, diagnosis and best practices

After setting up your Android and any other client, it's always a good idea verify that the VPN is working and that the traffic actually goes through the server. A simple method is to check your public IP address before connecting to the VPN and then, using services like ipv4.icanhazip.com from a browser or, in the case of Linux, with a command like curl ipv4.icanhazip.comIf the IP address changes to that of the server, you will know that the routing is configured correctly.

When something goes wrong, the systemctl utility in Linux is your ally for checking the status of the wg-quick@wg0 service . With `sudo systemctl status wg-quick@wg0` you can see if the service is running, if there have been any errors starting the interface, or if there are any problems with the iptables rules. Likewise, the `sudo wg` command shows you a detailed list of the interface, its keys, the listening port, and all registered peers along with their latest connections, allowed IPs, and bytes transmitted.

On Android, if the tunnel fails to connect or keeps disconnecting, check that you have access to the server's IP address or domain (for example, if CG-NAT is enabled, if port 51820 is correctly forwarded on the router, etc.) and that no battery-saving or power-management apps are killing the WireGuard process in the background. On some phones, it's advisable to disable battery optimization apps to prevent unexpected disconnections.

What is a VPN
Related articles:
How to Install and Configure a VPN on Android: Complete Guide 2025

As you add more and more devices to your VPN, maintaining a certain order in IP address assignments and peer names will save you a lot of headaches. You can keep a small list where you note, for example, that 10.0.0.2 It's your laptop, 10.0.0.3 your desktop PC, 10.0.0.4 your personal Android mobile and 10.0.0.5 your work mobile. So, if you ever want to revoke access for one of them, you'll just have to delete or comment out their block. [Peer] on the server and restart WireGuard.

Setting up your own VPN with WireGuard and using it from Android allows you to turn your mobile phone into a true "satellite" of your home network or your cloud server: all traffic travels encrypted, you go online with the server's IP address, you access your internal resources as if you were there, and you can also easily integrate other devices such as Windows, Linux, iOS, or macOS.

By following the steps to generate keys, create configuration files, activate packet forwarding, and scan the QR code from the app, you'll quickly have a robust, flexible VPN infrastructure under your control, which you can expand with new clients without relying on third parties or sacrificing your privacy. Share this guide so more users can learn about it.