切换网络配置之脚本法

切换网络配置之脚本法

由于现在移动设备的普遍使用等情况,需要经常改变网络配置,如:IP地址等。还有就象我们单位,因为上网的限制而出现的“抢ip”现象。使用简单的命令,就可以迅速修改ip,真真做到“上网,但不带走一片树叶“

D:\>netsh dump interface lacal area connection >MyNet.txt

现在,D:\下有一个文件:MyNet.txt,内容如下:

#========================
# Interface configuration
#========================
pushd interface

reset all


popd
# End of interface configuration

#========================
# Interface configuration
#========================
pushd interface ipv6

uninstall


popd
# End of interface configuration

 

# ----------------------------------
# ISATAP Configuration
# ----------------------------------
pushd interface ipv6 isatap

 

popd
# End of ISATAP configuration

 

# ----------------------------------
# 6to4 Configuration
# ----------------------------------
pushd interface ipv6 6to4

reset

 

popd
# End of 6to4 configuration

#========================
# Port Proxy configuration
#========================
pushd interface portproxy

reset


popd
# End of Port Proxy configuration

 

# ----------------------------------
# Interface IP Configuration        
# ----------------------------------
pushd interface ip


# Interface IP Configuration for "VMware Network Adapter VMnet8"

set address name="VMware Network Adapter VMnet8" source=static addr=192.168.159.1 mask=255.255.255.0
set dns name="VMware Network Adapter VMnet8" source=static addr=none register=PRIMARY
set wins name="VMware Network Adapter VMnet8" source=static addr=none

# Interface IP Configuration for "VMware Network Adapter VMnet1"

set address name="VMware Network Adapter VMnet1" source=static addr=192.168.148.1 mask=255.255.255.0
set dns name="VMware Network Adapter VMnet1" source=static addr=none register=PRIMARY
set wins name="VMware Network Adapter VMnet1" source=static addr=none

# Interface IP Configuration for "Local Area Connection"

set address name="Local Area Connection" source=static addr=192.168.0.183 mask=255.255.255.0
set address name="Local Area Connection" gateway=192.168.0.1 gwmetric=0
set dns name="Local Area Connection" source=static addr=221.136.0.1 register=PRIMARY
set wins name="Local Area Connection" source=static addr=none


popd
# End of interface IP configuration


                                           
# -----------------------------------------
# aaaa Configuration                        
# -----------------------------------------
# This script will NOT work across different versions of IAS.
# -----------------------------------------

# aaaa configuration script. 
# Known Issues and limitations:
# Import/Export between different versions is not supported.

Failed attempting to show the aaaa configuration. 
                                          


# End of aaaa configuration.                 
                                            
                                            

                                           
# -----------------------------------------
# Remote Access Configuration              
# -----------------------------------------
pushd ras

set authmode mode = standard
delete authtype type = PAP
delete authtype type = SPAP
delete authtype type = MD5CHAP
delete authtype type = MSCHAP
delete authtype type = MSCHAPv2
delete authtype type = EAP
add authtype type = MSCHAP
delete link type = SWC
delete link type = LCP
add link type = SWC
add link type = LCP
delete multilink type = MULTI
delete multilink type = BACP
add multilink type = MULTI
add multilink type = BACP

set user name = __vmware_user__ dialin = policy cbpolicy = none
set user name = Administrator dialin = policy cbpolicy = none
set user name = Guest dialin = policy cbpolicy = none
set user name = IUSR_LABSERVER2003 dialin = deny cbpolicy = none
set user name = IWAM_LABSERVER2003 dialin = deny cbpolicy = none
set user name = kavamorph dialin = policy cbpolicy = none
set user name = ss dialin = policy cbpolicy = none
set user name = SUPPORT_388945a0 dialin = policy cbpolicy = none


popd

# End of Remote Access configuration.       
                                            
                                            

                                           
# -----------------------------------------
# Remote Access AppleTalk Configuration    
# -----------------------------------------
pushd ras appletalk

set negotiation mode = allow

popd

# End of Remote Access AppleTalk Configuration.


                                           
# -----------------------------------------
# Remote Access Diagnostics Configuration  
# -----------------------------------------
pushd ras diagnostics

set rastracing component = * state = disabled

set modemtracing state = disabled

set cmtracing state = disabled

set securityeventlogs state = disabled


popd

# End of Remote Access Diagnostics Configuration.
                                                
                                                

                                           
# -----------------------------------------
# Remote Access IP Configuration           
# -----------------------------------------
pushd ras ip

delete pool

set negotiation mode = allow
set access mode = all
set addrreq mode = deny
set broadcastnameresolution mode = disabled
set addrassign method = auto

popd

# End of Remote Access IP configuration.    
                                            

                                           
# -----------------------------------------
# Remote Access IPX Configuration          
# -----------------------------------------
pushd ras ipx

set negotiation mode = deny
set access mode = all
set nodereq mode = allow
set netassign method = autosame

popd

# End of Remote Access IPX configuration.   
                                            
                                            

                                           
# -----------------------------------------
# Remote Access NBF Configuration          
# -----------------------------------------
pushd ras netbeui

set negotiation mode = allow
set access mode = all

popd

# End of Remote Access NBF configuration.  
                                           
                                           

                                           
# -----------------------------------------
# Remote Access AAAA Configuration         
# -----------------------------------------
pushd ras aaaa

set authentication provider = windows
set accounting provider = windows

delete authserver name = *
delete acctserver name = *

 

popd

# End of Remote Access AAAA configuration.    
                                              
                                              
# Routing Configuration
pushd routing
reset
popd
# IP Configuration
pushd routing ip
reset
set loglevel error
add preferenceforprotocol proto=LOCAL preflevel=1
add preferenceforprotocol proto=NetMgmt preflevel=10
add preferenceforprotocol proto=STATIC preflevel=3
add preferenceforprotocol proto=NONDOD preflevel=5
add preferenceforprotocol proto=AUTOSTATIC preflevel=7
add preferenceforprotocol proto=OSPF preflevel=110
add preferenceforprotocol proto=RIP preflevel=120
add interface name="Local Area Connection" state=enable
set filter name="Local Area Connection" fragcheck=disable
add interface name="VMware Network Adapter VMnet8" state=enable
set filter name="VMware Network Adapter VMnet8" fragcheck=disable
add interface name="VMware Network Adapter VMnet1" state=enable
set filter name="VMware Network Adapter VMnet1" fragcheck=disable
add interface name="Internal" state=enable
set filter name="Internal" fragcheck=disable
add interface name="Loopback" state=enable
set filter name="Loopback" fragcheck=disable
popd
# End of IP configuration

 

# ----------------------------------
# DNS Proxy configuration           
# ----------------------------------
pushd routing ip dnsproxy
uninstall


popd
# End of DNS proxy configuration

 

# ----------------------------------
# IGMP Configuration                
# ----------------------------------
pushd routing ip igmp
uninstall


popd
# End of IGMP configuration

 

# ----------------------------------
# NAT configuration                 
# ----------------------------------
pushd routing ip nat
uninstall


popd

 


# ----------------------------------
# OSPF configuration                
# ----------------------------------

pushd routing ip ospf
uninstall

popd
# End of OSPF configuration

 


# ----------------------------------
# DHCP Relay Agent configuration    
# ----------------------------------
pushd routing ip relay
uninstall


popd
# End of DHCP Relay configuration

 

# ----------------------------------
# RIP configuration                 
# ----------------------------------
pushd routing ip rip
uninstall


popd
# End of RIP configuration

 

# ----------------------------------
# Router Discovery Configuration    
# ----------------------------------
pushd routing ip routerdiscovery
uninstall
add interface name="Local Area Connection" disc=disable minint=7 maxint=10 life=30 level=0
add interface name="VMware Network Adapter VMnet8" disc=disable minint=7 maxint=10 life=30 level=0
add interface name="VMware Network Adapter VMnet1" disc=disable minint=7 maxint=10 life=30 level=0
add interface name="Internal" disc=disable minint=7 maxint=10 life=30 level=0
add interface name="Loopback" disc=disable minint=7 maxint=10 life=30 level=0


popd


# ----------------------------------
# DHCP Allocator Configuration      
# ----------------------------------
pushd routing ip autodhcp
uninstall


popd
# End of DHCP Allocator Configuration


Loading of DLL WinsEvnt.dll failed.
Wins Operation failed with Error There are no more endpoints available from the endpoint mapper.


做好了第一步,现在开始第二步:

通过控制面板修改网络设置,修改完以后在CMD下输入:

D:\>netsh dump interface lacal area connection >MyNet2.txt

大功告成,现在有两个网络配置的脚本了,如果你想切换,在CMD下输入:

D:\>netsh dump >mynet.txt

D:\>netsh dump >mynet2.txt

就可以迅速切换网络配置了。

转载于:https://www.cnblogs.com/kavamorph/archive/2004/03/11/2802.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值