【问题标题】:Set from static IP to DHCP on Windows 8 using command line [closed]使用命令行在 Windows 8 上从静态 IP 设置为 DHCP [关闭]
【发布时间】:2015-11-21 20:42:26
【问题描述】:

我的电脑是 Windows 8。 我使用命令行设置静态IP地址

netsh interface ipv4 set address name="Wired Ethernet Connection" source=static address=1.1.1.1 mask=1.1.1.1 gateway=1.1.1.1

和静态 DNS 由

netsh interface ipv4 add dnsserver name="Wired Ethernet Connection" address=1.1.1.1 index=1

其中 1.1.1.1 在这两种情况下都只是为了演示,并被我的真实 IP 所取代。

编辑:截至 2018 年,1.1.1.1 现在用作 DNS 服务器。


我现在想从静态 IP 更改为 DHCP。

我试过了

netsh interface ipv4 set address name="Wired Ethernet Connection" source=dhcp

对于 IP 和

netsh interface ipv4 set dnsservers name="Wired Ethernet Connection" source=dhcp

用于 DNS。

但是,只有 DNS 的命令有效。


然后我检查了

ipconfig /all

它告诉我以太网的 DHCP 已启用。不过我之前的IP还在。

有没有办法在命令行中从静态设置为 DHCP?

【问题讨论】:

    标签: windows dhcp static-ip-address


    【解决方案1】:
    netsh interface ipv4 set address name="Wired Ethernet Connection" source=dhcp
    ipconfig /renew Wired*
    

    如果上面的ipconfig /renew命令不起作用,试试

    netsh interface set interface name="Wired Ethernet Connection" admin=DISABLED
    netsh interface ipv4 set address name="Wired Ethernet Connection" source=dhcp
    netsh interface set interface name="Wired Ethernet Connection" admin=ENABLED
    

    但是,也许从dhcp 获得的所有addressmaskgateway 都可以匹配之前由source=static 定义的那些。
    ipconfig /ALL 输出中是否显示 Lease ObtainedLease Expires 属性?

    【讨论】:

    • 我在上面试过你的命令,但拔掉电源后它们不起作用。 (插入时,它们工作。)没有插入时我有什么办法吗?还是我必须插入才能设置这些命令?
    • 未插入的接口无法访问dhcp 服务器,因此它会丢失所有租用的属性... 重新插入后应续订租约,无需手动 干预。
    【解决方案2】:

    适用于 Windows 10

    netsh interface ip set address "Ethernet" static 10.10.10.11 255.255.255.0
    
    netsh interface ip set address "Ethernet" source=dhcp
    

    【讨论】:

      【解决方案3】:

      这是因为您没有为该特定接口插入电缆。所以尝试将电缆插入接口并再次运行命令。

      netsh interface ipv4 set address name="有线以太网连接" source=dhcp

      它对我有用。

      【讨论】:

        猜你喜欢
        • 2010-10-10
        • 2020-03-02
        • 2012-09-25
        • 1970-01-01
        • 2015-10-14
        • 2020-08-04
        • 2021-12-24
        • 2013-04-03
        • 2020-06-09
        相关资源
        最近更新 更多