Windows to modify the IP detailed explanation with the command line, with the approval file

xiaoxiao2021-03-06  21

Since I am going to switch between different networks, such as local area networks, internal networks and external networks (光 光 网 I want to switch between 3 ADSLs). The method I have always used is to set the IP of multiple different network segments on this machine, then switch the route (route), such a different network segment passes through different gateways, can achieve the purpose of simultaneous accessing multiple networks. But I found that some problems can often occur, so I decided to solve the most original way, that is, just use the IP of this network segment when you use a network segment, so you need to replace the IP address. . Of course, this change in Windows "Network Connection" attribute is very troublesome, but it is ok, the Windows "Netsh" command provides the command line to change the IP function, use this, you can make it Batch batch files are more convenient. The following is the specific method and command detailed: first enter the command prompt line: "Win R"> "cmd", enter the Enter Netsh, Enter, Enter, Enter the interface, Enter, Netsh Interface> IP, Enter, Netsh Interface IP> Enter IP settings, we need to use the following command: set address - Add an IP address to the specified interface. First look at the Windows Help for this order: ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ---------------------------------- Usage: set address [name =] [[Source =] DHCP | [Source =] static [addr =] ip address [mask =] ip subnet mask] [[Gateway =] | none [gwmetric =] integer]

parameter:

Tag value Name - interface name. Source - One of the following: DHCP: For the specified interface, set the IP address with DHCP. Static: Sets the settings of the IP address using the local static configuration.

Gateway - One of the following: : Specify the default gateway for your IP address. None: Do not set the default gateway. GWMETRIC - The number of hops of the default gateway. If the gateway is set to 'None', this field should not be set. Only set the following options only when 'Source' is 'Static':

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

Note: Used to change the IP address configuration mode from DHCP mode to static, or change from Static mode to DHCP. Add the IP address on the interface with a static IP address, or add the default gateway. Example:

Set address name = "local area connection" Source = DHCP set address local static 10.0.0.9 255.0.0.0 10.0.0.1 1 ------------------------ -------------------------------------------------- - After understanding the usage, we can set it: Enter the set address "Local Connection" Static 192.168.4.23 255.255.255.192 192.168.4.1 1 After Netsh Interface IP> Static 192.168.4.23 255.255.255.4.23 255.255.255.192 192.168.4.1 and then carriage return, will show "OK" later, IP setting is complete. Here, "local connection" refers to the name of the connection seen in Windows "Network Properties". Static means that you want to specify static IP instead of DHCP assignment, the three are IP, subnet mask, gateway, last "1" refers to the number of hops of the default gateway, generally "1". At this point, IP is set to the command line. At the same time, you can also change the DNS settings in the command line, use the Set DNS command, you can enter the SET DNS /? View how to use the usage method. Finally, we save these commands as a BAT file (setip192168423.bat): @ echo offrem eth // Eth is the NIC name, you can query in a network connection, such as "local connection" set eth = "local connection" REM IP / / ip IPSet IP = 192.168.4.23Rem GW // GW for you want to change to the gateway address set gw = 192.168.4.1Rem Netmasks // Netmasks for the subnet mask set netmasks = 255.255.255.192echo is changing this unit IP change To:% IP% Remif% GW% == None Netsh Interface IP Set Address% ETH% Static% IP%% Netmasks%% GW%> Nulif Not% GW% == None Netsh Interface IP Set Address% ETH% Static% IP %% Netmasks%% GW% 1> nulecto ....................... Echo Check the current native IP: ipconfigecho ....... ................ Echo successfully changed the native IP to% ip%! Pauseclose

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

New Post(0)