Skip to content

Windows: Changing The Name Server at the Command-Line

Still recovering from the server crash, but here’s a useful thing.

When I brought up dhcpd on my new server, I set its name server option to my ISP’s name server.  I hadn’t had time to set up a local DNS cache, and that was good enough to get web browsing working.

Last night I restored the VPN connection that bridges my network to my principal client’s, and set up a DNS cache so I could resolve names from their internal DNS servers — they use the bogus TLD .internal, so all their machines resolve as host.client.internal.  I tested pinging and browsing to their internal machines, and it was fine.

Today I tried to connect to their internal CVS server and my Windows machine couldn’t see it.

Error connecting to host cvs.client.internal: No such host is known.
cvs [update aborted]: Connection to server failed

It turns out that my Windows box still had the ISP’s name server, even though I had updated the dhcpd config, restarted the dhcpd server, and renewed my IP lease. I didn’t want to do a release/renew because I was streaming movies off that machine for the kids downstairs.

Luckily it turns out to be easy to set the name server on the command-line without disrupting your network connectivity:

netsh interface ip set dns "Local Area Connection" static 192.168.0.200

Setting parameters through netsh requires administrative privilege, so I had to start a new Cygwin and run it as adminstrator.  Minor annoyance.  (Where’s Cygwin’s version of sudo?)