The netsh command solves the network switching problem. The netsh Command performs network switching.

Source: Internet
Author: User

The netsh command solves the network switching problem. The netsh Command performs network switching.

Many companies involve multiple network problems during their work. Frequent network switching involves frequent IP configuration.

First, take a look at the netsh command.

Netsh is a powerful built-in system command. If you can understand some common operations, the Administrator may sometimes have unexpected help. For example, my customers' systems have all made some strategies. Many operations must also be completed in the command line. The following describes several common functions. For other help files, refer to the netsh help file.
A) Enable Firewall
C: \> netsh firewall set opmode mode = enable
OK.
B. Disable the firewall.
C: \> netsh firewall set opmode mode = disable
OK.
C) reset the Firewall
C: \> netsh firewall reset
OK.
1. View network configurations
Netsh interface ip show {Option}
{Option} can be:
Address-the IP address Configuration is displayed.
Config-displays the IP address and more information.
Dns-displays the DNS server address.
Icmp-displays ICMP statistics.
Interface-displays IP interface statistics.
Ipaddress: displays the current IP address.
Ipnet-display the ing between the IP network and the media.
Ipstats-displays IP statistics.
Joins-displays the added multicast groups.
Offload: displays the unload information.
Tcpconn-TCP connection is displayed.
Tcpstats-display TCP statistics.
Udpconn-displays UDP connections.
Udpstats-displays UDP statistics.
Wins-displays the address of the WINS server.
2. Configure the interface IP Address/gateway IP Address
Netsh interface ip set address "Local Connection" static 192.168.1.100 255.255.255.0 192.168.1.253
------------------------------
Microsoft Windows XP [version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C: \> netsh interface ip show config
Interface "Local Connection" configuration
DHCP enabled or not
IP address 192.168.1.100
Subnet Mask 255.255.255.0
Default Gateway: 192.168.1.253
GatewayMetric: 0
InterfaceMetric 0
Static DNS server: 202.96.209.134
Static WINS server: None
Which prefix is used for registration?
3. Configure Automatic exchange for IP addresses, DNS addresses, and wins addresses
Netsh interface ip set address "Local Connection" dhcp
Netsh interface ip set dns "Local Connection" dhcp
Netsh interface ip set wins "Local Connection" dhcp
4. Configure static IP addresses, DNS addresses, and wins addresses
Netsh interface ip set address "Local Connection" static 192.168.1.253
Netsh interface ip set dns "Local Connection" static 202.96.209.6
Netsh interface ip set wins "Local Connection" static 192.168.1.1
5. View and export the network configuration file
C: \> netsh interface dump> c: \ dump.txt (">" indicates export. ">" Indicates appending)
  
  
  


#======================================
# IPv4 Configuration
#======================================
Pushd interface ipv4

Reset
Set global defaultcurhoplimit = 64 icmpredirects = enabled
Set interface = "wireless network connection" forwarding = disabled advertise = enabled nud = enabled


Popd
# IPv4 configuration ends


6. Import the network configuration file
C: \> netsh-f c: \ dump.txt
C: \> netsh exec c: \ dump.txt

However, this operation does not solve the problem of frequent network replacement, and the computer needs to be restarted.

Write the netsh command as a script and generate a bat file to solve this problem.

Write a bat for Intranet/Internet switchover.

@ Echo off
@ Color E0
Title ipsettings
: Start
Echo "set ipv4 information"
Echo "1. Intranet ipv4 Settings"
Echo "2. Internet ipv4 Settings"
 
Set/p var = enter the option
Echo % var %
If % var % = 1 goto setLAN
If % var % = 2 goto setInter_WLAN

: SetLAN
Netsh-f F: \ IPChange \ inner.txt
Goto end

: SetInter_WLAN
Netsh-f F: \ IPChange \ internet.txt
Goto end
Echo "down ."
: End
Goto end

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.