Let us consider there are two networks 1) home network and 2) office network.

I have an application which will get the system IP and MAC Address of the installed machine while launching the application.

Since both the (home/office) are private networks, when I launch the application it will get the IP address within one of the below ranges of private IP's. through through through

My question is there any way to differentiate between home network and the office network while launching the application.

For example if I launch the application inside office network, my IP falls wih in the range through

And if I launch the application in home network my IP falls with in the range. through

If this is the configuration always, we can easily identify between home and office networks.

But there are possibilities the user can change his IP address to his office range while lauching within home network.

If that is the case how one can identify from which network the user's system IP came from?

Any help would be appreciated...


The easiest way would be, to check the DHCP servers MAC address (when you get the response from it).

If you need to take static IP addresses in consideration, you can check the MAC address of the default gateway.

Since MAC addresses should be (atleast in theory) globaly unique, there is a very low chance of having the same MAC address on the default gateway on both locations.

  • Thanks for your response. Since I am getting the IP address and MAC address of the machine where the application is installed. Are there any possibilities I can identify the DHCP servers MAC address?
    – satheesh91
    Feb 19 '14 at 8:24
  • This is also among the lines of what Windows does to identify networks. It always uses the default gateway's MAC address and sometimes the WIFI BSSID (or so it seems).
    – Daniel B
    Feb 19 '14 at 8:59

Depending on the network information tools available to you, and how the networks are set up..

Your network at work probably has a domain, which can help you identify it. If not, you can check the MAC address of the network's gateway. For example, on my WiFi right now, I have this:

[ .. extra info deleted for brevity .. ]
Default Gateway . . . . . . . . . :

(You might also use the DHCP server's IP (if any) instead of the gateway, but they are often one and the same..) From this, I can find the MAC of the gateway with:

c:\> arp -a
[ .. extra info deleted for brevity .. ]
Internet Address      Physical Address      Type           08-86-3b-06-ef-bd     dynamic

It's very unlikely that your home and work gateways will have the same MAC (Physical) address, so you can use this to identify each network you connect to.

Of course, I am guessing you want to be able to extract this information automatically, not having to manually type the commands every time you connect.. But that, again, will depend on the tools available to you (OS version, etc.). You might also search the web for command line tools others have wrote that does both the above in a single step and spits out just the gateway's MAC address (I might even write one myself if there are none already out there and others show interest..)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.