Mono.Nat icon indicating copy to clipboard operation
Mono.Nat copied to clipboard

Router as mesh repeater returns empty external IP

Open PhilKlae opened this issue 4 years ago • 1 comments

I use a router to expand my mesh, like a switch, and GetExternalIPAsync did throw "System.FormatException: An invalid IP address was specified". The string provided by the router was empty like this: uPnP Response: , <?xml version="1.0" encoding="utf-8"?> <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <s:Body> <u:GetExternalIPAddressResponse xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1"> <NewExternalIPAddress></NewExternalIPAddress> </u:GetExternalIPAddressResponse> </s:Body> </s:Envelope> I caught the exception so no big deal, was unsure if this is expected behavior though.

Great piece of code!

PhilKlae avatar Jan 19 '21 15:01 PhilKlae

Hrm, i suspect this is because upnp is still enabled on the router and it's returning an empty IP address because it doesn't have an actual WAN connection. Can you check if that is the case? If so, the best solution would be to disable upnp on this, or put it in bridge mode if it supports that concept. I suspect any ports forwarded on this device would not be helpful as this device is not connected to your WAN.

Apart from that, i can probably handle this edge case a bit better. I could probably raise a different exception type or something.

alanmcgovern avatar Jan 21 '21 20:01 alanmcgovern