Detect Lan Connection

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
#1
No computer connected to the Internet, or any other TCP/IP compliant network, can identify itself as 127.0.0.1

Thus;

echo %@if[%_ip eq 127.0.0.1,0,1]

function IsLan=`%@if[%_ip eq 127.0.0.1,0,1]`

echo %@IsLan[]

If @IsLan[] returns a 0, then you have no Lan connection.

If @IsLan[] returns a 1, then you have a Lan connection.

You can test this by issuing the IPCONFIG /release command to release the IP address for your adapter, and the IPCONFIG /renew command to renew the IP address for your adapter. (tested on XP).

Joe