netsh 更改DNS的问题

Audit 2007-06-22 09:43:04
有这样一个需求,由于程序需要,需要各用户的DNS地址设为我们想要的202.**.**.**

想用netsh命令编写一个bat来实现....

先把IP属性输出出来
C:\>netsh interface dump -c >c:\network.txt

#========================
# 接口配置
#========================
pushd interface

reset all


popd
# 接口配置结束

#========================
# 接口配置
#========================
pushd interface ipv6

uninstall


popd
# 接口配置结束



# ----------------------------------
# ISATAP 配置
# ----------------------------------
pushd interface ipv6 isatap



popd
# ISATAP 配置结束



# ----------------------------------
# 6to4 配置
# ----------------------------------
pushd interface ipv6 6to4

reset



popd
# 6to4 配置结束

#=============
# 端口代理配置
#=============
pushd interface portproxy

reset


popd
# 端口代理配置结束



# ----------------------------------
# 接口 IP 配置
# ----------------------------------
pushd interface ip


# "VMware Network Adapter VMnet8" 的接口 IP 配置

set address name="VMware Network Adapter VMnet8" source=static addr=192.168.5.1 mask=255.255.255.0
set dns name="VMware Network Adapter VMnet8" source=static addr=none register=PRIMARY
set wins name="VMware Network Adapter VMnet8" source=static addr=none

# "VMware Network Adapter VMnet1" 的接口 IP 配置

set address name="VMware Network Adapter VMnet1" source=static addr=192.168.126.1 mask=255.255.255.0
set dns name="VMware Network Adapter VMnet1" source=static addr=none register=PRIMARY
set wins name="VMware Network Adapter VMnet1" source=static addr=none

# "本地连接" 的接口 IP 配置

set address name="本地连接" source=dhcp
set dns name="本地连接" source=static addr=202.96.64.68 register=PRIMARY
add dns name="本地连接" addr=202.96.75.68 index=2
set wins name="本地连接" source=dhcp


popd
# 接口 IP 配置结束



问题出来了...我只想换他们的DNS地址....

这样需要用户手工去修改这个输出来的文件....现实情况是不可能的.....

有什么办法只去修改客户端的DNS属性吗??/自动的...批处理或小程序都可以......如果不输出来这个文件,根本获知不了客户端的网络链接叫什么名字...netsh是靠#本地连接 来实现的知道哪块网卡的.....




...全文
935 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
andyzgx1 2007-06-22
  • 打赏
  • 举报
回复
另外,问题又来了!就算有这样的工具,也不知道你到底要修改 N=多少的那个本地连接啊。
andyzgx1 2007-06-22
  • 打赏
  • 举报
回复
那真不好办!到baidu找下看看有什么软件可以自动识别“本地连接N”的批量更改DNS的工具吧!
Audit 2007-06-22
  • 打赏
  • 举报
回复
列位大爷的计算机水平..我属实不改恭维...

能不能知道啥叫"网上邻居"都是个事~~~
andyzgx1 2007-06-22
  • 打赏
  • 举报
回复
你发封邮件通知全世界!叫他们自己去网络邻居那里自己改好了!
Audit 2007-06-22
  • 打赏
  • 举报
回复
哥们您没理解我的意思....

换dhcp不现实.所以才想这么解决...


我的意思是我要发一个bat下去....我解决不了人家的本地连接叫什么名字的问题....

我也不能先看一眼人家本地连接是几.然后

netsh int ip set dns 本地连接N static xxx.xxx.xxx.xxx primary 再把程序发给他呀....
andyzgx1 2007-06-22
  • 打赏
  • 举报
回复
netsh int ip set dns 本地连接3 static xxx.xxx.xxx.xxx primary
量大可以做DHCP上分配!
Audit 2007-06-22
  • 打赏
  • 举报
回复
netsh int ip set dns 本地连接 static xxx.xxx.xxx.xxx primary

举例:

如果人家的网卡叫

本地连接3咋办....

换dns的规模较大.预计有4000~5000台pc
learn_forever 2007-06-22
  • 打赏
  • 举报
回复
up
Audit 2007-06-22
  • 打赏
  • 举报
回复
up
andyzgx1 2007-06-22
  • 打赏
  • 举报
回复
netsh int ip set dns 本地连接 static xxx.xxx.xxx.xxx primary
andyzgx1 2007-06-22
  • 打赏
  • 举报
回复
如果多网卡,有本地连接1、本地连接2。这样区分的!
Audit 2007-06-22
  • 打赏
  • 举报
回复
......

6,185

社区成员

发帖
与我相关
我的任务
社区描述
windows网络管理与配置
社区管理员
  • 网络管理与配置社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧