# Tips on how to make UPnP work

**URL:** https://forum.syncthing.net/t/tips-on-how-to-make-upnp-work/2436
**Category:** Support
**Created:** [April 15, 2015, 12:42am UTC](https://forum.syncthing.net/t/tips-on-how-to-make-upnp-work/2436 "2015-04-15T00:42:54Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![marcelpaulo](https://forum.syncthing.net/user_avatar/forum.syncthing.net/marcelpaulo/32/991_2.png) [@marcelpaulo](https://forum.syncthing.net/u/marcelpaulo)
#### Post date: [April 15, 2015, 12:42am UTC](https://forum.syncthing.net/t/tips-on-how-to-make-upnp-work/2436/1 "2015-04-15T00:42:54Z")

</div>

I wonder if someone could share some tip on how to make UPnP work. I know this is a router-specific thing. But then again, if someone has any tip whatsoever, I’d be humbly grateful.

This is what I’ve done so far:

- Enabled UPnP on syncthing
- Revised every single router (_D-Link DSL-2730E_) setting: there was only one UPnP-related, enabled it
- [Issue 2035](https://forum.syncthing.net/t/upnp-seems-not-to-work-mac-os-x-10-10-st-0-10-24-fritzbox-7330-router/2035) shows how to trace syncthing UPnP usage, which I did running: `STTRACE=upnp syncthing &> >(tee upnp.log)` No message said that a port had been mapped. Here they are:

```
[2L7Y5] 2015/04/14 21:10:11.588524 upnp.go:97: INFO: Starting UPnP discovery...
[2L7Y5] 2015/04/14 21:10:11.588552 upnp.go:146: DEBUG: Starting discovery of device type urn:schemas-upnp-org:device:InternetGatewayDevice:2...
[2L7Y5] 2015/04/14 21:10:11.588613 upnp.go:166: DEBUG: Sending search request for device type urn:schemas-upnp-org:device:InternetGatewayDevice:2...
[2L7Y5] 2015/04/14 21:10:11.588656 upnp.go:178: DEBUG: Listening for UPnP response for device type urn:schemas-upnp-org:device:InternetGatewayDevice:2...
[2L7Y5] 2015/04/14 21:10:14.588920 upnp.go:219: DEBUG: Discovery for device type urn:schemas-upnp-org:device:InternetGatewayDevice:2 finished.
[2L7Y5] 2015/04/14 21:10:14.589156 upnp.go:146: DEBUG: Starting discovery of device type urn:schemas-upnp-org:device:InternetGatewayDevice:1...
[2L7Y5] 2015/04/14 21:10:14.589332 upnp.go:166: DEBUG: Sending search request for device type urn:schemas-upnp-org:device:InternetGatewayDevice:1...
[2L7Y5] 2015/04/14 21:10:14.589454 upnp.go:178: DEBUG: Listening for UPnP response for device type urn:schemas-upnp-org:device:InternetGatewayDevice:1...
[2L7Y5] 2015/04/14 21:10:17.589580 upnp.go:219: DEBUG: Discovery for device type urn:schemas-upnp-org:device:InternetGatewayDevice:1 finished.
[2L7Y5] 2015/04/14 21:10:17.589744 upnp.go:124: INFO: UPnP discovery complete (found 0 devices).

```

- Installed `upnp-inspector` (_Xubuntu 14.10_): it sees my router, but I couldn’t see any messages indicating that syncthing managed to map a port. The information shown looked Greek to me!

I know UPnP is not working: if I enable UPnP, and disable fixed port forwarding, syncthing on my desktop doesn’t connect to my mother’s desktop, which is behind another NAT router.

As I said, I know this not syncthing’s problem, surely it’s my router’s, but if someone has already struggled with this and could share any pointers…

Paulo

**_EDIT:_**

- After starting syncthing, checked current tcp connections in LISTEN state, and noticed that it’s listening on **tcp6** but not on **tcp** :

```
paulo@monk:~/tmp$ netstat -tln
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State      
tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN     
tcp 0 0 127.0.0.1:5941 0.0.0.0:* LISTEN     
tcp 0 0 127.0.1.1:53 0.0.0.0:* LISTEN     
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN     
tcp 0 0 127.0.0.1:8888 0.0.0.0:* LISTEN     
tcp 0 0 127.0.0.1:5037 0.0.0.0:* LISTEN     
tcp6 0 0 :::22000 :::* LISTEN     
tcp6 0 0 ::1:631 :::* LISTEN     

```

- Indeed, checked whether port 22000 is opened using [CanYouSeeMe.org](http://www.canyouseeme.org/), and it is closed
- Both local and global discovery are enabled

Not sure what I’m missing here. I suspect it’s something shamefully obvious…

---

<div class="post-metadata">

### Author: ![calmh](https://forum.syncthing.net/user_avatar/forum.syncthing.net/calmh/32/15311_2.png) [@calmh](https://forum.syncthing.net/u/calmh)
#### Post date: [April 15, 2015, 6:15am UTC](https://forum.syncthing.net/t/tips-on-how-to-make-upnp-work/2436/2 "2015-04-15T06:15:06Z")

</div>

Looks like it’s simply not getting search responses when looking for the UPnP devices. Not sure why. Do you have a firewall on the machine you are running synchting on, even a local one? Try turning it off.

The tcp6 socket is normal (it means IPv4 and IPv6), and the port being closed is an effect of UPnP not doing it’s thing and there not being a manual port forward.

---

<div class="post-metadata">

### Author: ![AudriusButkevicius](https://forum.syncthing.net/user_avatar/forum.syncthing.net/audriusbutkevicius/32/277_2.png) [@AudriusButkevicius](https://forum.syncthing.net/u/AudriusButkevicius)
#### Post date: [April 15, 2015, 8:39am UTC](https://forum.syncthing.net/t/tips-on-how-to-make-upnp-work/2436/3 "2015-04-15T08:39:24Z")

</div>

If you are running windows, there ia a known bug which sometimes causes windows to drop the broadcasts.

On linux, I guess try getting a commandline/somw other upnp client and see if it can discover the device to start with. If it can, then probably using wireshark to see if syncthing is sending the broadcasts is your next best bet.

It also might be your firewall preventing ssdp discovery.

---

<div class="post-metadata">

### Author: ![marcelpaulo](https://forum.syncthing.net/user_avatar/forum.syncthing.net/marcelpaulo/32/991_2.png) [@marcelpaulo](https://forum.syncthing.net/u/marcelpaulo)
#### Post date: [April 15, 2015, 11:31am UTC](https://forum.syncthing.net/t/tips-on-how-to-make-upnp-work/2436/4 "2015-04-15T11:31:23Z")

</div>

> [@calmh](#):
>
> Do you have a firewall on the machine you are running synchting on, even a local one? Try turning it off.

> [@AudriusButkevicius](#):
>
> It also might be your firewall preventing ssdp discovery.

Oh, of course, you’re right. Disabled the firewall:

```bash
paulo@monk:~/tmp$ sudo ufw disable
Firewall stopped and disabled on system startup
paulo@monk:~/tmp$ sudo ufw status
Status: inactive

```

but the results were the same.

This modem-router (_D-Link DSL-2730E_) was leased by my ISP provider (_GVT_) and has a custom built firmware: I’m suspecting UPnP is firmware-disabled. I’ve written to D-Link inquiring about it. I’ll post back when I get any news.

In the meantime, I’ll try to grab another (proper) router to test.

> [@calmh](#):
>
> The tcp6 socket is normal (it means IPv4 and IPv6)

Oh dear, I didn’t know that, my ignorance, thanks for explaining.

> [@AudriusButkevicius](#):
>
> On linux, I guess try getting a commandline/somw other upnp client and see if it can discover the device to start with.

`upnp-inspector` can see the router. I’ll search for alternatives.

> [@AudriusButkevicius](#):
>
> If it can, then probably using wireshark to see if syncthing is sending the broadcasts is your next best bet.

I had `wireshark` running during the tests, but didn’t dig into the output. Will follow your suggestion and look more closely.

Thank you so much, @calmh and @AudriusButkevicius for your patient and useful tips.

---

<div class="post-metadata">

### Author: ![calmh](https://forum.syncthing.net/user_avatar/forum.syncthing.net/calmh/32/15311_2.png) [@calmh](https://forum.syncthing.net/u/calmh)
#### Post date: [April 15, 2015, 11:59am UTC](https://forum.syncthing.net/t/tips-on-how-to-make-upnp-work/2436/5 "2015-04-15T11:59:19Z")

</div>

Could be that the router doesn’t understand/like our discovery packets for some reason. The wireshark trace (pcap) of `upnp-inspector` and then starting `syncthing` would be interesting, we could check for relevant differences.

---

<div class="post-metadata">

### Author: ![marcelpaulo](https://forum.syncthing.net/user_avatar/forum.syncthing.net/marcelpaulo/32/991_2.png) [@marcelpaulo](https://forum.syncthing.net/u/marcelpaulo)
#### Post date: [April 15, 2015, 4:07pm UTC](https://forum.syncthing.net/t/tips-on-how-to-make-upnp-work/2436/6 "2015-04-15T16:07:13Z")

</div>

Bingo, I think your suggestion nailed the problem, @calmh ! Here’s what I did:

1. Started a `wireshark` capture with filter `udp port 1900`
2. Started `upnp-inspector`, waited for devices to show up. Took around 10s: ![](https://forum.syncthing.net/uploads/default/1187/def2ba39b4b6e28d.jpg)
3. Stopped capture. Here’s the [pcap file](https://docs.google.com/file/d/0B6eQjhXV-AquUFRYQm9wdnhLdUk/edit?usp=drivesdk)
4. Stopped `upnp-inspector`
5. Started another `wireshark` capture, same filter
6. Started `syncthing` with `STTRACE=upnp syncthing &> >(tee syncthing.log)` Waited for `syncthing` to finish UPnP discovery.
7. Stopped capture. Here’s the [pcap file](https://docs.google.com/file/d/0B6eQjhXV-AquQ05Cejg4M1I2b0k/edit?usp=drivesdk)
8. Stopped `syncthing`. Here’s the [output log](https://gist.github.com/marcelpaulo/f8440c4d7a2cdfc3096a)

The impression I get: the router takes around 10s to reply to the SDDP search requests, and syncthing times out too quickly, way before the replies arrive. If that is the case, do you want me to open an issue on the syncthing tracker ?

_ **EDIT:** _ Just for reference, here’s the [article](https://wiki.wireshark.org/SSDP) from wireshark’s Wiki I used to get the correct filter for capturing SDDP traffic.

_ **EDIT 2:** _ Found a more useful UPnP viewer, Ubuntu package `gupnp-tools`, utility `gupnp-universal-cp` shows detailed information about all UPnP devices on the network and their control points: ![](https://forum.syncthing.net/uploads/default/1188/606089c05131e4d9.jpg)

---

<div class="post-metadata">

### Author: ![AudriusButkevicius](https://forum.syncthing.net/user_avatar/forum.syncthing.net/audriusbutkevicius/32/277_2.png) [@AudriusButkevicius](https://forum.syncthing.net/u/AudriusButkevicius)
#### Post date: [April 15, 2015, 9:52pm UTC](https://forum.syncthing.net/t/tips-on-how-to-make-upnp-work/2436/7 "2015-04-15T21:52:47Z")

</div>

You can try building syncthing with a longer timeout, and see if that helps. We block our functionality until we complete UPnP so I don’t 10 seconds is a good default value.

---

<div class="post-metadata">

### Author: ![marcelpaulo](https://forum.syncthing.net/user_avatar/forum.syncthing.net/marcelpaulo/32/991_2.png) [@marcelpaulo](https://forum.syncthing.net/u/marcelpaulo)
#### Post date: [April 16, 2015, 5:13am UTC](https://forum.syncthing.net/t/tips-on-how-to-make-upnp-work/2436/8 "2015-04-16T05:13:53Z")

</div>

Wouldn’t it be the case of exposing this UPnP timeout as a configuration parameter ? Currently _config.xml_ has these UPnP-related parameters:

```xml
<upnpEnabled>true</upnpEnabled>
<upnpLeaseMinutes>0</upnpLeaseMinutes>
<upnpRenewalMinutes>30</upnpRenewalMinutes>

```

**_EDIT:_** Would it make sense to add this as a feature request on the issue tracker ?

---

<div class="post-metadata">

### Author: ![AudriusButkevicius](https://forum.syncthing.net/user_avatar/forum.syncthing.net/audriusbutkevicius/32/277_2.png) [@AudriusButkevicius](https://forum.syncthing.net/u/AudriusButkevicius)
#### Post date: [April 16, 2015, 8:05am UTC](https://forum.syncthing.net/t/tips-on-how-to-make-upnp-work/2436/9 "2015-04-16T08:05:25Z")

</div>

I already have a patch for that.

---

<div class="post-metadata">

### Author: ![marcelpaulo](https://forum.syncthing.net/user_avatar/forum.syncthing.net/marcelpaulo/32/991_2.png) [@marcelpaulo](https://forum.syncthing.net/u/marcelpaulo)
#### Post date: [April 16, 2015, 8:29am UTC](https://forum.syncthing.net/t/tips-on-how-to-make-upnp-work/2436/10 "2015-04-16T08:29:52Z")

</div>

Hey, great to know ! Problem solved, then. Will this patch be applied to 0.10 and 0.11 ?

---

<div class="post-metadata">

### Author: ![AudriusButkevicius](https://forum.syncthing.net/user_avatar/forum.syncthing.net/audriusbutkevicius/32/277_2.png) [@AudriusButkevicius](https://forum.syncthing.net/u/AudriusButkevicius)
#### Post date: [April 16, 2015, 8:43am UTC](https://forum.syncthing.net/t/tips-on-how-to-make-upnp-work/2436/11 "2015-04-16T08:43:19Z")

</div>

Not sure. Probably v0.11 only, as 0.10 is a maintenance release for now.

---

<div class="post-metadata">

### Author: ![bigbear2nd](https://forum.syncthing.net/user_avatar/forum.syncthing.net/bigbear2nd/32/4525_2.png) [@bigbear2nd](https://forum.syncthing.net/u/bigbear2nd)
#### Post date: [April 16, 2015, 8:45am UTC](https://forum.syncthing.net/t/tips-on-how-to-make-upnp-work/2436/12 "2015-04-16T08:45:56Z")

</div>

> [@Syncthing v0.11.0 Release Notes](https://forum.syncthing.net/t/syncthing-v0-11-0-release-notes/2426/1):
>
> Syncthing v0.10 will however not receive further updates.

I guess only v0.11 will get the fix

---

<div class="post-metadata">

### Author: ![calmh](https://forum.syncthing.net/user_avatar/forum.syncthing.net/calmh/32/15311_2.png) [@calmh](https://forum.syncthing.net/u/calmh)
#### Post date: [April 16, 2015, 12:25pm UTC](https://forum.syncthing.net/t/tips-on-how-to-make-upnp-work/2436/13 "2015-04-16T12:25:46Z")

</div>

> [@marcelpaulo](#):
>
> the router takes around 10s to reply to the SDDP search requests

That’s one lazy router… 😁

---

<div class="post-metadata">

### Author: ![system](https://forum-uploads.syncthingcdn.net/original/2X/0/0b50e0a202b22ae6a67190759e8c868805b8ed9f.png) [@system](https://forum.syncthing.net/u/system)
#### Post date: [May 12, 2017, 12:58pm UTC](https://forum.syncthing.net/t/tips-on-how-to-make-upnp-work/2436/14 "2017-05-12T12:58:16Z")

</div>


