Ejemplo n.º 1
0
 private void btnClearDns_Click(object sender, EventArgs e)
 {
     UpdateCurrentDNSLabelValues(new[] { "(Waiting)", "(Waiting)" });
     NetworkManagement.SetNameservers(CurrentNic, null, restart: true);
     tbDns01.Text = tbDns02.Text = "";
     RefreshDNSValues();
 }
Ejemplo n.º 2
0
        private void btnApplyDns_Click(object sender, EventArgs e)
        {
            string dns01 = tbDns01.Text?.Trim();

            if (!string.IsNullOrWhiteSpace(dns01) && !IsValidIPv4(dns01))
            {
                MessageBox.Show(this, "DNS 1 is not a valid IPv4 address", "Invalid IPv4", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            string dns02 = tbDns02.Text?.Trim();

            if (!string.IsNullOrWhiteSpace(dns02) && !IsValidIPv4(dns02))
            {
                MessageBox.Show(this, "DNS 2 is not a valid IPv4 address", "Invalid IPv4", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            UpdateCurrentDNSLabelValues(new[] { "(Waiting)", "(Waiting)" });
            NetworkManagement.SetNameservers(CurrentNic, new[] { dns01, dns02 }, restart: true);
            RefreshDNSValues();
        }