Shadowrocket WireGuard Setup: Private Key, Peer, Allowed IPs, and MTU

Learn what each WireGuard field in Shadowrocket means, from your private key and tunnel address to Peer, Endpoint, Allowed IPs, and MTU troubleshooting.

At a glance

This guide is for users who have received a WireGuard configuration from their own provider and want to check each setting in Shadowrocket. First, distinguish your local identity and tunnel address from the remote Peer. Then learn how Allowed IPs differ from app routing rules, and troubleshoot MTU in stages: handshake, light traffic, then larger transfers. Example addresses are for explaining fields only; they are not connectable servers.

1. Understand the local Interface and remote Peer

WireGuard in Shadowrocket should not be treated as “a server address and a password.” WireGuard identifies peers by public keys: your device keeps its own Private Key, and the corresponding Public Key must be registered on the remote side. Your local Peer entry uses the remote Public Key. The keys must match on both sides; a server address alone is not enough to establish a working tunnel.

A standard WireGuard configuration file usually has [Interface] and [Peer] sections. The first describes your device’s identity and tunnel address; the second describes the remote peer and the address ranges allowed through it. Shadowrocket may split these fields across several inputs. Match them by meaning, and do not paste the entire file into a key field.

32 bytes
The raw length of a WireGuard public or private key; configurations usually represent keys in Base64
UDP
WireGuard’s outer transport protocol; a successful TCP connection is not a handshake test
51820
A common example port, not a fixed port for every service

2. What to enter for Private Key, Address, and Peer

Private Key is your local private key, not a remote password. It is paired with your local Public Key. If you replace the local private key without having the remote side register the new public key, the remote side can no longer recognize your device under its previous identity. Do not generate or replace keys just to “try again.” First check that the provider’s configuration is complete and still assigned to this device.

Address is the tunnel address, not the Endpoint. For example, 10.66.66.2/32 indicates your device’s IPv4 address and prefix inside the tunnel. Do not enter the server’s public IP, your current Wi-Fi address, or a destination website address here. If your provider gives you both IPv4 and IPv6 addresses, enter them separately as the form allows; do not guess an unassigned address.

Local Interface

Private Key
Enter the local private key from your provider’s configuration, preserving the Base64 characters and any trailing padding
Address
For example, 10.66.66.2/32; an example format for a tunnel address only
MTU
Sets the IP packet size allowed on the tunnel interface; use the configured value when available
DNS
If the original configuration includes this setting, also check whether Shadowrocket’s DNS settings carry it over

Address, DNS, and MTU are configuration parameters; they do not replace key-based authentication.

Remote Peer

Public Key
Enter the remote public key—not your local public key or either side’s private key
Endpoint
For example, 192.0.2.10:51820; both the address and port are for illustration
Allowed IPs
For example, 0.0.0.0/0; use the range specified by your provider for your intended use
Preshared Key
An optional extra shared key; if enabled on the remote side, it must match on both ends

Compact names in the original file, such as PublicKey and AllowedIPs, correspond to the fields listed here by meaning.

Preshared Key and Private Key are different fields. The former is an additional shared secret agreed by both sides; the latter belongs only to your local identity. If the original configuration does not include a Preshared Key, do not make one up. Similar-looking keys are not interchangeable.

3. Endpoint address, port, and UDP connectivity

Endpoint is the outer network destination used to establish WireGuard communication. If the form splits it into Address or Server and Port, enter only the hostname or IP in the address field and the port number supplied by your provider in the port field. Do not add https:// or a web path. For an IPv6 Endpoint in the original file, the common format is [2001:db8::10]:51820; the brackets distinguish the address’s colons from the port separator.

Persistent Keepalive sends periodic packets to help maintain a NAT mapping. PersistentKeepalive = 25 is a common example that sends a packet every 25 seconds, not a value required on every network. It cannot fix an incorrect Public Key, a closed remote port, or expired account access.

4. Allowed IPs are not Global Routing rules

In WireGuard, Allowed IPs help select the Peer for traffic to a destination address and also restrict the inner source addresses accepted from that Peer. 0.0.0.0/0 covers all IPv4 addresses, while ::/0 covers all IPv6 addresses; entering only the former does not include the latter. If your provider gives you only a private subnet, the configuration is usually intended for access to a specific private network. Expanding the range yourself does not mean the remote side can route the entire internet.

Shadowrocket adds another layer of routing decisions: Global Routing and Config rules determine whether traffic is sent to this node. Even if the Peer’s Allowed IPs include the default route, traffic matching DIRECT will not automatically use the node. Conversely, routing traffic to WireGuard in the app does not mean the remote side is configured to forward it or provide the required routes and internet access.

Setting layerExampleWhat it controls
Peer Allowed IPs10.20.0.0/16Specifies the inner address ranges for that Peer; these are not domain rules
Peer default route0.0.0.0/0, ::/0Covers both IP address families; the remote side must still be able to forward the traffic
Config domain ruleDOMAIN-SUFFIX,example.com,DIRECTRoutes traffic for matching domains using the DIRECT policy
Config address ruleIP-CIDR,192.0.2.0/24,DIRECTSelects a policy by destination IPv4 range without changing Peer keys

In Global Routing, Proxy routes traffic through a proxy, Direct connects without one, Config follows the active configuration’s rules, and Scene follows its configured scenario. Record the current mode before troubleshooting. If you test an external website in Direct mode, the result does not show whether the WireGuard node works. In Config mode, check which rule and policy actually match your test destination.

5. Add and test the settings in Shadowrocket

The steps below use the Home node editor on iPhone or iPad. Keep the provider’s original configuration and any currently working configuration, then enter the values one at a time. The form layout may change, but the relationship between the local Interface and Peer stays the same. If your WireGuard node was imported from a subscription, open its edit screen to check the settings rather than creating multiple nodes with similar names and different parameters.

  1. Gather the settings

    Get the configuration from your provider. Identify the Interface and Peer sections, and note the Endpoint, port, Address, Allowed IPs, and MTU. Do not copy keys into publicly visible notes.

  2. Choose the protocol

    Home → “+” in the upper-right corner → Type → WireGuard. Use the form to distinguish local settings from Peer settings; do not paste the whole configuration into Private Key.

  3. Enter each field

    Enter the local Private Key and Address, then the Peer’s Public Key and the Endpoint address and port. Fill in the remaining options from the original configuration and save.

  4. Select the node

    Return to Home and tap the circle to the left of the server. Check Global Routing. To rule out routing rules as a cause, you can briefly switch to Proxy for a test, then restore the previous mode.

  5. Test traffic

    Turn on the connection. If prompted to add a VPN configuration for the first time, follow the system instructions. Run Connectivity Test, then test a small webpage and a larger transfer, recording each result.

A successful Connectivity Test confirms only the connectivity covered by the selected test method; it does not replace testing actual traffic through the tunnel. A system status showing VPN connected does not prove that a valid handshake with the remote side has completed. If the interface or available logs show the handshake time, sent bytes, and received bytes, use those as additional clues. A growing sent counter alone does not confirm two-way communication.

6. MTU symptoms and how to change one setting at a time

MTU limits the size of IP packets on the tunnel interface, in bytes. WireGuard adds encryption and UDP/IP encapsulation around inner IP packets, and the outer path may pass through other tunnels. So you cannot simply use the 1500 value common on physical network interfaces. 1420 is a common setting, not a universal answer; the usable value depends on the outer address family and the capacity of the network path.

A typical MTU or Path MTU Discovery problem looks like this: the handshake and small transfers seem fine, and small webpages load, but larger responses, uploads, or sustained transfers stall. Packet loss, DNS problems, remote restrictions, or app timeouts can cause similar symptoms, so treat this only as a troubleshooting clue. If there is no handshake at all, check the keys, Endpoint, and UDP first rather than changing MTU.

Use the configured MTU

Recommended

Start with the value explicitly supplied by your provider to establish a baseline for comparison. If the original configuration does not specify MTU, keep the client’s default behavior; do not guess based on network speed.

Best for: first-time setup or when no large-transfer issue has been confirmed

Compare with a lower MTU

If the original value is 1420, try 1380 and 1280 as separate diagnostic comparisons, leaving all other settings unchanged. Save and reconnect after each change. Do not assume a test value is the best permanent setting.

Best for: small transfers work, but larger transfers repeatedly stall

Increase the MTU

Consider this only when path conditions and test results support it. A larger number does not mean faster speeds; exceeding the path’s capacity can cause fragmentation, packet loss, or connection delays.

Best for: advanced testing with a stable baseline and controlled conditions

7. Troubleshoot by failure stage, not just by blaming the keys

Troubleshoot from the outside in: first confirm that the Endpoint resolves and is configured correctly, then check UDP connectivity and identity settings, followed by the inner address, routing, DNS, and app rules. Do not change five fields at once. Even if the connection starts working, you will not know which change helped, and you could leave an incorrect address range or unnecessary keepalive setting behind.

SymptomCheck firstNext step
Endpoint hostname does not resolveHostname spelling, current DNS, network connectionRestore hostname resolution without changing Private Key
No valid handshake or two-way trafficUDP port, remote Public Key, registration of the local key, Preshared KeyCheck each item with your provider; do not send your private key
Handshake works, but destination is unreachableAddress, Allowed IPs, remote forwarding, Global Routing, and rulesConfirm that this node is meant to carry traffic to the destination
IP address works, but domain name failsDNS resolution and the route used by DNS requestsCheck DNS resolution separately; do not rebuild the Peer first
Small requests work, but larger transfers stallMTU, packet loss along the path, remote restrictionsKeep other conditions fixed and lower MTU one step at a time for comparison
Original settings return after a subscription updateWhether the node is managed by a subscriptionAsk your provider to confirm the source configuration and distinguish subscription-managed nodes from manual nodes

A subscription update may reapply node settings supplied by your provider. If you manually changed a field for troubleshooting, record the change and check whether a later refresh will overwrite it. Do not ignore an error in the source configuration just because a local change temporarily helped, and do not stop necessary configuration updates indefinitely just to preserve a test value.

Download Shadowrocket