Today I went bug hunting to find out why UPNP and Apple's Back to my Mac are not working if put together...
First of all:
I have a Routerboard RB450G that is running the latest RouterOS 5.0beta4.
Setup is the following:
- Routerboard 450G is configured as the main NAT (Masquerading) router for my small network. IP: 192.168.0.1
- My computer connects directly to the Routerboard over Ethernet. IP: 192.168.0.102
My UPNP settings are the following:
[admin@MikroTik] /ip upnp> print
enabled: yes
allow-disable-external-interface: no
show-dummy-rule: yes
I tried several different program that forward ports through UPNP and/or NAT-PMP. All worked fine except for the Back to my Mac service, which constantly tells me, that my router doesn't support UPNP (yeah, sure ^^).
I tried everything that can be found on the internet to make it work (like the post just above this one), but Back to my Mac and RouterOS just do not want to play together.
This damn incompatibility bugged me so much, that i figured to start up Wireshark and look a bit deeper.
I tried to forward a port with 3 different programs to see where the difference is:
With first two programs a get what a expect. A nice success response to the port forwarding request.
Transmission:
===REQUEST===
POST /upnp/control/wanipconn-7 HTTP/1.0
Host: 192.168.0.1:2828
User-Agent: Darwin/10.4.0, UPnP/1.0, MiniUPnPc/1.4
Content-Length: 606
Content-Type: text/xml
SOAPAction: "urn:schemas-upnp-org:service:WANIPConnection:1#AddPortMapping"
Connection: Close
Cache-Control: no-cache
Pragma: no-cache
<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:AddPortMapping xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1"><NewRemoteHost></NewRemoteHost><NewExternalPort>51417</NewExternalPort><NewProtocol>TCP</NewProtocol><NewInternalPort>51417</NewInternalPort><NewInternalClient>192.168.0.102</NewInternalClient><NewEnabled>1</NewEnabled><NewPortMappingDescription>Transmission at 51417</NewPortMappingDescription><NewLeaseDuration>0</NewLeaseDuration></u:AddPortMapping></s:Body></s:Envelope>
===RESPONSE===
HTTP/1.1 200 OK
CONTENT-LENGTH: 282
CONTENT-TYPE: text/xml; charset="utf-8"
DATE: Tue, 13 Jul 2010 15:08:31 GMT
EXT:
SERVER: RouterOS/5.0beta4UPnP/1.0 MikroTik UPnP/1.0
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<u:AddPortMappingResponse xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1"></u:AddPortMappingResponse>
</s:Body>
</s:Envelope>
Portmap:
===REQUEST===
POST /upnp/control/wanipconn-7 HTTP/1.1
Host: 192.168.0.1:2828
User-Agent: POSIX, UPnP/1.0, miniUPnPc/1.0
Content-Length: 614
Content-Type: text/xml
SOAPAction: "urn:schemas-upnp-org:service:WANIPConnection:1#AddPortMapping"
Connection: Close
Cache-Control: no-cache
Pragma: no-cache
<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><m:AddPortMapping xmlns:m="urn:schemas-upnp-org:service:WANIPConnection:1"><NewRemoteHost></NewRemoteHost><NewExternalPort>12345</NewExternalPort><NewProtocol>TCP</NewProtocol><NewInternalPort>12345</NewInternalPort><NewInternalClient>192.168.0.102</NewInternalClient><NewEnabled>1</NewEnabled><NewPortMappingDescription>cPM.Port.Map.925d7518fc597af0</NewPortMappingDescription><NewLeaseDuration>0</NewLeaseDuration></m:AddPortMapping></s:Body></s:Envelope>
===RESPONSE===
HTTP/1.1 200 OK
CONTENT-LENGTH: 282
CONTENT-TYPE: text/xml; charset="utf-8"
DATE: Tue, 13 Jul 2010 15:09:48 GMT
EXT:
SERVER: RouterOS/5.0beta4UPnP/1.0 MikroTik UPnP/1.0
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<u:AddPortMappingResponse xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1"></u:AddPortMappingResponse>
</s:Body>
</s:Envelope>
But when I try to do the same thing with Apple's Back to my Mac service, I get NOTHING.
Back to my Mac:
===REQUEST===
POST /upnp/control/wanipconn-7 HTTP/1.1
Content-Type: text/xml; charset="utf-8"
SOAPAction: "urn:schemas-upnp-org:service:WANIPConnection:1#DeletePortMapping"
User-Agent: Mozilla/4.0 (compatible; UPnP/1.0; Windows 9x)
Host: 192.168.0.1:2828
Content-Length: 604
Connection: close
Pragma: no-cache
<?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><m:DeletePortMapping xmlns:m="urn:schemas-upnp-org:service:WANIPConnection:1"><NewRemoteHost xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="string"></NewRemoteHost><NewExternalPort xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="ui2">4500</NewExternalPort><NewProtocol xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="string">UDP</NewProtocol></m:DeletePortMapping></SOAP-ENV:Body></SOAP-ENV:Envelope>
===RESPONSE===
No error message, nothing! Only an empty packet as response:
84 6.360812 192.168.0.1 192.168.0.102 TCP itm-lm > 63728 [ACK] Seq=1 Ack=913 Win=7616 Len=0 TSV=480186 TSER=464120379
0000 58 b0 35 f5 8b a4 00 0c 42 3e 8f be 08 00 45 00 X.5.....B>....E.
0010 00 34 51 e9 40 00 40 06 67 23 c0 a8 00 01 c0 a8 .4Q.@.@.g#......
0020 00 66 0b 0c f8 f0 10 fe 02 53 f2 09 ac 58 80 10 .f.......S...X..
0030 01 dc e3 d2 00 00 01 01 08 0a 00 07 53 ba 1b a9 ............S...
0040 ea 3b .;
Shouldn't there be at least some sort of response and/or error message? (like defined in 2.4.16.1 of
http://upnp.org/specs/gw/UPnP-gw-WANIPC ... ervice.pdf)
The only really visible difference in these 3 requests is that apple uses XML namespaces and attributes more extensively than the other 2 programs.
For example
<NewExternalPort xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="ui2">4500</NewExternalPort>
instead of the much simpler form that the other 2 programs use
<NewExternalPort>12345</NewExternalPort>
This shouldn't pose a problem since the XML requests are all at least wellformed (it didn't validate them against the XSD, but a guess they are valid too), but could it be that RouterOS has a problem while parsing these XML requests?
I hope my information get's this bug fixed soon, because I really want to this feature and Apple's Back to my Mac won't be the only UPNP implementation that has problems with RouterOS.
Best regards,
Martin (aka maruchinu)
PS: I can supply the Wireshark files that I captured, but I don't want to post them publicly since they could contain other sensitive traffic/information.