tag:blogger.com,1999:blog-2516515388142486814.post3935741789633651770..comments2023-09-13T07:21:12.291-07:00Comments on Mumblestiltskin: Windows: Add multiple DNS servers to NIC (netSh)Unknownnoreply@blogger.comBlogger9125tag:blogger.com,1999:blog-2516515388142486814.post-13487918447619765812022-02-12T14:30:36.110-08:002022-02-12T14:30:36.110-08:00DnsDnsAnonymoushttps://www.blogger.com/profile/15863776076146800396noreply@blogger.comtag:blogger.com,1999:blog-2516515388142486814.post-19925200403576598362013-11-06T01:36:18.180-08:002013-11-06T01:36:18.180-08:00Steve, if you're still having this problem wit...Steve, if you're still having this problem with my example make sure you have an up carrot "^" before the pipe "|". Batch will interpret the pipe as a pipe instead of a character if not preceded with the "^".Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-2516515388142486814.post-8192595171336145312013-07-11T01:42:33.042-07:002013-07-11T01:42:33.042-07:00'Local Area Connection' is the name of all...'Local Area Connection' is the name of all my nics across all my servers. Ive tried running this on my xp machine, win7 and 2008 r2. Servers are Win2k3 or Win2k8r2Steve Francehttps://www.blogger.com/profile/09421332976933866090noreply@blogger.comtag:blogger.com,1999:blog-2516515388142486814.post-80478793617853127682013-07-11T01:40:10.211-07:002013-07-11T01:40:10.211-07:00Hi
Neither of these work for me for some reason?
...Hi<br />Neither of these work for me for some reason?<br /><br /><br />C:\pstools\Change DNS>(<br />IF !Index! EQU 1 (Netsh interface ip set dns name="!vAdaptername!" source="static" addr="10.133.34.30" )<br /> IF !Index! GTR 1 (Netsh interface ip add dns name="!vAdaptername!" addr="10.133.34.30" index=!Index! )<br /> SET /A Index=!Index!+1<br />)<br /><br />Invalid interface Local Area Connection specified.<br /><br /><br />C:\pstools\Change DNS>(<br />IF !Index! EQU 1 (Netsh interface ip set dns name="!vAdaptername!" source="static" addr="10.133.48.30" )<br /> IF !Index! GTR 1 (Netsh interface ip add dns name="!vAdaptername!" addr="10.133.48.30" index=!Index! )<br /> SET /A Index=!Index!+1<br />)<br /><br />Invalid interface Local Area Connection specified.<br /><br /><br />On the second example set by Skuzzy, I get the following error<br /><br />C:\pstools\Change DNS>autosetdns2.bat<br />| was unexpected at this time.<br />C:\pstools\Change DNS><br /><br />Can someone explain why?<br />thanksSteve Francehttps://www.blogger.com/profile/09421332976933866090noreply@blogger.comtag:blogger.com,1999:blog-2516515388142486814.post-91033654621491626262011-08-23T16:01:06.512-07:002011-08-23T16:01:06.512-07:00Nice Skuzzy, thanks for the comment. I like that a...Nice Skuzzy, thanks for the comment. I like that a lot... :o)<br /><br />Thanks for the heads up on the wmic, had not seen that before... just always used psexec... will look into that some more.Allanhttps://www.blogger.com/profile/01348010564037769760noreply@blogger.comtag:blogger.com,1999:blog-2516515388142486814.post-33221982066112960792011-08-23T14:31:53.009-07:002011-08-23T14:31:53.009-07:00Here it is:
:: Sets the primary and alternate DNS...Here it is:<br /><br />:: Sets the primary and alternate DNS for IPv4 on Windows Server 2000/2003/2008 & Windows XP/Vista/7<br />@ECHO OFF<br />SETLOCAL EnableDelayedExpansion<br /><br />SET adapterName=<br /><br />FOR /F "tokens=* delims=:" %%a IN ('IPCONFIG ^| FIND /I "ETHERNET ADAPTER"') DO (<br /> SET adapterName=%%a<br /> <br /> REM Removes "Ethernet adapter" from the front of the adapter name<br /> SET adapterName=!adapterName:~17!<br /> <br /> REM Removes the colon from the end of the adapter name<br /> SET adapterName=!adapterName:~0,-1!<br /> <br /> netsh interface ip set dns name="!adapterName!" static x.x.x.x primary<br /> netsh interface ip add dns name="!adapterName!" x.x.x.x index=2<br />)<br /><br />ipconfig /flushdns<br /><br />:EOFskuzzyhttps://www.blogger.com/profile/13382017326331309819noreply@blogger.comtag:blogger.com,1999:blog-2516515388142486814.post-42482998663470750012011-08-23T12:47:03.954-07:002011-08-23T12:47:03.954-07:00I found the best way to accomplish this without kn...I found the best way to accomplish this without knowing the adapter name upfront is to use IPCONFIG and FIND. Example: IPCONFIG | FIND /I "Ethernet adapter".<br /><br />An example output would be:<br />Ethernet adapter Local Area Connection:<br />Ethernet adapter Local Are Connection #2:<br />Ethernet adapter ManuallyRenamedLANC:<br /><br />Then use a FOR loop while using ":" as the delimiter. Since "Ethernet adapter" is a fixed size for all outputs you just have to remove those characters from each string. I will reply with a finished script when I do it. This task was just assigned to me. <br /><br />A side note, if you are using Windows 7/Vista/Server 2008 then you can use WMIC /NODE:%REMOTECOMPUTER% process call "%call%" instead of PSEXEC. WMIC is native and requires no Sysinternals download.skuzzyhttps://www.blogger.com/profile/13382017326331309819noreply@blogger.comtag:blogger.com,1999:blog-2516515388142486814.post-21997156334512219722011-06-18T05:16:51.181-07:002011-06-18T05:16:51.181-07:00I have been away so have only just picked this up....I have been away so have only just picked this up.<br /><br />The Netsh command relies on knowing the adapter name, I don't believe you can just do a wildcard and apply to all.<br /><br />Quickly thinking, you may be able to list out all the adapters and dump into a list which you can use, but this will take some scripting to achieve. This list could then be used for <br />SET AdapterNames=..... <br /><br />If you have managed to sort this out already then I would be interested in your solution.Allanhttps://www.blogger.com/profile/01348010564037769760noreply@blogger.comtag:blogger.com,1999:blog-2516515388142486814.post-804659788847204862011-06-12T19:27:23.455-07:002011-06-12T19:27:23.455-07:00hi.. i'm working at campus, we give wifi free ...hi.. i'm working at campus, we give wifi free to student and sudenly virus spead and became rouge dhcp pointing dns to its own (after changing dns setting).<br /><br />and idea to make a script to change all adapter dns setting in winxp and win7 to our official dns? <br />is it= "%ALL%" or "%*%" ?<br />thanks.. if u mind, pelase send to my mail: sabriptm@yahoo.comnomorehttps://www.blogger.com/profile/04303982214950467048noreply@blogger.com