Home > Batch Scripting, Scripting, Windows Server > Setting Dns entries on network properties from remote.

Setting Dns entries on network properties from remote.

Tricky one recently where the server wasnt responding to RDP… the DNS entries on this webserver were incorrect and it couldnt lookup its connection to an oracle database.

I connected over psexec, and used netsh to dump the current configuration.

  • netsh  interface  ip  dump

this command should give you an output similar to below:

# ———————————-
# Interface IP Configuration
# ———————————-
pushd interface ip

# Interface IP Configuration for “Local Area Connection 5″

set address name=”Local Area Connection 5″ source=static addr=192.168.1.20 mask
=255.255.255.0
set address name=”Local Area Connection 5″ gateway=192.168.1.1 gwmetric=0
set dns name=”Local Area Connection 5″ source=static addr=192.168.1.115 register=PRIMARY
add dns name=”Local Area Connection 5” addr=192.168.1.116 index=2
popd
# End of interface IP configuration

looking at the above,

To set the primary server the command would be:

netsh interface ip set dns name=”Local Area Connection 5″ source=static addr=192.168.1.115 register=PRIMARY

and to set the secondary:

netsh interface ip add dns name=”Local Area Connection 5″ addr=192.168.1.116 index=2

you can set more than two if you like using the above command and incrementing the “index” by one.

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: