博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
如何快速将多个IP地址添加到Windows服务器
阅读量:2520 次
发布时间:2019-05-11

本文共 3237 字,大约阅读时间需要 10 分钟。

If you have ever added multiple IP addresses to a single Windows server, going through the graphical interface is an incredible pain as each IP must be added manually, each in a new dialog box. Here’s a simple solution.

如果您曾经将多个IP地址添加到单个Windows服务器,则通过图形界面非常麻烦,因为每个IP必须手动添加,每个IP地址都在一个新对话框中。 这是一个简单的解决方案。

image

Needless to say, this can be incredibly monotonous and time consuming if you are adding more than a few IP addresses. Thankfully, there is a much easier way which allows you to add an entire subnet (or more) in seconds.

不用说,如果要添加多个IP地址,这可能会非常单调且耗时。 值得庆幸的是,有一种更简单的方法可以让您在几秒钟内添加整个子网(或更多)。

从命令行添加IP地址 (Adding an IP Address from the Command Line)

Windows includes the “netsh” command which allows you to configure just about any aspect of your network connections. If you view the accepted parameters using “netsh /?” you will be presented with a list of commands each which have their own list of commands (and so on). For the purpose of adding IP addresses, we are interested in this string of parameters:

Windows包含“ netsh”命令,该命令使您几乎可以配置网络连接的任何方面。 如果使用“ netsh /?”查看接受的参数您将看到一个命令列表,每个命令都有自己的命令列表(依此类推)。 为了添加IP地址,我们对以下参数字符串感兴趣:

netsh interface ipv4 add address

netsh接口ipv4添加地址

Note: For Windows Server 2003/XP and earlier, “ipv4” should be replaced with just “ip” in the netsh command.

注意:对于Windows Server 2003 / XP和更早版本,在netsh命令中应仅将“ ipv4”替换为“ ip”。

If you view the help information, you can see the full list of accepted parameters but for the most part what you will be interested in is something like this:

如果查看帮助信息,则可以看到已接受参数的完整列表,但是在大多数情况下,您会感兴趣的是:

netsh interface ipv4 add address “Local Area Connection” 192.168.1.2 255.255.255.0

netsh接口ipv4添加地址“本地连接” 192.168.1.2 255.255.255.0

The above command adds the IP Address 192.168.1.2 (with Subnet Mask 255.255.255.0) to the connection titled “Local Area Network”.

上面的命令将IP地址192.168.1.2(带有子网掩码255.255.255.0)添加到名为“局域网”的连接中。

一次添加多个IP地址 (Adding Multiple IP Addresses at Once)

When we accompany a netsh command with the FOR /L loop, we can quickly add multiple IP addresses. The syntax for the FOR /L loop looks like this:

当netsh命令与FOR / L循环一起使用时,我们可以快速添加多个IP地址。 FOR / L循环的语法如下所示:

FOR /L %variable IN (start,step,end) DO command

FOR / L%variable IN(开始,步骤,结束)DO命令

So we could easily add every IP address from an entire subnet using this command:

因此,我们可以使用以下命令轻松地从整个子网中添加每个IP地址:

FOR /L %A IN (0,1,255) DO netsh interface ipv4 add address “Local Area Connection” 192.168.1.%A 255.255.255.0

FOR / L%A IN(0,1,255)做netsh接口ipv4添加地址“本地连接” 192.168.1。%A 255.255.255.0

This command takes about 20 seconds to run, where adding the same number of IP addresses manually would take significantly longer.

该命令运行大约需要20秒钟,而手动添加相同数量的IP地址将花费更长的时间。

快速演示 (A Quick Demonstration)

Here is the initial configuration on our network adapter:

这是我们的网络适配器上的初始配置:

ipconfig /all

ipconfig /全部

image

Now run netsh from within a FOR /L loop to add IP’s 192.168.1.10-20 to this adapter:

现在从FOR / L循环中运行netsh,将IP的192.168.1.10-20添加到此适配器:

FOR /L %A IN (10,1,20) DO netsh interface ipv4 add address “Local Area Connection” 192.168.1.%A 255.255.255.0

FOR / L%A IN(10,1,20)DO netsh接口ipv4添加地址“本地连接” 192.168.1。%A 255.255.255.0

After the above command is run, viewing the IP Configuration of the adapter now shows:

运行以上命令后,现在查看适配器的IP配置将显示:

image

翻译自:

转载地址:http://ozxwd.baihongyu.com/

你可能感兴趣的文章
矩阵分析-线性系统-4 病态系统(ill-conditioned Systems)与条件数(condtion number)
查看>>
MYSQL 安装&配置
查看>>
[POJ2478]Farey Sequence
查看>>
(四)单链接表算法之删除节点
查看>>
Servlet,GenericServlet和HttpServlet的继承关系
查看>>
[ActionScritp 3.0] 使用LocalConnection建立通信
查看>>
iOS软件代码规范
查看>>
分桶法和平方分割
查看>>
HDU 5514 题解
查看>>
Django和Python中的Timezone处理
查看>>
FIND_IN_SET()
查看>>
github高效搜索使用总结
查看>>
osg 基本几何图元
查看>>
tyvj 1305 —— 长度不超过m的最大连续和 【前缀和+单调队列】
查看>>
HDU -1213 How Many Tables
查看>>
关于CG Relighting系统设计的片言碎语
查看>>
shell脚本-传参方式
查看>>
配置本地SVN[转载]
查看>>
团队任务 3 每日立会
查看>>
Android——LayoutInflater详解
查看>>