windows 将网络适配器设置更改为 DHCP
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5533975/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Change Network Adapter Setting to DHCP
提问by BZink
I'm trying to write a few short scripts with netsh. One to change an adapter to static addressing and one to change the same adapter back to DHCP.
我正在尝试用 netsh 编写一些简短的脚本。一种是将适配器更改为静态寻址,另一种是将同一适配器更改回 DHCP。
I can get the adapter set with all of the correct static address settings with
我可以使用所有正确的静态地址设置来设置适配器
netsh interface ip set address "Local Area Connection" static 10.61.1.253 255.255.255.0 10.61.1.1 1
This works fine. When I run the following command (a script) to switch back to DHCP I get an error message.
这工作正常。当我运行以下命令(脚本)切换回 DHCP 时,我收到一条错误消息。
netsh interface ip set address "Local Area Connection" dhcp
DHCP is already enabled on this interface.
此接口已启用 DHCP。
This is on a Windows 7 machine.
这是在 Windows 7 机器上。
Any idea what the problem is?
知道问题是什么吗?
回答by Joe Kidd
It took me a while of "?" in the command to figure this one out as I had the same issue, but here is the syntax that worked for me in Windows 7: netsh interface ip set address name="Local Area connection" source=dhcp
我花了一段时间“?” 在命令中解决这个问题,因为我遇到了同样的问题,但这里是在 Windows 7 中对我有用的语法:netsh interface ip set address name="Local Area connection" source=dhcp
回答by user3893318
I had a similar problem with Windows 7. I found that if the link is down on the interface you are trying to modify, you get the message "DHCP is already enabled on this interface." If you plug a cable in (establish a link), the same command works fine.
我在 Windows 7 上遇到了类似的问题。我发现如果您尝试修改的接口上的链接断开,您会收到消息“此接口上已启用 DHCP”。如果插入电缆(建立链接),则相同的命令可以正常工作。