切换网络配置之脚本法

由于现在移动设备的普遍使用等情况,需要经常改变网络配置,如: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

切换网络配置之脚本法相关推荐

  1. Centos的网络配置命令和文件

    一.ifcongfig Centos6之前最常用的配置网络命令就是ifconfig,使用ifconfig命令时最好切换到root用户的身份 1.直接使用ifconfig可以查看当前配置的网络设备的信息 ...

  2. linux网络配置、测试及故障诊断方法和工具二

    网络配置的工具<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> ...

  3. 网络配置——Linux运维基础

    今天把Linux的网络配置总结了一下,尽管并不难可是是个比較重要的基础.然后我也不知到自己以后是否会做运维,可是我知道自己比較喜欢刨根问底.还有就是我很珍惜我以前掌握过的这些运维的技能.今天突然间问自 ...

  4. VMware虚拟机NAT模式网络配置图文教程

    https://www.cnblogs.com/passer101/p/9899202.html 一.引言 在Windows上搭建集群实验环境时,为能够让集群结点之间相互通信,我们需要通过VMware ...

  5. 大型企业网络配置系列课程详解(四) --HSRP和VRRP配置与相关概念的理解(一)...

    大型企业网络配置系列课程详解(四)<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office&qu ...

  6. RHCE课程-初级部分6、编辑工具VIM,网络配置,进程优先,日志文件简介。

    我们通常用各种编辑工具来处理文本文件 常用的编辑工具: VI VIM EMACS VI和VIM的区别 它们都是多模式编辑器,不同的是vim 是vi的升级版本,它不仅兼容vi的所有指令,而且还有一些新的 ...

  7. virtualbox配置apache_virtualbox 网络配置 (转)

    http://www.vmbest.com/school/2-virtualbox-school/13-virtualbox-net-config-four-plan "网络"配置 ...

  8. tx2无法识别网络_Jetson TX2开篇--网络配置

    续接上文,硬件连接完毕后,接通电源,按开机按钮. 系统开机首次进入的是以nvidia用户登录的Ubuntu 命令行界面. 习惯使用图形界面的用户莫慌,首次开机通过startx 命令发现无法启动图形界面 ...

  9. Docker的网络配置:创建网桥

    Table of Contents 环境 介绍 关于命名空间 关于Veth对 建立我自己的Docker网络 里程碑1:主机内Ping 里程碑2:通过主机NAT进行外部访问 里程碑3:从主机到远程容器的 ...

最新文章

  1. ubuntu安装deepin terminal 终端
  2. 【freeCodeCamp】免费晋级前台工程师呦!!!!
  3. java aop性能检测_Spring AOP 性能监控器
  4. 论文笔记:Distilling the Knowledge
  5. 关于MFC的CString 访问越界问题
  6. [SPP-NET]Spatial Pyramid Pooling in Deep Convolutional Networks for Visual Recognition
  7. NOIP2018——总结油记
  8. 第5章 初识JQuery
  9. 【LeetCode】剑指 Offer 24. 反转链表
  10. sql server 流程控制
  11. 【ZooKeeper Notes 6】客户端对zookeeper的操作是不可回退的 [OK]
  12. 一个简单的软件工程流程
  13. 富怡服装cad制图软件Super V8官方免费版 | 富怡服装cad制图软件下载 | 提供高清版富怡cad教程视频全集免费下载
  14. Creo 由方程创建曲线
  15. 推荐一个js代码混淆工具的网址
  16. 【Google面试题】有四个线程1、2、3、4同步写入数据…C++11实现
  17. Nvidia Agx Xavier平台nvp6324模块调试
  18. 45 | chmod命令
  19. 面试/笔试第一弹 —— 计算机网络面试问题集锦【转】
  20. 暗黑模式(黑暗模式,深色模式)适配

热门文章

  1. 硅谷程序员佛系养生法:我不修bug, 谁修bug
  2. 零基础学Python(第十三章 元组)
  3. plsql学习范例--使用utl_file包将查询结果输出到文件中
  4. 一文弄懂神经网络中的反向传播法——BackPropagation【转】
  5. BZOJ2209: [Jsoi2011]括号序列
  6. Windows下安装和配置tomca(免安装版本)
  7. golang 防知乎 中文验证码 源码
  8. Net性能分析与调试培训资料
  9. DispacherServlet默认加载配置文件名
  10. bzoj3715 [PA2014]Lustra