I'm trying to find a way to get my router to report back my WAN IP using UPnP/SSDP, but so far I have been unable to even get a list of UPnP supporting internet access devices on my network. Here's the request I'm sending:
$ cat request.txt
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
MAN: "ssdp:discover"
MX: 3
ST: urn:schemas-upnp-org:device:InternetGatewayDevice:1
With the command:
$ nc -uvv 239.255.255.250 1900 < request.txt
Connection to 239.255.255.250 1900 port [udp/ssdp] succeeded!
I just get the connnection succeded message and then nothing...
Could anyone give me any pointers (no memory addresses please!) as to what I'm doing wrong?
Update: Ok so I tried using tcpdump
to get responses here's what I got:
$ sudo tcpdump -vv -A -s 0 -i en1 udp port 1900 and host 239.255.255.250
…
NOTIFY * HTTP/1.1
Host: 239.255.255.250:1900
Cache-Control: max-age=60
Location: http://192.168.1.1:1780/InternetGatewayDevice.xml
NTS: ssdp:alive
Server: POSIX, UPnP/1.0 linux/5.100.104.2
NT: urn:schemas-upnp-org:device:InternetGatewayDevice:1
…
I guess the next step is to parse the output of tcpdump and filter out all responses that don't contain the NT: urn:schemas-upnp-org:device:InternetGatewayDevice:1
header then make the actual SOAP request to the router.