// Handles the whole task of making sure the NICs are still
    // set to the correct settings once they have been initially set
    public static bool EnsureNICsState(IP_CHOICES Choice)
    {
        try
        {
            // Handles first run and all that
            SaveCurNICSettings();

            List<NetworkInterface> ResetNICs = TestNICs(Choice);

            // Reset the offenders
            foreach (NetworkInterface NIC in ResetNICs)
            {
                switch (Choice)
                {
                    case IP_CHOICES.DEFAULT:
                        SetDNSDefault(NIC);
                        break;
                    case IP_CHOICES.LOCALHOST:
                        SetDNSProxy(NIC);
                        break;
                    case IP_CHOICES.OPENDNS:
                        SetDNSOpenDNS(NIC);
                        break;
                }
            }
        }
        catch (Exception Ex)
        {
            string sMsg = Ex.Message;
            return false;
        }

        return true;
    }
    static void SetNICs(IP_CHOICES Choice)
    {
        NetworkInterface[] NICs = NetworkInterface.GetAllNetworkInterfaces();
        foreach (NetworkInterface NIC in NICs)
        {
            // Only full NICs we care about
            if (!IsReceiveOnly(NIC))
            {
                IPInterfaceProperties IPProps   = NIC.GetIPProperties();
                IPAddressCollection   ipCollDNS = IPProps.DnsAddresses;

                foreach (IPAddress Addr in ipCollDNS)
                {
                    switch (Choice)
                    {
                    case IP_CHOICES.DEFAULT:
                        SetDNSDefault(NIC);
                        break;

                    case IP_CHOICES.LOCALHOST:
                        SetDNSProxy(NIC);
                        break;

                    case IP_CHOICES.OPENDNS:
                        SetDNSOpenDNS(NIC);
                        break;

                    case IP_CHOICES.FORCE_AUTO:
                        ForceDNSDefault(NIC);
                        break;
                    }
                }
            }
        }
    }
    // Tests all NICs for current DNS settings, and returns a list not matching
    // the input state
    static List <NetworkInterface> TestNICs(IP_CHOICES Choice)
    {
        List <NetworkInterface> ResetNICs = new List <NetworkInterface>();

        NetworkInterface[] NICs = NetworkInterface.GetAllNetworkInterfaces();
        foreach (NetworkInterface NIC in NICs)
        {
            // Only full NICs we care about
            if (!IsReceiveOnly(NIC))
            {
                IPInterfaceProperties IPProps   = NIC.GetIPProperties();
                IPAddressCollection   ipCollDNS = IPProps.DnsAddresses;

                if (NIC.OperationalStatus != OperationalStatus.Up)
                {
                    continue;
                }

                foreach (IPAddress Addr in ipCollDNS)
                {
                    if (Addr.AddressFamily == System.Net.Sockets.AddressFamily.InterNetworkV6)
                    {
                        continue;
                    }

                    switch (Choice)
                    {
                    case IP_CHOICES.DEFAULT:

                        if (Addr.ToString() != "")
                        {
                            ResetNICs.Add(NIC);
                        }
                        break;

                    case IP_CHOICES.LOCALHOST:

                        if (Addr.ToString() != "127.0.0.1")
                        {
                            ResetNICs.Add(NIC);
                        }

                        break;

                    case IP_CHOICES.OPENDNS:

                        if ((Addr.ToString() != "208.67.220.220") && (Addr.ToString() != "208.67.222.222"))
                        {
                            ResetNICs.Add(NIC);
                        }

                        break;
                    }
                }
            }
        }

        return(ResetNICs);
    }
    // Sets every NIC possible to point to the DNS server of our choice
    public static bool SetDNSServer(IP_CHOICES Choice)
    {
        try
        {
            SetNICs(Choice);
        }
        catch (Exception Ex)
        {
            string sMsg = Ex.Message;
            return(false);
        }

        return(true);
    }
    // Sets every NIC possible to point to the DNS server of our choice
    public static bool SetDNSServer(IP_CHOICES Choice)
    {
        try
        {
            SetNICs(Choice);
        }
        catch (Exception Ex)
        {
            string sMsg = Ex.Message;
            return false;
        }

        return true;
    }
    // Handles the whole task of making sure the NICs are still
    // set to the correct settings once they have been initially set
    public static bool EnsureNICsState(IP_CHOICES Choice)
    {
        try
        {
            // Handles first run and all that
            SaveCurNICSettings();

            List <NetworkInterface> ResetNICs = TestNICs(Choice);

            // Reset the offenders
            foreach (NetworkInterface NIC in ResetNICs)
            {
                switch (Choice)
                {
                case IP_CHOICES.DEFAULT:
                    SetDNSDefault(NIC);
                    break;

                case IP_CHOICES.LOCALHOST:
                    SetDNSProxy(NIC);
                    break;

                case IP_CHOICES.OPENDNS:
                    SetDNSOpenDNS(NIC);
                    break;
                }
            }
        }
        catch (Exception Ex)
        {
            string sMsg = Ex.Message;
            return(false);
        }

        return(true);
    }
    // Tests all NICs for current DNS settings, and returns a list not matching
    // the input state
    static List<NetworkInterface> TestNICs(IP_CHOICES Choice)
    {
        List<NetworkInterface> ResetNICs = new List<NetworkInterface>();
        NetworkInterface[] NICs = NetworkInterface.GetAllNetworkInterfaces();
        foreach (NetworkInterface NIC in NICs)
        {
            // Only full NICs we care about
            if (!IsReceiveOnly(NIC))
            {
                IPInterfaceProperties IPProps = NIC.GetIPProperties();
                IPAddressCollection ipCollDNS = IPProps.DnsAddresses;

                if (NIC.OperationalStatus != OperationalStatus.Up)
                    continue;

                foreach (IPAddress Addr in ipCollDNS)
                {
                    if (Addr.AddressFamily == System.Net.Sockets.AddressFamily.InterNetworkV6)
                        continue;

                    switch (Choice)
                    {
                        case IP_CHOICES.DEFAULT:

                            if (Addr.ToString() != "")
                            {
                                ResetNICs.Add(NIC);
                            }
                            break;

                        case IP_CHOICES.LOCALHOST:

                            if (Addr.ToString() != "127.0.0.1")
                            {
                                ResetNICs.Add(NIC);
                            }

                            break;

                        case IP_CHOICES.OPENDNS:

                            if ((Addr.ToString() != "208.67.220.220") && (Addr.ToString() != "208.67.222.222"))
                            {
                                ResetNICs.Add(NIC);
                            }

                            break;
                    }
                }

            }
        }

        return ResetNICs;
    }
    static void SetNICs(IP_CHOICES Choice)
    {
        NetworkInterface[] NICs = NetworkInterface.GetAllNetworkInterfaces();
        foreach (NetworkInterface NIC in NICs)
        {
            // Only full NICs we care about
            if (!IsReceiveOnly(NIC))
            {
                IPInterfaceProperties IPProps = NIC.GetIPProperties();
                IPAddressCollection ipCollDNS = IPProps.DnsAddresses;

                foreach (IPAddress Addr in ipCollDNS)
                {
                    switch (Choice)
                    {
                        case IP_CHOICES.DEFAULT:
                            SetDNSDefault(NIC);
                            break;

                        case IP_CHOICES.LOCALHOST:
                            SetDNSProxy(NIC);
                            break;

                        case IP_CHOICES.OPENDNS:
                            SetDNSOpenDNS(NIC);
                            break;

                        case IP_CHOICES.FORCE_AUTO:
                            ForceDNSDefault(NIC);
                            break;
                    }
                }

            }
        }
    }