Originally posted on: http://geekswithblogs.net/Plumbersmate/archive/2020/02/02/setting-dns-server-addresses-with-control-panel-and-powershell.aspx
In my test environment, which isn't optimally configured, new installations can't find the domain as they are not pointing to the domain's DNS. Instead they default to the hub which forwards all DNS requests to the Default Gateway and the Internet.
I can fix this on a case-by-case basis through the Control Panel:
- Go to 'Control Panel \ Network and Internet \ Network Connections'
- Right-click the network adapter and choose 'Properties'
- Select "Internet Protocol version 4 (TCP/IPv4) and click 'Properties'
- On the General tab, select "Use the following DNS server addresses:"
- For "Preferred DNS server:", enter the IP address of the DNS machine for the test domain
- For "Alternate DNS server:", enter the IP address of the Internet router
- Click 'OK', then 'Close'
Alternatively, if there is no Desktop Experience (i.e. Core) then the following Powershell command will do the same thing:
Set-DNSClientServerAddress –interfaceIndex 15 –ServerAddresses (“192.168.0.1”,”10.0.0.2”)
You may need to find the interface index first with Get-NetIPInterface:
ifIndex InterfaceAlias AddressFamily NlMtu(Bytes) InterfaceMetric Dhcp ConnectionState PolicyStore
------- -------------- ------------- ------------ --------------- ---- --------------- -----------
1 Loopback Pseudo-Interface 1 IPv4 4294967295 75 Disabled Connected ActiveStore
45 Local Area Connection* 27 IPv4 1500 25 Disabled Disconnected ActiveStore
32 Ethernet 8 IPv4 1500 5 Enabled Disconnected ActiveStore
23 Bluetooth Network Connection 7 IPv4 1500 65 Enabled Disconnected ActiveStore
15 WiFi IPv4 1500 50 Enabled Connected ActiveStore
------- -------------- ------------- ------------ --------------- ---- --------------- -----------
1 Loopback Pseudo-Interface 1 IPv4 4294967295 75 Disabled Connected ActiveStore
45 Local Area Connection* 27 IPv4 1500 25 Disabled Disconnected ActiveStore
32 Ethernet 8 IPv4 1500 5 Enabled Disconnected ActiveStore
23 Bluetooth Network Connection 7 IPv4 1500 65 Enabled Disconnected ActiveStore
15 WiFi IPv4 1500 50 Enabled Connected ActiveStore
References