开发者

Determine if IP Address is Cellular IP Address

开发者 https://www.devze.com 2022-12-26 08:32 出处:网络
In .NET Compact Framework a device can have several IP Addresses.I want to find one that is NOT coming from the Cellular connection. Goal is for WiFi or Ethernet connection.

In .NET Compact Framework a device can have several IP Addresses. I want to find one that is NOT coming from the Cellular connection. Goal is for WiFi or Ethernet connection.

Is there a way to do this?

Seems like State and Notificati开发者_高级运维on Broker would have a way to do this but didn't see a way.


Nope, you'll have to do it manually.

Obviously there's not an easy way for you to know which IPs belong to cell or not. The easiest way would be to grab the "ISP" IP database from maxmind.com - http://www.maxmind.com/app/isp - which will give you the name of the ISP for any IP address (well, most IP addresses). You would then just setup a regular expression matching keywords like "sprint", "verizon wireless", "cellular", etc, to determine if it's a cell phone IP or not.

Not the prettiest of funnest solution but I'm not aware of a better way.


Every operator has a group of IP addresses. If you know the network address of the operator you can compare the visitor's IP with operator's address.

So for example if you know the mobile operator owns a group of ip addresses starting with 212.235.*.*

you compare first 16 bits of the visitor's address with it, if for example the visitor's address is 212.235.190.215 you know it comes from mobile network.

You can check this condition with simple string operations - compare first x characters of visitor's ip address with x known characters at the beginning of operator's ip address.

0

精彩评论

暂无评论...
验证码 换一张
取 消