How to detect an ip is wan ip or lan ip?

How to detect an ip is wan ip or lan ip?

Postby ShumingWang » Mon Nov 08, 2010 3:28 am

Hello!
How to or What function can detect an ip is wan ip or lan ip in fwh/harbour ?
Best regards!
Shuming Wang
http://www.xtech2.top
Mobile:(86)13802729058
Email:100200651@qq.com
QQ:100200651
Weixin: qq100200651
ShumingWang
 
Posts: 465
Joined: Sun Oct 30, 2005 6:37 am
Location: Guangzhou(Canton),China

Re: How to detect an ip is wan ip or lan ip?

Postby anserkk » Mon Nov 08, 2010 4:39 am

The Internet Assigned Numbers Authority (IANA) has reserved the following three blocks of the IP address space for private internets (local networks):

10.0.0.0 - 10.255.255.255
172.16.0.0 - 172.31.255.255
192.168.0.0 - 192.168.255.255

Also, IP addresses in the range of 169.254.0.0 -169.254.255.255 are reserved for Automatic Private IP Addressing.

These IP's should not be used on the Internet.

If you know the above range of IP's, you can easily write a function to grab your system's IP and then compare whether the IP address of your system falls in any of the above given three IP ranges or not. If it belongs to the above given IP blocks, it is a private/LAN IP else it is a WAN IP.

Regards
Anser
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: How to detect an ip is wan ip or lan ip?

Postby ShumingWang » Mon Nov 08, 2010 7:33 am

If Mysql server running on windows , select substring_index(user(),_utf8'@',-1) returns windows computer name instead of ip.
While Mysql on linux, select substring_index(user(),_utf8'@',-1) returns ip, like 'myserver','001',...
Shuming Wang
http://www.xtech2.top
Mobile:(86)13802729058
Email:100200651@qq.com
QQ:100200651
Weixin: qq100200651
ShumingWang
 
Posts: 465
Joined: Sun Oct 30, 2005 6:37 am
Location: Guangzhou(Canton),China


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], nageswaragunupudi and 26 guests