netsh command resolves network switchover issues

Source: Internet
Author: User

Many companies work in the process, involving multiple network problems. Frequent switching of networks involves an issue of frequent IP configuration.

First, take a look at the netsh command.

Netsh is a very powerful system built-in command. If you can understand a little general operation, for the administrator sometimes have unexpected help. For example, my client's system has done some strategy. Many operations must also be done under the command line. Below is a brief introduction to several common functions. Others can refer to the Netsh help file.
A) Enable firewall
C:\>netsh Firewall set Opmode mode = enable
Are you sure.
b) Turn off the firewall
C:\>netsh Firewall set Opmode mode = disable
Are you sure.
c) Resetting the firewall
C:\>netsh Firewall Reset
Are you sure.
1. View network Configuration
netsh interface ip show {option}
{Options} can be:
Address-Displays the IP address configuration.
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-Displays the network-to-media mapping of the IP.
Ipstats-Displays IP statistics.
Joins-Displays the joined multicast group.
Offload-Displays the uninstallation information.
Tcpconn-Displays the TCP connection.
Tcpstats-Displays the TCP statistics.
Udpconn-Displays the UDP connection.
Udpstats-Displays UDP statistics.
WINS-Displays the WINS server address.
2. Configuring the Interface ip/Gateway IP
netsh interface ip set address "Local Area 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
Configuration of the interface "Local Area Connection"
DHCP Enable No
IP Address 192.168.1.100
Subnet Mask 255.255.255.0
Default gateway: 192.168.1.253
gatewaymetric:0
InterfaceMetric 0
Statically configured DNS servers: 202.96.209.134
Statically configured WINS server: None
Which prefix to register with: just the main
3, configure auto-Exchange IP address, DNS address and WINS address
netsh interface ip set address "Local Area Connection" DHCP
netsh interface ip set DNS "Local Area Connection" DHCP
netsh interface ip set wins "Local Area Connection" DHCP
4. Configure static IP address, DNS address and WINS address
netsh interface ip set address "Local Area Connection" static 192.168.1.253
netsh interface ip set DNS "Local Area Connection" static 202.96.209.6
netsh interface ip set wins "Local Area Connection" static 192.168.1.1
5. View and export the network configuration file
C:\>netsh interface Dump >c:\dump.txt (">" means export.) ">>" means append)
  
  
  


#========================
# IPV4 Configuration
#========================
pushd interface IPv4

Reset
Set global defaultcurhoplimit=64 icmpredirects=enabled
Set interface interface= "Wireless network Connection" Forwarding=disabled advertise=enabled nud=enabled


popd
# IPV4 Configuration End


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

However, this does not solve the problem of frequent network changes, and the need to restart the computer.

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

Now write an inside and outside network toggle bat.

@echo off
@color E0
Title IP Settings
: Start
echo "Set IPv4 info"
echo "1. Intranet IPv4 Settings"
echo "2. External network IPv4 Settings"

set/p var= Please 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

netsh command resolves network switchover issues

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.