DOS add IP

xiaoxiao2021-03-30  210

First, add IP addresses and default gateways (add, reset or update the original IP, please see the third point)

Netsh Interface IP Add Address

Usage: add address [name =] [[addr =] ip address [mask =] ip subnet mask]

[[Gateway =] IP Address [gwmetric =] integer]

Parameters:

Name - IP interface name.

Addr - To add an IP address to this interface.

Mask - Specifies the IP subnet mask of the IP address.

Gateway - Specifies the default gateway for the IP address.

GWMETRIC - The number of hops of the default gateway.

Note: Add IP addresses to an interface configured with a static IP address and

Default gateway.

Example:

Add Address "Local Area Connection" 10.0.0.2 255.0.0.0

Add Address "Local Area Connection" GATEWAY = 10.0.0.3 GWMETRIC = 2

The first command adds a static IP address 10.0.0.2, subnet mask to the local connection interface.

It is 255.0.0.0.0. The second command adds IP addresses to interfaces of gateway hop number 2

10.0.0.3 As the second default gateway.

My instance:

(1) Netsh Interface IP Add Address "LocalConnection" 172.20.0.49 255.255.252.0

This command sets the LocalConnection IP 172.20.0.49, the subnet mask is 255.255.252.0

(2)

C: /> Netsh Interface IP Add Address "LocalConnection" Gateway = 172.20.0.254 GWMETRIC = 1

This command sets the default gateway of LocalConnection to 172.20.0.254, the number of hops of the default gateway is 1

Second, add DNS

NETSH INTERFACE IP Add DNS?

Usage: add dns [name =] [addr =] [[index =] integer]

Parameters:

Tag value

Name - Add the name of the interface of the DNS server.

Addr - The IP address of the added DNS server.

INDEX - address for the specified DNS server

Specify an index (preference).

Description: Static adds a new DNS server IP address or reinterprets a list of existing DNS server addresses to modify the DNS server preferences.

E.g :

Add DNS "Local Area Connection" 10.0.0.1

Add DNS "Local Area Connection" 10.0.0.3 INDEX = 2

My instance:

Netsh Interface IP Add DNS "LocalConnection" 172.20.0.1

Netsh Interface IP Add DNS "LocalConnection" 202.96.128.68 index = 2

Third, set the IP address, default gateway and DNS:

Netsh Interface IP Set Address Local Static 172.20.0.49 255.255.252.0 Sets IP and subnet mask

Netsh Interface IP Set Address Local Static Gateway = 172.20.0.254 GWMETRIC = 1

(set address name = "localconnection" Source = DHCP This article represents IP from DHCP Server to Netsh Interface IP Set DNS "LocalConnection" static 172.20.0.1

(SET DNS Name = "localconnection" Source = DHCP)

Fourth, comprehensive case

Netsh Interface IP Set Address Local Static 172.20.0.49 255.255.252.0

Netsh Interface IP Set Address Local Static Gateway = 172.20.0.254 GWMETRIC = 1

Netsh Interface IP Set DNS "LocalConnection" static 172.20.0.1

Netsh Interface IP Add DNS "LocalConnection" 202.96.128.68 index = 2

The above command is made into batch:

Edit setip.bat

NETSH Interface IP Set Address Local Static% 2 255.255.252.0

Netsh Interface IP Set Address Local Static Gateway = 172.20.0.254 GWMETRIC = 1

Netsh Interface IP SET DNS "% 1" static 172.20.0.1

Netsh Interface IP Add DNS "% 1" 202.96.128.68 INDEX = 2

Setip.bat command usage is:

SETIP network interface name IP address

E.g:

Setip localconnection 172.20.0.49

转载请注明原文地址:https://www.9cbs.com/read-130576.html

New Post(0)