Shadowrocket WireGuard Setup: Private Key, Peer, AllowedIPs & MTU

Learn what each WireGuard field means in Shadowrocket, including Private Key, Public Key, Endpoint, AllowedIPs, MTU, and DNS, plus common configuration mistakes.

At a glance

This guide is for users who already have WireGuard settings from their provider and want to enter or verify them manually in Shadowrocket. First distinguish the local interface from the Peer, then check keys, addresses, the UDP endpoint, and DNS. Finally, use routing modes and layered tests to narrow down the issue. Standard configuration fields are explained to clarify where parameters come from; not every field is necessarily editable under the same name in the app.

1. Distinguish the local interface from Peer

WireGuard identifies peers by public key and sends encrypted data over UDP. The local interface defines the device's identity and tunnel address; a Peer represents the remote endpoint. Keep the keys for each side separate: your device holds its own Private Key and uses the remote party's Public Key to connect. The remote side must register the Public Key corresponding to your Private Key.

This guide assumes you already have a valid configuration. This site does not provide, sell, or recommend nodes or subscriptions. WireGuard setup is not as simple as entering an address and a generic password: at minimum, verify the key pair, local tunnel address, and remote endpoint. Do not reuse authentication fields from Shadowsocks, VMess, VLESS, Trojan, or Hysteria2 in WireGuard.

32 bytes
The raw length of a WireGuard key, usually represented as Base64 text
UDP
Transport protocol for the remote Endpoint; there is no universally required port
2 categories
Parameter sources: local Interface and remote Peer

In a standard WireGuard configuration, [Interface] and [Peer] describe the parameters. They are not Shadowrocket [Rule] sections. Before importing a configuration, confirm that its file format is supported by the app; matching file extensions alone do not make formats interchangeable.

2. What to enter for Private Key, Public Key, and addresses

Private Key is your device's secret credential. Copy it exactly from your existing configuration, taking care not to add spaces or line breaks or omit any characters. Changing the Private Key changes your device's identity. If the remote side still has the old Public Key registered, communication will fail even if the Endpoint is correct. Do not generate a new key just to see if it fixes a connection issue.

Local Interface parameters

Private Key
Your device's private key; it must correspond to the Public Key registered by the remote side.
Address
The tunnel address assigned to your device, such as 10.7.0.2/32; this is not the remote server address.
DNS
The address of a DNS resolver; this is an app integration setting, not a key-handshake parameter.
MTU
The maximum packet size for the tunnel interface, in bytes; start with the value specified by your provider or the default.

These descriptions explain the source configuration. In Shadowrocket, check how they map to the available fields and import options.

Remote Peer parameters

Public Key
The remote party's public key—not a public key derived from your local Private Key.
Endpoint
The remote address and UDP port, such as 192.0.2.10:51820.
AllowedIPs
The tunnel destination prefixes and allowed source-address ranges for this Peer.
Preshared Key
An optional additional shared key; if configured, it must match on both sides.

The example addresses are reserved for documentation and cannot be used to connect. Use the values from your own configuration.

In Address, /32 denotes a single IPv4 address prefix; /128 is commonly used for a single IPv6 address. These addresses are determined by the remote network's design. Do not replace them with local network addresses just because they differ from your home Wi-Fi addresses. If the source configuration includes both IPv4 and IPv6, first confirm that the remote side and your current network support both.

3. Add and check WireGuard in Home

In Shadowrocket, Home is where you select a connection, Config manages rule configurations, and Settings manages app preferences. Get the WireGuard settings right before working on traffic routing. The field layout may change between app versions, so the steps below describe the general navigation. Names such as AllowedIPs and DNS from a source file may not appear as individual fields in the editor; do not put them into unrelated fields just because there is no matching input.

  1. Gather your settings

    From your configuration, identify your Private Key, tunnel Address, remote Public Key, Endpoint, and optional Preshared Key. Keep an original copy for reference.

  2. Choose the type

    Go to Home → “+” in the upper-right corner → Type → WireGuard. Select the type before entering the fields so you don't mistake another protocol's editor for the WireGuard setup screen.

  3. Enter the endpoint

    Enter the Endpoint host and port in the corresponding server fields, such as Address and Port. For the documentation endpoint 192.0.2.10:51820, the host is 192.0.2.10 and the port is 51820. The server Address is not the same as the tunnel Address.

  4. Check the keys

    Enter your Private Key and the remote Public Key, then verify the local tunnel address. If you have a Preshared Key, enter the value from your original configuration. If not, do not substitute a password or Public Key.

  5. Save and test

    After saving, return to Home and select the connection, then check Global Routing. For the first test, use one specific destination. During troubleshooting, you can temporarily turn off automatic triggers in Settings → On Demand to prevent a manual disconnect from reconnecting automatically.

51820 is a common WireGuard listening port, not a port required by the protocol. If your original configuration specifies 443, use that UDP endpoint; this does not mean it supports TCP or HTTPS. If UDP is blocked on your network, entering a different port does not mean the remote side is listening there.

4. AllowedIPs and Global Routing operate at different levels

In standard WireGuard, AllowedIPs helps select a Peer for outgoing traffic and limits the source addresses accepted in decrypted traffic from that Peer. The common 0.0.0.0/0 prefix covers all IPv4 addresses, while ::/0 covers all IPv6 addresses. 10.7.0.0/24 covers only a specified subnet. AllowedIPs is not a domain list, website access permission, or paid usage allowance.

Shadowrocket also has routing layers in Global Routing and Config. Which app requests go through the selected connection depends on the current routing mode; seeing 0.0.0.0/0 in a source configuration does not prove that every request will use WireGuard. Scene lets you arrange settings for different scenarios. For basic troubleshooting, start with one clearly defined mode to reduce variables.

Config

Recommended

Choose a policy based on the rules in your current configuration. Before using it for everyday traffic routing, check the rule order and which connection the PROXY policy actually uses.

Best for: routing by domain or IP range after confirming that WireGuard works.

Proxy

Send requests that can use the current proxy route through the selected connection. This is useful for temporarily ruling out Config rules, but it does not mean that all system traffic will be routed through it.

Best for: briefly checking whether the selected WireGuard connection can carry traffic.

Direct

Requests connect directly; this does not test whether the WireGuard tunnel works. A page loading in your browser does not prove that the tunnel was established.

Best for: establishing a local network baseline and checking whether the same issue occurs with a direct connection.

The following illustrates Shadowrocket rule syntax, not WireGuard configuration. DOMAIN-SUFFIX matches domain suffixes, IP-CIDR matches IP subnets, and FINAL handles requests that did not match earlier rules. Rules are evaluated from top to bottom; requests already matched by an earlier rule do not continue to FINAL.

[Rule]
DOMAIN-SUFFIX,example.com,PROXY
IP-CIDR,192.0.2.0/24,DIRECT
FINAL,DIRECT

Here, example.com and 192.0.2.0/24 are for documentation only. If you use GEOIP, note that it relies on an IP geolocation database and cannot replace checks of the Peer, AllowedIPs, or the server's return route. For more on rule behavior, see the rule reference.

5. MTU and DNS: two reasons a connection may still fail

MTU limits the size of IP packets carried by the tunnel interface. Encryption adds outer packet overhead, so tunnel MTU is usually lower than the underlying link MTU. 1420 is a common reference value, but it is not a universal setting for every Wi-Fi, cellular, or nested tunnel connection. Start with the value specified in your existing configuration or the default. Make controlled comparisons only if you see symptoms that point to an MTU issue.

What you observeCheck firstChange one setting at a time
Small requests succeed, but larger responses repeatedly stallPath MTU, packet loss, and remote forwardingIf MTU is editable, compare 1420 with 1380. Record the result, then restore the original or keep the value that works.
Name resolution times out, but diagnostic requests to a known IP get a responseDNS address and the route to the DNS serverCheck whether the DNS server in your original configuration is reachable only through the tunnel.
Only some IPv6 destinations failIPv6 addresses, routes, and remote forwarding supportTest IPv4 and IPv6 separately; adding ::/0 is not a fix by itself.
Data stops arriving after switching networksUDP reachability and NAT mappingReconnect on the new network, then test the same destination again.

These are diagnostic symptoms and test methods, not results from local testing. 1380 is not a universally optimal value either. If lowering MTU does not produce a repeatable improvement, restore the original value and check other layers. Do not change MTU, DNS, Endpoint, and routing mode at the same time, or you will not know which change made a difference.

DNS resolves domain names to addresses; it is not involved in the WireGuard public-key handshake. In a standard configuration, DNS is usually handled by the client software. Shadowrocket's actual DNS behavior also depends on the current Config settings. A DNS server reachable only inside the tunnel cannot handle all DNS lookups needed before the tunnel is established, especially if the Endpoint is a domain name.

6. Troubleshoot in this order: endpoint, handshake, data, rules

A connected status in the app or a VPN icon in the system only indicates the local connection state. It does not prove that the remote side accepted the keys or that a request reached its destination. WireGuard can remain quiet when there is no traffic, so trigger a specific request to test it. If you have remote administrative access, check the latest handshake time and transfer counters as well.

  1. Endpoint: Verify the hostname or IP, confirm that the port matches the remote listener, and make sure the current network allows the required UDP traffic. Successful DNS resolution does not mean the UDP port is reachable.
  2. Handshake: Confirm that the Public Key corresponding to your Private Key is registered on the remote side, that the remote Public Key is correct, and that both sides use the same optional Preshared Key. Matching-looking key lengths are not enough to verify a key pair.
  3. Data: If the handshake succeeds but traffic does not, check the tunnel address, AllowedIPs, remote forwarding, firewall, and return route. Whether the remote side needs NAT or an explicit return route depends on its network design.
  4. Rules: Compare the same request using Global Routing → Proxy and Config. If it fails only under Config, first check which rule matches and which policy it references; you do not need to replace the keys as a first step.
  5. Stability: If the connection drops after being idle, check NAT mapping and whether keepalives are needed. In a standard configuration, PersistentKeepalive is measured in seconds; 25 is a common example, not a requirement for every connection. Change it only if your existing configuration calls for it and the app supports the setting.

7. Common configuration mistakes and a pre-save checklist

The most common manual setup errors are not about choosing from too few protocols; they come from mixing up field roles. Review each field before saving, especially when both the server address and tunnel address are labeled Address. If a WireGuard connection comes from a subscription, manual changes may be overwritten at the next update. Keep a separate record and check where the settings are managed.

After checking the configuration, first confirm that a specific destination can send traffic through the selected WireGuard connection. Then restore your Config routing and everyday automatic connection settings. Shadowrocket is a closed-source commercial app for Apple platforms, primarily used on iPhone and iPad. Check the App Store listing for pricing, system requirements, and compatibility with other Apple devices. Buying the app does not include a network service or connection configuration.

Verify Shadowrocket on the App Store