Shadowrocket WireGuard Setup Guide: PrivateKey, PublicKey, Endpoint, and MTU

Learn what each field means when you select WireGuard in Add Server, where to find Address, DNS, Allowed IPs, and MTU values, and what to check first if the handshake fails.

Quick overview

If you already have a WireGuard client configuration, first distinguish your device’s PrivateKey from the peer’s PublicKey and Endpoint. Then compare the tunnel address, route scope, and DNS settings with the original configuration. Turning on the connection does not mean the handshake succeeded. To troubleshoot, first send a request that should use WireGuard, then determine whether the peer is not responding, the destination is unreachable, or only domain name resolution is failing.

Select WireGuard in Add Server

The steps below use Home on iPhone / iPad. Have the configuration assigned to this device by your network administrator or service provider ready. Do not copy the server-side configuration. The [Interface] and [Peer] sections and their field names below help you locate values in the original configuration; they do not mean Add Server uses the same labels for every field.

  1. Open the Add Server screen

    In Home, tap + in the upper-right corner to open Add Server, then select WireGuard under Type.

  2. Enter both keys

    Use the device’s PrivateKey from [Interface] and the peer’s PublicKey from [Peer]. If the original configuration also includes a PresharedKey, enter that value too. Do not substitute the public key.

  3. Match the address and port

    Map the host and port in Endpoint to the form’s Address and Port fields. The Address under the original [Interface] section is the device’s tunnel address. Enter it in the field for the local tunnel IP, not the server address field. Check that the form supports the other settings in the original configuration. If it does not, ask the configuration provider before proceeding; do not omit required settings.

  4. Save and test

    After saving, return to Home, select the entry under SERVER, and turn on the connection. If Global Routing is set to Config, first make sure the test destination’s rule routes the request through this connection, then try a destination known to be reachable.

Where to find PrivateKey, PublicKey, and Endpoint values

The client proves its identity with its own private key and identifies the other end with the peer’s public key. The peer must also register the client public key that corresponds to the device’s private key. If you switch devices or change the private key, confirm that the public key registered on the peer still matches the current configuration—even if the server address and port have not changed.

The two sections in a client configuration

[Interface]: this device
  • PrivateKey belongs to the current device. Copy it exactly, including any trailing padding characters. Do not include the field name or a line break.
  • Address is the tunnel IP assigned to this device, such as 10.66.0.2/32. Do not enter your current Wi-Fi address or change the prefix length yourself.
[Peer]: the other end
  • PublicKey identifies the peer for this configuration. It is not the client public key derived from this device’s private key.
  • Endpoint specifies the peer’s address outside the tunnel and its UDP port. In 192.0.2.10:51820, the host comes before the colon and the port after it. This is only a formatting example.

The two fields named Address serve different purposes: the server address field in the form comes from Endpoint, while the local tunnel address comes from [Interface].

If the peer uses a domain name, Endpoint takes a form such as vpn.example.com:51820. For an IPv6 literal, use the combined format [2001:db8::10]:51820. If the interface has separate host and port fields, do not paste a URL scheme, path, or port into the host field. Use the port from the original configuration.

Common formats for Address, DNS, and Allowed IPs

Address defines the device’s address inside the tunnel. DNS specifies the server used to resolve domain names. In WireGuard, AllowedIPs defines which destination prefixes can be routed to this peer and is also used to validate tunnel source addresses received from it. These fields are not interchangeable.

FieldExampleHow to fill it in
Address10.66.0.2/32 or 2001:db8:66::2/128Use the address and prefix assigned to this device. Check IPv4 and IPv6 separately.
DNS10.66.0.53Use the resolver specified in the configuration. If it is inside the tunnel, make sure it is reachable through this connection.
AllowedIPs10.66.0.0/24A route that covers only the specified subnet. Before accessing other subnets, check the prefix range provided by your administrator.
AllowedIPs0.0.0.0/0, ::/0A route that covers both IPv4 and IPv6. Use it only if the original configuration requires dual-stack and the peer supports it.

These values illustrate the format only. If the original configuration specifies IPv4 only, do not add ::/0 just to create a dual-stack route. Also, having an address covered by AllowedIPs does not guarantee that Shadowrocket will send traffic to it through WireGuard. With Global Routing set to Direct, app traffic is not handled by the selected proxy entry. With Config, check the matching rule and its policy as well.

MTU: Keep the original value first, then adjust based on symptoms

MTU limits the size, in bytes, of each IP packet sent through the tunnel interface; it is not a measure of bandwidth. WireGuard encapsulation increases the size of outer packets. If the path cannot carry packets that large, small responses may get through while downloads or larger responses repeatedly stall. A handshake timeout alone is not a reason to change MTU first.

51820
A common WireGuard UDP port, not a fixed port
1420
Reference value estimated for IPv6 encapsulation with an outer MTU of 1500
1280
Minimum IPv6 link MTU requirement, not a general recommendation

Keep the MTU from the original configuration

Recommended

Keep the configured value if one is provided. If no value is specified and the form allows it to be left blank, keep the app’s default behavior for now. Do not treat a reference value as a required setting.

Best for: first-time setup, or when the connection and data transfer are both working normally.

Lower the MTU and compare results

If you have confirmed that the handshake succeeds and small requests are reliable, but large responses repeatedly stall on a particular network, note the original value. If it is 1420, try 1380 first. Reconnect on the same network and test the same destination again. If there is no improvement, restore the original value. Avoid changing DNS and routing at the same time.

Best for: a successful handshake with repeatable issues transferring large packets.

Troubleshooting order: handshake failures and failures after the handshake

First, send a request that you know should use WireGuard. The connection toggle in Home shows the local connection state; Connectivity Test alone cannot confirm that a specific destination is reachable through this tunnel. If peer status is available, ask your administrator to confirm that the latest handshake time for this client public key updates during the test.

The connection is on. Why is there still no handshake?

Check the selected entry and routing policy first, then verify the host and UDP port in Endpoint. If the host is a domain name, make sure it resolves before the tunnel is established. Without changing the configuration, test on both Wi-Fi and cellular. If it fails on only one network, check name resolution or UDP reachability to the peer on that network before changing keys.

The address and port are correct. Why is the peer still not responding?

Using the same client configuration, recheck the device’s PrivateKey, the peer’s PublicKey, and whether both ends use the same PresharedKey. Ask your administrator to verify the peer’s registration against the client public key. Do not post your private key or full configuration in a support ticket or chat.

There is a handshake, but why can’t I reach the internal address?

First, try reaching an internal service your administrator has confirmed is available, without relying on domain name resolution. Check whether the destination IP falls within this peer’s AllowedIPs, and whether the app’s rules select this connection. If the handshake refreshes but the service never responds, ask your administrator to check the server’s registration of the client tunnel address and the return route.

The internal service is reachable. Why won’t the internal domain name open?

First, check whether the active DNS server is the resolver specified in the configuration and whether its address is reachable. If an internal domain is served only by a private resolver, switching to a public resolver will not provide those records. Fix the DNS resolution path first; there is no need to reconfigure the keys or port.

Download Shadowrocket