I am having hard time doing this and i’m not good when it comes to scripting, I have seen/copied some tips on this forum but I am getting error in bigfix action script saying unknown command. does anyone have a working script for changing dns that I can test or use? Thanks appreciate any help.
I have tried SystemAdmin’s post, but I get unknown command in the actionscript on the registry part of the task in bigfix.
Relevance:
(name of operating system as lowercase =
"winxp" OR name of operating system as lowercase =
"winvista" OR name of operating system as lowercase =
"win7") AND not (exists addresses whose (it as string =
"208.67.222.222") of dns servers of network AND exists addresses whose (it as string =
"208.67.220.220") of dns servers of network)
Action:
// Change DNS Server // regset
"[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters]"
"NameServer"=
"208.67.222.222 208.67.220.220" regset
"[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters]"
"DhcpNameServer"=
"208.67.222.222 208.67.220.220"
// Script 1 if Vista or Win7 //
if
{(name of operating system =
"WinVista") or (name of operating system =
"Win7")
} delete __createfile createfile until END_CREATE @echo off netsh
interface ip add dnsserver
"{name of connection whose (status of it = (connection status connected)) of network}" 208.67.222.222 netsh
interface ip add dnsserver
"{friendly name of adapters whose (cidr string of it = wake on lan subnet cidr string) of network}" 208.67.222.222 ipconfig /flushdns END_CREATE delete dns1.bat move __createfile dns1.bat runhidden dns1.bat endif
// Script 2 for everyone and WinXP // delete __createfile createfile until END_CREATE @echo off netsh
interface ip add dnsserver
"local" 208.67.222.222 index=1 netsh
interface ip add dnsserver
"local" 208.67.220.220 index=2 netsh
interface ip add dnsserver
"Local Area Connection" 208.67.222.222 index=1 netsh
interface ip add dnsserver
"Local Area Connection" 208.67.220.220 index=2 netsh
interface ip add dnsserver
"Local Area Connection 1" 208.67.222.222 index=1 netsh
interface ip add dnsserver
"Local Area Connection 1" 208.67.220.220 index=2 netsh
interface ip add dnsserver
"Local Area Connection 2" 208.67.222.222 index=1 netsh
interface ip add dnsserver
"Local Area Connection 2" 208.67.220.220 index=2 netsh
interface ip add dnsserver
"Wireless Network Connection" 208.67.222.222 index=1 netsh
interface ip add dnsserver
"Wireless Network Connection" 208.67.220.220 index=2 ipconfig /flushdns END_CREATE
// Run script delete dns2.bat move __createfile dns2.bat runhidden dns2.bat
// Change DNS Server //
regset "[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters]" "NameServer"="208.67.222.222 208.67.220.220"
regset "[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters]" "DhcpNameServer"="208.67.222.222 208.67.220.220"
// Script 1 if Vista or Win7 //
if {(name of operating system = "WinVista") or (name of operating system = "Win7")}
delete _createfile
createfile until ENDCREATE
@echo off
netsh interface ip add dnsserver "{name of connection whose (status of it = (connection status connected)) of network}" 208.67.222.222
netsh interface ip add dnsserver "{friendly name of adapters whose (cidr string of it = wake on lan subnet cidr string) of network}" 208.67.222.222
ipconfig /flushdns
END_CREATE
delete dns1.bat
move __createfile dns1.bat
runhidden dns1.bat
endif
// Script 2 for everyone and WinXP //
delete _createfile
createfile until ENDCREATE
@echo off
netsh interface ip add dnsserver "local" 208.67.222.222 index=1
netsh interface ip add dnsserver "local" 208.67.220.220 index=2
netsh interface ip add dnsserver "Local Area Connection" 208.67.222.222 index=1
netsh interface ip add dnsserver "Local Area Connection" 208.67.220.220 index=2
netsh interface ip add dnsserver "Local Area Connection 1" 208.67.222.222 index=1
netsh interface ip add dnsserver "Local Area Connection 1" 208.67.220.220 index=2
netsh interface ip add dnsserver "Local Area Connection 2" 208.67.222.222 index=1
netsh interface ip add dnsserver "Local Area Connection 2" 208.67.220.220 index=2
netsh interface ip add dnsserver "Wireless Network Connection" 208.67.222.222 index=1
netsh interface ip add dnsserver "Wireless Network Connection" 208.67.220.220 index=2
ipconfig /flushdns
END_CREATE
// Run script
delete dns2.bat
move __createfile dns2.bat
runhidden dns2.bat
Sir ( @strawgate ), I followed the script that you gave to me, I didn’t got an unknown command prompt but I got an error status when I deployed it. Is there something missing with the way I deployed it?
Also, I wouldn’t recommend blindly using that script without validating what it does and how it does it on the command line before trying to deploy it through BigFix. It makes some assumptions about the names of the networks instead of querying them dynamically and it tries to set them on a bunch of differently named networks even if they don’t exist. In general it might not do what you need depending on your situation.
my goal is to deploy/change dns ip addresses to workstations, actually the one that I screenshot was from my lab test account. I have read that there is a possibility that bigfix can do it, instead of changing it manually per workstations.
It definitely can do it, it is just a matter of figuring out what the correct commands are to make the changes needed.
The script you referenced seemed to be for setting DNS to OpenDNS specifically.
Which OSes are you trying to do this for? Windows 7 or later?
I haven’t really ever done this before, so I’d look for microsoft documentation on how to do this for the targeted OS. I’d also use relevance to dynamically target only the connections that actually exist on the target computer instead of the blunt force approach in the existing script.
For OS Windows 7 or later, but I’m currently testing it first for Windows 7. I think the relevance is quiet correct but something in the command line seems not working, I’ll just try to figure it out for the moment. Thanks for sharing your ideas on this matter Sir jgstew. Happy New Year!
Do you want to replace all DNS settings for all connections so that they all use OpenDNS only or another DNS?
Do you want to append DNS servers to the list of DNS servers the machine is using?
Do you want to put the new DNS servers at the top of the list, but keep the existing servers that may already configured at the bottom of the list?
It may be important to make a distinction between computers configured statically normally, those configured statically that are a special case, and those using DHCP.
Related Relevance:
This should be the name of the network that needs changed: ( Examples are from Win10 )
Q: names of connections of networks
A: Ethernet
T: 52.708 ms
.
Q: addresses of dns servers of networks
A: 192.168.1.1
T: 19.102 ms
Your answers are a bit contradictory, but it sounds like you want to put a new set of DNS servers at the top of the list of currently configured DNS servers for endpoints, but retain the current set of DNS servers at the bottom of the list, instead of just entirely replacing the DNS servers configured.
This is definitely more complicated than the example script will do, though possible.