实用netsh命令备份网络配置
要把主机上的所有网络相关的配置信息备份到C盘test.txt文件,可以运行命令:
netsh dump>c:\test.txt
要把本机中远程访问连接和TCP/IP配置接口参数备份到C盘下的test.txt,可以运行命令:netsh interface dump>test.txt。
示例如下:
C:\>netsh dump>c:\test.txt,然后我们就可以在c盘找到test.txt文件,改文件的内容如下:
#========================
# 接口配置
#========================
pushd interface
popd
# 接口配置结束
# ----------------------------------
# IPHTTPS 配置
# ----------------------------------
pushd interface httpstunnel
reset
popd
# IPHTTPS 配置的结尾
#========================
# IPv4 配置
#========================
pushd interface ipv4
reset
set global defaultcurhoplimit=64 icmpredirects=enabled taskoffload=enabled
popd
# IPv4 配置结束
# ----------------------------------
# IPv6 配置
# ----------------------------------
pushd interface ipv6
reset
popd
# IPv6 配置的结尾
# ----------------------------------
# ISATAP 配置
# ----------------------------------
pushd interface isatap
popd
# ISATAP 配置结束
# ----------------------------------
# 6to4 配置
# ----------------------------------
pushd interface 6to4
reset
popd
# 6to4 配置结束
# ----------------------------------
# ISATAP 配置
# ----------------------------------
pushd interface isatap
popd
# ISATAP 配置结束
#========================
# 端口代理配置
#========================
pushd interface portproxy
reset
popd
# 端口代理配置结束
# ----------------------------------
# TCP 配置
# ----------------------------------
pushd interface tcp
reset
全局设置 rss=enabled chimney=automatic autotuninglevel=normal congestionprovider=none ecncapability=disabled timestamps=disabled netdma=enabled dca=enabled
popd
# TCP 配置结束
# ----------------------------------
# Teredo 配置
# ----------------------------------
pushd interface teredo
set state type=client servername=teredo.ipv6.microsoft.com. servervirtualip=0.0.0.0
popd
# Teredo 配置结束
# ----------------------------------
# 6to4 配置
# ----------------------------------
pushd interface 6to4
reset
popd
# 6to4 配置结束
# ------------------------------------
# 桥配置 (不支持)
# ------------------------------------
# ------------------------------------
# 桥配置结束
# ------------------------------------
# ----------------------------------------
# 有线局域网配置
# ----------------------------------------
pushd lan
popd
# 有线局域网配置结尾。
不支持移动宽带配置转储
# ==========================================================
# 健康注册机构配置
# ==========================================================
pushd nap hra
popd
# NAP HRA 配置的结尾
# -----------------------------------------
# 远程访问配置
# -----------------------------------------
pushd ras
set authmode mode = standard
delete authtype type = PAP
delete authtype type = MD5CHAP
delete authtype type = MSCHAPv2
delete authtype type = EAP
delete authtype type = CERT
add authtype type = MSCHAPv2
delete link type = SWC
delete link type = LCP
add link type = SWC
add link type = LCP
delete multilink type = MULTI
add multilink type = MULTI
set conf confstate = disabled
set type ipv4rtrtype = lananddd ipv6rtrtype = none rastype = ipv4
set wanports device = "WAN Miniport (IKEv2)" rasinonly = disabled ddinout = disabled ddoutonly = disabled maxports = 2
set wanports device = "WAN Miniport (L2TP)" rasinonly = disabled ddinout = disabled ddoutonly = disabled maxports = 2
set wanports device = "WAN Miniport (PPPOE)" ddoutonly = disabled
set wanports device = "WAN Miniport (PPTP)" rasinonly = disabled ddinout = disabled ddoutonly = disabled maxports = 2
set wanports device = "WAN Miniport (SSTP)" rasinonly = disabled ddinout = disabled ddoutonly = disabled maxports = 2
set user name = Administrator dialin = policy cbpolicy = none
set user name = Guest dialin = policy cbpolicy = none
set ikev2connection idletimeout = 5 nwoutagetime = 30
set ikev2saexpiry saexpirytime = 480 sadatasizelimit = 100
popd
# 远程访问配置结束。
# -----------------------------------------
# 远程访问诊断配置
# -----------------------------------------
pushd ras diagnostics
set rastracing component = * state = disabled
set modemtracing state = disabled
set cmtracing state = disabled
set securityeventlog state = disabled
set loglevel events = warn
popd
# 远程访问诊断配置结束
# -----------------------------------------
# 远程访问 IP 配置
# -----------------------------------------
pushd ras ip
delete pool
set negotiation mode = allow
set access mode = all
set addrreq mode = deny
set broadcastnameresolution mode = enabled
set addrassign method = auto
set preferredadapter
popd
# 远程访问 IP 配置结束。
# -----------------------------------------
# 远程访问 IPv6 配置
# -----------------------------------------
pushd ras ipv6
set negotiation mode = deny
set access mode = all
set routeradvertise mode = enabled
popd
# 远程访问 IPv6 配置结束。
# -----------------------------------------
# 远程访问 AAAA 配置
# -----------------------------------------
pushd ras aaaa
popd
# 远程访问 AAAA 配置结束。
# -----------------------------------------
# WinHTTP 代理服务器配置
# -----------------------------------------
pushd winhttp
reset proxy
popd
# WinHTTP 代理服务器配置末尾
以后在进行网络设置调整时,如果发生了操作错误,或者服务器网络出现故障,可以利用备份快速恢复网络设置:
netsh -f c:\test.txt或netsh exec c:\test.txt
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。