Sep 6, 2026 · Protocols · About 10 min

Shadowrocket WireGuard Setup: PrivateKey, Peer PublicKey, Endpoint, Address & MTU

Learn where to add WireGuard in Shadowrocket and what each field means, including PrivateKey, peer PublicKey, PresharedKey, Address and MTU, plus common mistakes to avoid.

At a glance

If you already have a WireGuard configuration, identify the local identity, peer identity and tunnel address before entering the details in Shadowrocket. These steps use the Home workflow on iPhone and iPad; the parameter explanations also apply when checking configurations on Mac, Windows, Android and Linux. After setup, troubleshoot in this order: handshake, data transfer, DNS and MTU. This guide assumes you already have your own service and configuration. We do not provide, sell or recommend nodes or subscriptions.

Check that you have all the WireGuard parameters

WireGuard in Shadowrocket is not a standard proxy form where you enter a server address and password. WireGuard identifies both ends of the connection with public-key cryptography and sends encrypted traffic over UDP. Before you start, have the local PrivateKey, peer PublicKey, Endpoint and the Address assigned to your device. Keep PresharedKey, DNS and MTU too if they appear in your original configuration.

A standard WireGuard configuration file is usually divided into [Interface] and [Peer] sections. The first describes the local device; the second describes the peer. Shadowrocket's edit form may split Endpoint into separate address and port fields, or show IPv4 and IPv6 addresses separately. Match each value by its meaning rather than copying it based only on field position. The addresses and ports in this guide illustrate syntax only; they are not working service endpoints.

2 sections
Basic configuration sections: [Interface] and [Peer]
UDP
WireGuard's outer transport; confirm that your network allows it
51820
Common port example; use the value in your existing configuration

Add WireGuard from Home and keep the original configuration

These steps use the iPhone and iPad workflow. On other platforms, check the same fields; button placement may differ by interface. If the configuration comes from an existing subscription, first check whether it already contains a WireGuard entry. Avoid editing a subscription-generated entry while also creating a manual entry with the same name, or you may select the wrong one after a refresh.

  1. Keep the original

    Store the existing configuration somewhere secure, and note which section each Endpoint, Address and key comes from. Do not edit your only copy of the original file, and never use the server's PrivateKey as the client parameter.

  2. Choose the type

    Open Home → tap “+” in the upper-right corner → Type → WireGuard. Confirm that the form is for WireGuard before entering anything. Do not enter WireGuard values in a Shadowsocks, VMess, VLESS, Trojan or Hysteria2 form.

  3. Enter the local details

    Map the PrivateKey in [Interface] to the local private-key field, and Address to the tunnel-address field. If IPv4 and IPv6 have separate fields, enter each address with its required prefix length.

  4. Enter the peer details

    Map the PublicKey in [Peer] to the peer public-key field, and Endpoint to the server address and port. Enter PresharedKey only if it appears in the original configuration; do not substitute a PublicKey.

  5. Save and test

    After saving, return to Home, select the new entry and start the connection. On the first connection, allow the VPN configuration when prompted by the system, then make a real request. Seeing the system VPN indicator alone does not confirm that the WireGuard peer has completed a handshake.

During testing, keep the automatic connection conditions in Settings → On Demand unchanged or temporarily disable automatic triggers so you can confirm that each connection is started manually. On Demand controls when a connection starts; it does not fix incorrect keys, ports or addresses. Once the parameters check out, restore the automatic connection settings you need.

Which end uses PrivateKey, PublicKey and PresharedKey?

PrivateKey is the local device's identity credential. The local PublicKey derived from it must be registered in the remote Peer configuration. The peer PublicKey field in the client form comes from the remote Interface. The relationship is crosswise: the local device holds its own private key and knows the peer's public key. You do not copy every field from one side into a single form.

Local identity and address

Source
[Interface]
PrivateKey
Local private key; not the remote private key
Local PublicKey
Derived from the local PrivateKey; register it on the remote end
Address
Tunnel address and prefix assigned to this device
DNS
DNS settings, not the server Endpoint

If you change the local PrivateKey, update the corresponding local PublicKey on the remote end too.

Peer identity and connection

Source
[Peer]
PublicKey
The remote peer's public key, not the local PublicKey
PresharedKey
Optional extra shared key; the value must match at both ends
Endpoint
Reachable remote host address and UDP port
AllowedIPs
Tunnel address range assigned to this Peer

Do not substitute local fields for peer fields. Check the original configuration for any missing parameters.

WireGuard PrivateKey, PublicKey and PresharedKey values are often shown as Base64 text, but they serve different purposes. Standard key encoding represents 32 bytes and commonly produces a 44-character string, sometimes ending in =. Length can reveal an obvious copy omission, but it cannot prove that a key is the right one. When pasting, remove extra quotes and surrounding whitespace, but do not delete characters that are part of the encoding.

Endpoint and Address: a public entry point is not a tunnel address

Endpoint is the remote entry point your device must reach over its current Wi-Fi or cellular network. It can be a hostname or IP address followed by a UDP port. Address is the address assigned to your device inside the tunnel, usually with a CIDR prefix. Putting Address in the Endpoint field makes the client try to reach the wrong destination; putting Endpoint in Address gives the local device the wrong tunnel identity.

ParameterSyntax exampleWhat to check
Endpoint,IPv4192.0.2.10:51820Documentation example address; use the actual address and port from your existing configuration.
Endpoint,IPv6[2001:db8::10]:51820When combined, use brackets to separate an IPv6 address from its port. In a split-field form, enter each value in its own field.
Address,IPv410.66.0.2/32Example of a local tunnel address, not a public server address.
Address,IPv6fd00:66::2/128Enter this only if IPv6 is assigned in the original configuration; do not derive it yourself.
AllowedIPs0.0.0.0/0, ::/0Represents all IPv4 and IPv6 address ranges; it does not mean every request will necessarily use this entry.

If the form has separate server-address and port fields, do not append :51820 to the address again. Do not add https:// or a path to a hostname. 51820 is a common port, but if the remote end uses 443 or another UDP port, enter that value instead. A matching port number does not make the transport HTTPS or TCP.

In WireGuard, AllowedIPs helps select a Peer for traffic and constrain which addresses it can receive; it is not simply equivalent to Shadowrocket's domain-based routing rules. Address, DNS and MTU in a standard configuration file also relate to local interface settings, and you should not assume every import method applies all of them. If a setting is missing from the interface, check which fields that workflow supports. Do not paste an entire standard configuration file into Config and assume it will work as-is.

How to adjust MTU, DNS and PersistentKeepalive

MTU sets the maximum size of an individual IP packet inside the tunnel. WireGuard encapsulation adds overhead, so the usable inner packet size is smaller than the underlying link's MTU. 1420 is a common setting, not a one-size-fits-all answer. The underlying network, outer IPv4 or IPv6 transport, and encapsulation along the route can all affect the result.

  1. Check basic connectivity first. If there is never a handshake or reply, check the keys, Endpoint and UDP connectivity first. Lowering MTU usually will not fix an identity mismatch.
  2. Then look for packet-size symptoms. If small requests work but larger pages or uploads repeatedly stall, path MTU may be a factor. Also rule out remote throttling, packet loss and other causes; one slow page is not enough to draw a conclusion.
  3. Change one setting at a time and record it. For example, if the original value is 1420, temporarily try 1380 and compare the same request on the same network. If it does not help, restore the original value. Do not change DNS, rules and keys at the same time.
  4. Preserve the requirements for IPv6. The minimum link MTU for IPv6 is 1280. If IPv6 is involved, do not casually lower the value below that. Use a value supported by both the existing configuration requirements and real-world network testing.

DNS and MTU problems can look similar, but they need different tests. If the connection can exchange data but domain requests fail during resolution, check the DNS settings in the current Shadowrocket Config and whether the resolver is reachable. A hostname used as the Endpoint must also resolve before the tunnel comes up. Pointing all DNS requests to an unreachable address inside the tunnel can create a startup dependency problem.

After WireGuard connects, check Global Routing

Saving a WireGuard entry configures the transport tunnel. Whether requests use it also depends on the selected entry in Home, the Global Routing mode and the rules in Config. The system VPN being active, the WireGuard peer being reachable and a particular website using that entry are three separate things; check each one independently.

Config

Recommended

Let the current configuration's rules select the policy. Requests matching DIRECT do not use the selected WireGuard entry; requests matching PROXY follow the corresponding proxy policy. Check that the policies referenced by the rules match your current selection.

Best for: everyday use when the tunnel is confirmed working and you need to route traffic by domain or address.

Proxy

Send requests handled by the client and eligible for proxying through the proxy path. This can help temporarily rule out the effects of regular routing rules. It does not fix incorrect WireGuard parameters, and it does not mean every kind of system traffic on the device will enter the tunnel.

Best for: briefly verifying data transfer through the selected WireGuard entry. Restore the previous mode when testing is complete.

Direct

Route handled requests directly, without using the selected proxy entry. If a webpage opens in this mode, that does not prove the WireGuard tunnel is working.

Best for: checking whether the local network works normally and separating direct-connection issues from tunnel issues.

The snippet below illustrates how rules in Config are matched from top to bottom; it is not a complete WireGuard configuration. DOMAIN-SUFFIX matches domain suffixes, IP-CIDR matches address ranges, GEOIP matches based on address-location data, and FINAL handles requests that did not match earlier rules. During testing, check which rule an actual request matched rather than just looking for the WireGuard name in the list.

DOMAIN-SUFFIX,example.com,PROXY
IP-CIDR,192.168.0.0/16,DIRECT,no-resolve
GEOIP,CN,DIRECT
FINAL,PROXY

Troubleshoot by symptom; avoid changing several fields at once

Change only one category of settings per test, and record the current network, Endpoint port, selected entry and Global Routing mode. Check the connection logs, error messages and traffic counters available in the app. If the current interface does not show a handshake time, do not infer that a handshake completed from the VPN icon. If you have permission to check the remote Peer status, use it to confirm whether a handshake and data were received.

Observed symptomCheck firstNext step
Connection starts, but no replies arrivePrivateKey, peer PublicKey, PresharedKey and UDP portCompare against the original configuration, then check the remote listener and firewall. Try another network as a comparison.
Peer handshakes, but the destination is unreachableAddress, AllowedIPs, remote forwarding and return routeConfirm that the remote end allows this local address and check for a corresponding return route.
Domain requests fail with a resolution errorConfig DNS, resolver reachability and Endpoint resolutionPinpoint the resolution stage first; do not disable certificate checks or change keys as a workaround.
Small requests work, but larger transfers stallMTU, packet loss and path limitationsKeep the test conditions the same, lower MTU slightly and compare the results.
Manual changes disappear after a subscription updateWhether the entry was generated by a subscriptionCheck the source configuration; use different names for test copies and subscription entries.
Two devices work only in turnWhether they share a PrivateKey and AddressCheck identity assignments for remote Peers and configure each device separately.

A subscription update addresses changes in the configuration source; it is not a general network fix. If an existing subscription manages WireGuard parameters, back up and record your changes before updating and checking the configuration. After troubleshooting, keep the working parameters, restore the required Config and On Demand settings, then test once on Wi-Fi and once on cellular to determine whether any difference comes from the network or the configuration.

Download Shadowrocket