I want to write a batch file to get the DNS numbers behind a router.

techs

New member
Member
Local time
12:58 PM
Messages
14
I do a lot of internet troubleshooting and would like to put a simple batch file in customers computers that will let me see their DNS numbers when they are using a router.
I currently do this from a command prompt for Comast:

nslookup
set type=ns
comcast.net

It's been years since I wrote a batch file and so I just put these lines in notepad and labeled it dns.bat

However, this just runs the first line, nslookup.
Is there a command that will cause each line to run after Windows has performed the line above?

Or, is there an easier way to do what I want to do?

Thanks in advance!
 

My Computer My Computer

At a glance

Windows 7 Professional 64bitIntel Clarkdale 3.2 Ghz4 Gb.On board Intel HD Graphics 2000
Computer Manufacturer/Model Number
Shop built
OS
Windows 7 Professional 64bit
CPU
Intel Clarkdale 3.2 Ghz
Motherboard
Biostar H55
Memory
4 Gb.
Graphics Card(s)
On board Intel HD Graphics 2000
Sound Card
On board Realtek
Monitor(s) Displays
Sony 52inch LCD
Screen Resolution
1920x1080
Hard Drives
Intel x25-m G2 SSD 80 Gb.
Western Digital 500 Gb. Black edtion
PSU
Antec Earthwatts 500
Case
Antec Sonata2
Cooling
Stock
Keyboard
Stock
Mouse
Stock
Internet Speed
16 Mbits
NSLookup itself pulls up the first server IP of the two servers I have listed.
Would it not be easier to simply open Network and Sharing Center, click Change Adapter Settings, right click on the Local Area Connection and select Properties, select IPv4, click properties?
Note I am using servers I manually entered in.
 

My Computer My Computer

At a glance

Windows 7 Ultimate x64 (Retail)Intel I7-860G.Skill RipJaw DDR3-1333 16GB (4x4GB)Nvidia GTS-250 1GB
Computer Manufacturer/Model Number
Personal build
OS
Windows 7 Ultimate x64 (Retail)
CPU
Intel I7-860
Motherboard
Asus Maximus III Formula
Memory
G.Skill RipJaw DDR3-1333 16GB (4x4GB)
Graphics Card(s)
Nvidia GTS-250 1GB
Sound Card
SupremeFX X-Fi 7.1 HD sound system.
Monitor(s) Displays
VisionQuest VQL-22WSHD LCD Monitor
Screen Resolution
1680x1050
Hard Drives
1x Seagate ST3500418AS 500G SATA2 HDD
1x Western Digital Caviar SE16 500G SATA2 HDD
1x Western Digital Caviar SE16 750G SATA2 HDD
2x Western Digital Caviar Green 2TB SATA2 HDD, configured RAID1
PSU
OCZ EliteXtream OCZ1000EXS 1000W ATX12V 20/24 Pin Active PFC
Case
Antec 1200
Cooling
Swifteck H2O-220 Ultima XT Liquid Cooling w/ 320 Radiator
Keyboard
Logitech G11 Keyboard
Mouse
Logitech MX518 Optical Mouse
Internet Speed
Cable Modem
Other Info
Visiontek TV Wonder 650 Theater PCI-E TV Tuner Card
Logitech 9000 Pro Web Camera
Logitech Cordless RumblePad 2 game controller
LG 18x SuperMulti SATA2 DVD Writer
NmediaPC CR98 Multi Card reader
Nmedia Pro-LCD
Corsair Dominator Memory Fan
Coolermaster R4-L2R-20ac 120mm Case Fan x2
Set Command

The set command is use to enter a value for a variable. There is no defined variable for "type" that I am aware of. The same goes for your third command listed in your post. Probably that is the problem.
 

My Computer My Computer

At a glance

win 7 X64 Ultimate SP1I3770KG Skill F3-14900CL9-4GBXL x 4NVIDIA GeForce GTX670 + Intel 4000
Computer Manufacturer/Model Number
BGC (Bob's Garage Crew)
OS
win 7 X64 Ultimate SP1
CPU
I3770K
Motherboard
Asus P8Z77-V Deluxe
Memory
G Skill F3-14900CL9-4GBXL x 4
Graphics Card(s)
NVIDIA GeForce GTX670 + Intel 4000
Sound Card
Realtek HD 5.1 (MOB)
Monitor(s) Displays
Asus VW224T (1)
Screen Resolution
1920 x 1080
Hard Drives
SATA Corsair Force GT 2.5" 180GB (System) Sata 3
OCZ Vertex3 120GB
OCZ Vertex 2 120GB 2.5" SATA II
ST31000524AS 1000.2GB
WD15EARS (External)
PSU
CoolerMaster 1000 Watt
Case
CoolerMaster HAF X
Cooling
CPU -- CoolerMaster 520N
Keyboard
MS Wireless 3000 V2
Mouse
MS Wireless 3000 V2
Internet Speed
Cable
Antivirus
Norton Internet Security
Browser
IE9
Other Info
AMI Bios 1805
OC'd 3%
NSLookup itself pulls up the first server IP of the two servers I have listed.
Would it not be easier to simply open Network and Sharing Center, click Change Adapter Settings, right click on the Local Area Connection and select Properties, select IPv4, click properties?
Note I am using servers I manually entered in.

It just gives me the ip of the router.
And in Adapter Settings I can't see the DNS numbers using DHCP.
 

My Computer My Computer

At a glance

Windows 7 Professional 64bitIntel Clarkdale 3.2 Ghz4 Gb.On board Intel HD Graphics 2000
Computer Manufacturer/Model Number
Shop built
OS
Windows 7 Professional 64bit
CPU
Intel Clarkdale 3.2 Ghz
Motherboard
Biostar H55
Memory
4 Gb.
Graphics Card(s)
On board Intel HD Graphics 2000
Sound Card
On board Realtek
Monitor(s) Displays
Sony 52inch LCD
Screen Resolution
1920x1080
Hard Drives
Intel x25-m G2 SSD 80 Gb.
Western Digital 500 Gb. Black edtion
PSU
Antec Earthwatts 500
Case
Antec Sonata2
Cooling
Stock
Keyboard
Stock
Mouse
Stock
Internet Speed
16 Mbits
The set command is use to enter a value for a variable. There is no defined variable for "type" that I am aware of. The same goes for your third command listed in your post. Probably that is the problem.
I see.

Any ideas on how to automate the whole procedure?
 

My Computer My Computer

At a glance

Windows 7 Professional 64bitIntel Clarkdale 3.2 Ghz4 Gb.On board Intel HD Graphics 2000
Computer Manufacturer/Model Number
Shop built
OS
Windows 7 Professional 64bit
CPU
Intel Clarkdale 3.2 Ghz
Motherboard
Biostar H55
Memory
4 Gb.
Graphics Card(s)
On board Intel HD Graphics 2000
Sound Card
On board Realtek
Monitor(s) Displays
Sony 52inch LCD
Screen Resolution
1920x1080
Hard Drives
Intel x25-m G2 SSD 80 Gb.
Western Digital 500 Gb. Black edtion
PSU
Antec Earthwatts 500
Case
Antec Sonata2
Cooling
Stock
Keyboard
Stock
Mouse
Stock
Internet Speed
16 Mbits
The set command is use to enter a value for a variable. There is no defined variable for "type" that I am aware of. The same goes for your third command listed in your post. Probably that is the problem.
I see.

Any ideas on how to automate the whole procedure?

@Hammerhead, using the 'set' command will create a variable with the value and stores it in volatile memory for the current console session. As soon as you close the console, the variable is cleared and forgotten ;)

@techs, try the command:
nslookup -type=ns comcast.net

For me, it returned:
Code:
Server:  [I]xxxxxxx[/I].aut.ac.nz
Address:  156.62.8.1

Non-authoritative answer:
comcast.net     nameserver = dns101.comcast.net
comcast.net     nameserver = dns103.comcast.net
comcast.net     nameserver = dns102.comcast.net
comcast.net     nameserver = dns105.comcast.net
comcast.net     nameserver = dns104.comcast.net

dns104.comcast.net      internet address = 68.87.68.244
dns104.comcast.net      AAAA IPv6 address = 2001:558:100a:5:68:87:68:244
dns101.comcast.net      internet address = 68.87.29.164
dns101.comcast.net      AAAA IPv6 address = 2001:558:1002:a:68:87:29:164
dns105.comcast.net      internet address = 68.87.72.244
dns105.comcast.net      AAAA IPv6 address = 2001:558:100e:5:68:87:72:244
dns103.comcast.net      internet address = 68.87.76.228
dns103.comcast.net      AAAA IPv6 address = 2001:558:1014:c:68:87:76:228
dns102.comcast.net      internet address = 68.87.85.132
dns102.comcast.net      AAAA IPv6 address = 2001:558:1004:7:68:87:85:132
 

My Computer My Computer

At a glance

Windows 7 EnterpriseIntel Pentium Dual E2200 @2.2GHz4GBPalit GForce 9500GT 1GB
OS
Windows 7 Enterprise
CPU
Intel Pentium Dual E2200 @2.2GHz
Motherboard
Gigabyte II-G31
Memory
4GB
Graphics Card(s)
Palit GForce 9500GT 1GB
Sound Card
onBoard
Hard Drives
WesternDigital: 250GB + 1TB + 1TB + 2TB
PSU
450W
Case
CoolerMaster CM690
Cooling
Corsair H50
Mouse
Logitech MX518
Good

Xarden:

Thanks for straightening me out.
 

My Computer My Computer

At a glance

win 7 X64 Ultimate SP1I3770KG Skill F3-14900CL9-4GBXL x 4NVIDIA GeForce GTX670 + Intel 4000
Computer Manufacturer/Model Number
BGC (Bob's Garage Crew)
OS
win 7 X64 Ultimate SP1
CPU
I3770K
Motherboard
Asus P8Z77-V Deluxe
Memory
G Skill F3-14900CL9-4GBXL x 4
Graphics Card(s)
NVIDIA GeForce GTX670 + Intel 4000
Sound Card
Realtek HD 5.1 (MOB)
Monitor(s) Displays
Asus VW224T (1)
Screen Resolution
1920 x 1080
Hard Drives
SATA Corsair Force GT 2.5" 180GB (System) Sata 3
OCZ Vertex3 120GB
OCZ Vertex 2 120GB 2.5" SATA II
ST31000524AS 1000.2GB
WD15EARS (External)
PSU
CoolerMaster 1000 Watt
Case
CoolerMaster HAF X
Cooling
CPU -- CoolerMaster 520N
Keyboard
MS Wireless 3000 V2
Mouse
MS Wireless 3000 V2
Internet Speed
Cable
Antivirus
Norton Internet Security
Browser
IE9
Other Info
AMI Bios 1805
OC'd 3%
No worries.
Furthermore, the 'setx' command does the same but stores it as a system environment variable. Which you can use in different sessions, or after reboots.
Just be careful that you dont overwrite an existing one, like 'path' for instance.


@Techs,
let us know how that goes for you.
 

My Computer My Computer

At a glance

Windows 7 EnterpriseIntel Pentium Dual E2200 @2.2GHz4GBPalit GForce 9500GT 1GB
OS
Windows 7 Enterprise
CPU
Intel Pentium Dual E2200 @2.2GHz
Motherboard
Gigabyte II-G31
Memory
4GB
Graphics Card(s)
Palit GForce 9500GT 1GB
Sound Card
onBoard
Hard Drives
WesternDigital: 250GB + 1TB + 1TB + 2TB
PSU
450W
Case
CoolerMaster CM690
Cooling
Corsair H50
Mouse
Logitech MX518
No worries.
Furthermore, the 'setx' command does the same but stores it as a system environment variable. Which you can use in different sessions, or after reboots.
Just be careful that you dont overwrite an existing one, like 'path' for instance.


@Techs,
let us know how that goes for you.
Just back from vacation.
I will test and let you know.
thanks!
 

My Computer My Computer

At a glance

Windows 7 Professional 64bitIntel Clarkdale 3.2 Ghz4 Gb.On board Intel HD Graphics 2000
Computer Manufacturer/Model Number
Shop built
OS
Windows 7 Professional 64bit
CPU
Intel Clarkdale 3.2 Ghz
Motherboard
Biostar H55
Memory
4 Gb.
Graphics Card(s)
On board Intel HD Graphics 2000
Sound Card
On board Realtek
Monitor(s) Displays
Sony 52inch LCD
Screen Resolution
1920x1080
Hard Drives
Intel x25-m G2 SSD 80 Gb.
Western Digital 500 Gb. Black edtion
PSU
Antec Earthwatts 500
Case
Antec Sonata2
Cooling
Stock
Keyboard
Stock
Mouse
Stock
Internet Speed
16 Mbits
I use OpenDNS and doing the following:

ipconfig /all | find "DNS Servers"

returns this:

DNS Servers . . . . . . . . . . . : 208.67.222.222
DNS Servers . . . . . . . . . . . : fec0:0:0:ffff::1%1
DNS Servers . . . . . . . . . . . : 208.67.222.222

It shows both the IPV4 and IPV6 DNS servers available to me.
 

My Computer My Computer

At a glance

Windows 10 Pro X64Intel Quad Core i7-4770 @ 3.4Ghz16.0GB PC3-12800 DDR3 SDRAM 1600 MHzIntel Integrated HD Graphics
Computer type
PC/Desktop
Computer Manufacturer/Model Number
Lenovo IdeaCenter 450
OS
Windows 10 Pro X64
CPU
Intel Quad Core i7-4770 @ 3.4Ghz
Memory
16.0GB PC3-12800 DDR3 SDRAM 1600 MHz
Graphics Card(s)
Intel Integrated HD Graphics
Sound Card
Realtek HD Audio
Monitor(s) Displays
HP 22" LCD
Screen Resolution
1680 x 1050
Hard Drives
250GB Samsung EVO SATA-3 SSD
2TB Seagate ST2000DM001 SATA-2
1.5TB Seagate ST3150041AS SATA
Keyboard
Dell USB
Mouse
Lenovo USB
Internet Speed
Cable via Road Runner 3MB Upload, 30MB Download
Antivirus
Windows Defender, MBAM Pro, MBAE
Browser
Seamonkey
Other Info
UEFI/GPT
PLDS DVD-RW DH16AERSH
Well, it doesn't seem to do what I want to do.
However, I would like to thank ALL of you for your interest and help.

Cheers.
 

My Computer My Computer

At a glance

Windows 7 Professional 64bitIntel Clarkdale 3.2 Ghz4 Gb.On board Intel HD Graphics 2000
Computer Manufacturer/Model Number
Shop built
OS
Windows 7 Professional 64bit
CPU
Intel Clarkdale 3.2 Ghz
Motherboard
Biostar H55
Memory
4 Gb.
Graphics Card(s)
On board Intel HD Graphics 2000
Sound Card
On board Realtek
Monitor(s) Displays
Sony 52inch LCD
Screen Resolution
1920x1080
Hard Drives
Intel x25-m G2 SSD 80 Gb.
Western Digital 500 Gb. Black edtion
PSU
Antec Earthwatts 500
Case
Antec Sonata2
Cooling
Stock
Keyboard
Stock
Mouse
Stock
Internet Speed
16 Mbits
You said you wanted an easy/automated way to get the DNS server addresses.

What exactly do you want. This is fun stuff so ask away:D

If you put this ina batch (.bat) file you can place a link to it on the Desktop:
Code:
cmd /k ipconfig /all | find "DNS Servers"

It will open a Command Prompt window with the result displayed for you.
 

My Computer My Computer

At a glance

Windows 10 Pro X64Intel Quad Core i7-4770 @ 3.4Ghz16.0GB PC3-12800 DDR3 SDRAM 1600 MHzIntel Integrated HD Graphics
Computer type
PC/Desktop
Computer Manufacturer/Model Number
Lenovo IdeaCenter 450
OS
Windows 10 Pro X64
CPU
Intel Quad Core i7-4770 @ 3.4Ghz
Memory
16.0GB PC3-12800 DDR3 SDRAM 1600 MHz
Graphics Card(s)
Intel Integrated HD Graphics
Sound Card
Realtek HD Audio
Monitor(s) Displays
HP 22" LCD
Screen Resolution
1680 x 1050
Hard Drives
250GB Samsung EVO SATA-3 SSD
2TB Seagate ST2000DM001 SATA-2
1.5TB Seagate ST3150041AS SATA
Keyboard
Dell USB
Mouse
Lenovo USB
Internet Speed
Cable via Road Runner 3MB Upload, 30MB Download
Antivirus
Windows Defender, MBAM Pro, MBAE
Browser
Seamonkey
Other Info
UEFI/GPT
PLDS DVD-RW DH16AERSH
You said you wanted an easy/automated way to get the DNS server addresses.

What exactly do you want. This is fun stuff so ask away:D

If you put this ina batch (.bat) file you can place a link to it on the Desktop:
Code:
cmd /k ipconfig /all | find "DNS Servers"

It will open a Command Prompt window with the result displayed for you.
That gives me the ip of the router, not the dns servers the router is using.

Yah, this is something I just wanted to play around with.

A few years ago I found it simple to just place a batch file on all my client computers, which basically did a release, renew for ipconfig. Saved some time with explaining to customers how to open a command prompt, which was the backslash key, etc.

I thought maybe I could do something with this.
 

My Computer My Computer

At a glance

Windows 7 Professional 64bitIntel Clarkdale 3.2 Ghz4 Gb.On board Intel HD Graphics 2000
Computer Manufacturer/Model Number
Shop built
OS
Windows 7 Professional 64bit
CPU
Intel Clarkdale 3.2 Ghz
Motherboard
Biostar H55
Memory
4 Gb.
Graphics Card(s)
On board Intel HD Graphics 2000
Sound Card
On board Realtek
Monitor(s) Displays
Sony 52inch LCD
Screen Resolution
1920x1080
Hard Drives
Intel x25-m G2 SSD 80 Gb.
Western Digital 500 Gb. Black edtion
PSU
Antec Earthwatts 500
Case
Antec Sonata2
Cooling
Stock
Keyboard
Stock
Mouse
Stock
Internet Speed
16 Mbits

My Computer My Computer

At a glance

Windows 10 Pro X64Intel Quad Core i7-4770 @ 3.4Ghz16.0GB PC3-12800 DDR3 SDRAM 1600 MHzIntel Integrated HD Graphics
Computer type
PC/Desktop
Computer Manufacturer/Model Number
Lenovo IdeaCenter 450
OS
Windows 10 Pro X64
CPU
Intel Quad Core i7-4770 @ 3.4Ghz
Memory
16.0GB PC3-12800 DDR3 SDRAM 1600 MHz
Graphics Card(s)
Intel Integrated HD Graphics
Sound Card
Realtek HD Audio
Monitor(s) Displays
HP 22" LCD
Screen Resolution
1680 x 1050
Hard Drives
250GB Samsung EVO SATA-3 SSD
2TB Seagate ST2000DM001 SATA-2
1.5TB Seagate ST3150041AS SATA
Keyboard
Dell USB
Mouse
Lenovo USB
Internet Speed
Cable via Road Runner 3MB Upload, 30MB Download
Antivirus
Windows Defender, MBAM Pro, MBAE
Browser
Seamonkey
Other Info
UEFI/GPT
PLDS DVD-RW DH16AERSH
Back
Top