• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Windows 2000/XP command line DNS settings?

Xuttah

Member
I've looked at Microsoft's site and searched Google. Does anyone know if DNS settings can be set via the command line in W2K and/or WinXP Pro? The ipconfig documentation doesn't list any DNS options.

Thanks!
 
I don't know of any built in tool to adjust dns settings from the command line. You could throw something together if you *really* needed this capability. Curious, what are you trying to do?
Bill
 
I'd like to set my laptop up to access work-specific resources while at work, and home resources while at home, and I'd like to create a simple batch file with the commands to acheive it. I can set my routes and gateway just fine, but DNS is the missing piece. I'd like to avoid having to manually adjust each setting every day.

BTW, I'm simplifying this quite a bit to avoid a lengthy explanation. Home is straight DHCP, but work is what is complicated.

Thanks

 


<< I've looked at Microsoft's site and searched Google. Does anyone know if DNS settings can be set via the command line in W2K and/or WinXP Pro? The ipconfig documentation doesn't list any DNS options.

Thanks!
>>



Xuttah,

This probably won't help you much, but you can flush and reregister dns settings at the command prompt. This is useful if say you have NATing and the name of the internal machine is the same as the external machine.

In other words,

Inside the network you type

"nslookup nameA.domainA.com"&nbsp&nbspand you get&nbsp&nbsp"XXX.XXX.XXX.XXX"

Outside the network you type

"nslookup nameA.domainA.com"&nbsp&nbspand you get&nbsp&nbsp"YYY.YYY.YYY.YYY"

That way moving from inside the network to outside the network and back again screws up your settings because you keep searching for the same machine and keep getting different IP addresses.

To solve this, I typed the following two commands at my prompt and it solved the problem,

ipconfig /flushdns
ipconfig /registerdns

I know this works for Windows 2000 and not for Windows 98 or Windows 95. Unfortunately, I have no idea about Windows XP.
 
Is work non dhcp? If so, you might be able to use the 'alternate tcp/ip' configuration that XP supports. The way it works is that you configure XP to use DHCP (for home), if a DHCP server can't be found it will use the alternate settings (you can specify ip/mask/gw/dns there).

Of course if works has dhcp too, this won't work (but brings up the question why you can't take the work dhcp defaults).

Best,
Bill
 

Garet Jax,

That's a great thing to remember, and I appreciate your response. But I want to be able to set my resolvers in cmd line, not necessarily refresh domain lookups. At work, the resolvers for one network do not resolve addresses on the other network, so I must change my resolvers when I need to access resources on one network or the other.

But your tip sounds like something that will help in the future.
 
bsobel,

I have two possible gateways I can use at work. There are mutually exclusive resources behind each gateway. I do receive a DHCP address, but in order to access resources behind each gateway simultaneously, I have my laptop set with static routes, and have a DNS resolver from each network as my primary/secondary so I can access both networks simultaneously. However, if I want to connect to my LAN at home, I set everything back to DHCP.

I just want to be able to write a batch file I can execute to set my routes, gateway, and DNS resolvers, rather than do it manually each time.

Thanks
 
I don't know the answer to your question.

but could this possibly be done by using two different users? or two different connections that use the same nic?
 
DNS settings are kind-of TCP/IP settings, but they're not NIC centric.
Anyway, why don't you do a registry export of the DNS settings when you've got it set up in each of your environments. Then, in your batch file, just call the appropriate .reg file.
 
Yes!! Woodie you da man. That's a great idea. Rather than mess with finding command line parameters, it would be just as easy to actually set values in the registry.

Thanks!!
 
Except you'll find (I believe) the registry values won't take affect until you reboot, which I presumed your trying to avoid...
Bill
 
use the netsh command
I have a .bat file I made to use at work, it sets the ip according to machine name and dns settings, pretty cool.
Email me and I will send it to you so I don't forget, cause AT forums are banned at work 🙁

Here it is, found it:
*********
echo
netsh interface ip set address "Local Area Connection" static 192.168.0.8 255.255.255.0 192.168.0.1 1
add dns "Local Area Connection" 200.100.100.1
add dns "Local Area Connection" 200.100.100.2
netsh exit
*********

Adjust accordingly
 
One of the great improvements under W2K was that network changes take effect immediately, without the need to reboot (like NT 4, Win9x, etc...). I tested the batch file today. It runs on bootup and works great. I also set up easy Start-menu icons to move back and forth as needed.

I'd never heard of the netsh command or it's parameters. I'll be playing around with that as well. Thanks for the help!
 
I just found this thread, otherwise I would have posted sooner 🙂

I've been using NetSwitcher to toggle between the LAN at my college and my cable modem at home. Works instantly (without rebooting), and you can script it to do all kinds of other stuff when you change locations as well - like mounting servers, changing your e-mail profile, default printers, etc. etc...

It works great on W2K as well.

Good luck!
 
Back
Top