If you have a NAT router which supports UPnP, the easiest way to get a working
port forward is to make sure UPnP setting is enabled on both Syncthing and the
router – Syncthing will try to handle the rest. If it succeeds you will see a
message in the console saying:
.INDENT0.0
.INDENT3.5
.sp
.nf
.ftC
Created UPnP port mapping for external port XXXXX on UPnP device YYYYY.
.ftP
.fi
.UNINDENT
.UNINDENT
.sp
If this is not possible or desirable you should set up a port forward for port
\fB22000/TCP\fP, or the port set in the \fISync Protocol Listen Address\fP setting.
The external forwarded port and the internal destination port has to be the same
(i.e. 22000/TCP).
.sp
Communication in Syncthing works both ways. Therefore if you set up port
forwards for one device, other devices will be able to connect to it even when
they are behind a NAT network or firewall.
.sp
In the absence of port forwarding, relaying may work well enough to get
devices connected and synced, but will perform poorly in comparison to a
direct connection.
.SHLOCALFIREWALL
.sp
If your PC has a local firewall, you will need to open the following ports for
incoming and outgoing traffic:
.INDENT0.0
.IP\(bu2
Port \fB22000/TCP\fP (or the actual listening port if you have changed
the \fISync Protocol Listen Address\fP setting.)
.IP\(bu2
Port \fB21027/UDP\fP (for discovery broadcasts on IPv4 and multicasts on IPv6)
.UNINDENT
.SSUncomplicatedFirewall(ufw)
.sp
If you’re using \fBufw\fP on Linux and have installed the \fI\%Syncthing package\fP <\fBhttps://apt.syncthing.net/\fP>, you can allow the necessary ports by running:
.INDENT0.0
.INDENT3.5
.sp
.nf
.ftC
sudo ufw allow syncthing
.ftP
.fi
.UNINDENT
.UNINDENT
.sp
If you also want to allow external access to the Syncthing web GUI, run:
.INDENT0.0
.INDENT3.5
.sp
.nf
.ftC
sudo ufw allow syncthing\-gui
.ftP
.fi
.UNINDENT
.UNINDENT
.sp
Allowing external access is \fBnot\fP necessary for a typical installation.
.sp
You can then verify that the ports mentioned above are allowed:
.INDENT0.0
.INDENT3.5
.sp
.nf
.ftC
sudo ufw status verbose
.ftP
.fi
.UNINDENT
.UNINDENT
.sp
In case you installed Syncthing manually you can follow the \fI\%instructions to manually add the syncthing preset\fP <\fBhttps://github.com/syncthing/syncthing/tree/main/etc/firewall-ufw\fP> to ufw.
.SSFirewalld
.sp
If you are using [Firewalld](\fI\%https://www.firewalld.org\fP) it has included
support for syncthing (since version 0.5.0, January 2018), and you can enable