首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >通过CMD/注册表禁用IPv4

通过CMD/注册表禁用IPv4
EN

Stack Overflow用户
提问于 2012-08-06 15:44:44
回答 2查看 1.8K关注 0票数 2

我正在用Java编写一个程序(只适用于Windows ),它创建了PPPoE连接(并不是很重要)。重要的是,我需要在局域网选项卡中禁用IPv4。

问题http://img228.imageshack.us/img228/3253/4dcb10eb731a403e9fc785e.png

(其使用捷克语)

我需要在ceratin网络适配器中以某种方式“取消”IPv4协议。我可以通过CMD和netsh工具设置很多东西,但我无法为单个适配器禁用IPv4协议。我知道如何禁用整个计算机的IPv4,但这对我不起作用(因为我需要IPv4通信,只是通过不同的渠道)。我知道如何通过“取消”IPv6 (我在互联网上找到了它),但是对于IPv4来说也不起作用。

任何帮助都将不胜感激。

我需要达到的结果(从程序上)

结果http://img35.imageshack.us/img35/8459/bfebacf3b9bb428c84dee44.png

PS:请不要问我为什么用Java制作Windows专用的应用程序.

EN

回答 2

Stack Overflow用户

发布于 2012-08-06 20:59:12

请参阅Microsoft示例代码这里

您将希望用ms_tcpip6替换对ms_tcpip的引用,您可能需要进行一些实验,以确定如何确定正确的适配器。这个附加的代码片段可能会有所帮助,它属于内部循环:

代码语言:javascript
运行
复制
        [...]
        while (hr == S_OK) 
        {
            LPWSTR lpszPathToken;
            hr = pncbp->GetPathToken(&lpszPathToken);
            if (hr != S_OK) fail(hr);
            wprintf(L"Path token: %s\n", lpszPathToken);

            // Get owner

            INetCfgComponent *owner;
            LPWSTR lpszOwner;

            hr = pncbp->GetOwner(&owner);
            if (hr != S_OK) fail(hr);

            hr = owner->GetId(&lpszOwner);
            if (hr != S_OK) fail(hr);

            wprintf(L"Path owner: %s\n", lpszOwner);
            // Disable this binding.

            hr = pncbp->Enable(ENABLE);
            [...]

希望路径令牌或路径所有者将为您提供标识正确适配器所需的信息。

票数 3
EN

Stack Overflow用户

发布于 2013-05-09 23:27:42

检查此工具:https://gallery.technet.microsoft.com/Hyper-V-Network-VSP-Bind-cf937850

代码语言:javascript
运行
复制
nvspbind is a tool for modifying network bindings from the command line. It is especially useful in Server Core environments with the Hyper-V role enabled.

It can be used to set the correct bindings for NICs used in Virtual Networks.

It can also be used to enable or disable specific bindings on any NIC and to query and change the NIC connection order.

It utilizes the INetCfg APIs documented on MSDN (http://msdn.microsoft.com/en-us/library/ms805265.aspx).

Most options are documented in the readme and nvpsbind.txt which download with the install.

To get help run “nvspbind.exe /?”
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11831567

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档