Skip to content

Cloud server with WireGuard

Like the Tailscale setup, the gateway does not listen on the public internet: it listens only on the server’s WireGuard address, and the iPhone reaches it through the tunnel. The difference is that you run the tunnel yourself, with no third-party coordination service. The server opens one UDP port for WireGuard and nothing for hmob.

The examples use these addresses; replace them with your own:

Address
WireGuard network 10.8.0.0/24
Server (WireGuard endpoint) 10.8.0.1, listening on UDP 51820
iPhone 10.8.0.2
  • A Linux server (x86_64 or aarch64) with herdr installed, root access, and wireguard-tools, nftables and qrencode installed (for example sudo apt install wireguard-tools nftables qrencode).
  • The official WireGuard app and the Hmob app on the iPhone.

Create keys for the server and the phone:

Terminal window
sudo sh -c 'umask 077; cd /etc/wireguard &&
wg genkey | tee server.key | wg pubkey > server.pub &&
wg genkey | tee phone.key | wg pubkey > phone.pub'

Create /etc/wireguard/hmobwg.conf:

[Interface]
Address = 10.8.0.1/32
ListenPort = 51820
PostUp = wg set %i private-key /etc/wireguard/server.key
PreUp = nft -f /etc/wireguard/hmobwg.nft
PostDown = nft delete table inet hmobwg
[Peer]
# iPhone: the contents of /etc/wireguard/phone.pub
PublicKey = <phone public key>
AllowedIPs = 10.8.0.2/32

By default a WireGuard peer can reach every service on the server. Allow only hmob and drop everything else from the tunnel. Create /etc/wireguard/hmobwg.nft:

table inet hmobwg {
chain input {
type filter hook input priority filter - 5; policy accept;
iifname "hmobwg" ip saddr 10.8.0.2 ip daddr 10.8.0.1 tcp dport 8443 accept comment "hmob"
iifname "hmobwg" drop
}
}

Start the tunnel:

Terminal window
sudo systemctl enable --now wg-quick@hmobwg
sudo wg show hmobwg

In your cloud firewall or security group, allow inbound UDP 51820 (narrow the source to the networks you use if you can). Do not open TCP 8443.

Generate the phone’s configuration on the server and show it as a QR code:

Terminal window
SERVER_PUBLIC_IP=203.0.113.10 # your server's public address
sudo sh -c "umask 077; cat > /etc/wireguard/phone.conf" <<EOF
[Interface]
PrivateKey = $(sudo cat /etc/wireguard/phone.key)
Address = 10.8.0.2/32
[Peer]
PublicKey = $(sudo cat /etc/wireguard/server.pub)
Endpoint = $SERVER_PUBLIC_IP:51820
AllowedIPs = 10.8.0.1/32
PersistentKeepalive = 25
EOF
sudo qrencode -t ansiutf8 < /etc/wireguard/phone.conf

In the WireGuard app, tap + → Create from QR code, scan it and turn the tunnel on. Then delete the phone’s key material from the server:

Terminal window
sudo rm /etc/wireguard/phone.conf /etc/wireguard/phone.key

AllowedIPs = 10.8.0.1/32 sends only traffic for the server through the tunnel; the rest of the phone’s traffic is unaffected.

As the user who runs herdr (not root):

Terminal window
curl -fsSL https://hmob-app.github.io/install.sh | sh
export PATH="$HOME/.local/bin:$PATH" # if the script says it is not on PATH
hmob install-service --bind 10.8.0.1
ss -ltn | grep 8443 # only 10.8.0.1:8443

This installs a systemd user service and enables lingering, so it runs at boot without you logging in.

Terminal window
hmob pair --url https://10.8.0.1:8443

With the WireGuard tunnel on, open the Hmob app, tap Scan pairing QR code and scan the code. Always scan: manual entry has no certificate fingerprint and fails against the gateway’s self-signed certificate.

Rule-based VPN clients (Stash, Clash and similar)

Section titled “Rule-based VPN clients (Stash, Clash and similar)”

Rule-based clients send private address ranges such as 10.0.0.0/8 outside their tunnel by default, so connecting to 10.8.0.1 times out. Use a private host name instead:

  • Pick a name ending in .test or .internal, for example hmob.wg.test. The app relaxes iOS’s system trust check only for these reserved suffixes; the QR fingerprint still decides trust.
  • Run a small DNS server on the server’s WireGuard address that answers that name with 10.8.0.1 and forwards everything else (for example dnsmasq --host-record=hmob.wg.test,10.8.0.1 --listen-address=10.8.0.1 --bind-interfaces --server=1.1.1.1), and allow TCP/UDP 53 from the phone in hmobwg.nft before the drop rule.
  • In the client, use fake-ip DNS, set the WireGuard outbound’s dns to 10.8.0.1, and put DOMAIN,hmob.wg.test,<your WireGuard outbound> before any LAN-direct rule.
  • Pair with hmob pair --url https://hmob.wg.test:8443.
Symptom Check
Pairing times out The tunnel is on in the WireGuard app and sudo wg show hmobwg shows a recent handshake; UDP 51820 is open; sudo tcpdump -ni hmobwg port 8443 sees packets.
Packets arrive but nothing connects sudo nft list table inet hmobwg: the accept rule is before the drop; ss -ltn shows hmob on 10.8.0.1:8443.
“A TLS error caused the secure connection to fail” You entered the address by hand, or used a host name not ending in .test / .internal. Pair again by scanning.
Large screens stall Lower the tunnel MTU to 1280–1380 (MTU = 1380 in the phone’s [Interface]).