IP White List VB NET

0

I want to know how to do, that my program to be opened from a IP that is already in the code, can be, and if it is not the same IP , that can not. The part that can be and is not easy, but the variable of ip type

if ip = (X) then form1.show

do not do it.

    
asked by felixAntonio 21.05.2018 в 21:56
source

1 answer

0

What kind of application is it? depending on that you have many options. For example, if it is Web, you can probably capture the IP that makes the request from the Request (although this can be done from the IIS).

Now if it is from Console or from Desktop or WPF you can capture the Local IP and with that do your validation. Something like this:

public static string GetLocalIPAddress()
{
    var host = Dns.GetHostEntry(Dns.GetHostName());
    foreach (var ip in host.AddressList)
    {
        if (ip.AddressFamily == AddressFamily.InterNetwork)
        {
            return ip.ToString();
        }
    }
    throw new Exception("No network adapters with an IPv4 address in the system!");
} 

if (GetLocalIPAddress() == "ipPermitida") 
  //TODO Lo que quieras hacer
    
answered by 21.05.2018 в 23:04