Backup and Restore Network Configuration with netsh utility


This post is about Backup and Restore Network configuration from a client, in this case a Windows 2003 Server.

We will use netsh dump to proceed wit our goal.

C:\>netsh dump /?
Usage: dump
Remarks:    Creates a script that contains the current configuration.  If saved to a
    file, this script can be used to restore altered configuration settings.

To Backup your network configuration run in the command prompt this:

netsh interface dump > netcfg.dat

To Restore your network configuration run in the command prompt this:

netsh exec netcfg.dat

Content of netcfg.dat file
# Interface configuration

#========================
# Interface configuration
#========================
pushd interface
reset all
popd
# End of interface configuration
#========================
# Interface configuration
#========================
pushd interface ipv6
uninstall
popd
# End of interface configuration

# ISATAP Configuration

# ----------------------------------
# ISATAP Configuration
# ----------------------------------
pushd interface ipv6 isatap
popd
# End of ISATAP configuration

# 6to4 Configuration

# ----------------------------------
# 6to4 Configuration
# ----------------------------------
pushd interface ipv6 6to4
reset
popd
# End of 6to4 configuration

# Port Proxy configuration

#========================
# Port Proxy configuration
#========================
pushd interface portproxy
reset
popd
# End of Port Proxy configuration

# Interface IP Configuration    

# ---------------------------------- 
# Interface IP Configuration         
# ---------------------------------- 
pushd interface ip
# Interface IP Configuration for "GST"
set address name="GST" source=static addr=xxx.xxx.xxx.xxx mask=255.255.xxx.xxx
set dns name="GST" source=static addr=none register=NONE
set wins name="GST" source=static addr=none
# Interface IP Configuration for "BKP"
set address name="BKP" source=static addr=xxx.xxx.xxx.xxx mask=255.255.xxx.xxx
set dns name="BKP" source=static addr=none register=NONE
set wins name="BKP" source=static addr=none
# Interface IP Configuration for "FE"
set address name="FE" source=static addr=xxx.xxx.xxx.xxx mask=255.255.xxx.xxx
set address name="FE" gateway=10.163.124.65 gwmetric=0
set dns name="FE" source=static addr=xxx.xxx.xxx.xxx register=BOTH
add dns name="FE" addr=xxx.xxx.xxx.xxx index=2
set wins name="FE" source=static addr=none
popd
# End of interface IP configuration

# aaaa 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.
# IAS.MDB Version = 7
pushd aaaa
set config  blob=\
... text was cut from here because is to extensive and unreadable.
*\
A7ACI/wD\
\
*
popd
# End of aaaa show config
# End of aaaa configuration.

# Remote Access 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 = Guest dialin = policy cbpolicy = none 
set user name = ITSMICROSOFT dialin = policy cbpolicy = none 
set user name = IUSR_TCPCODBF01 dialin = deny cbpolicy = none 
set user name = IWAM_TCPCODBF01 dialin = deny cbpolicy = none 
set user name = SQLDebugger dialin = policy cbpolicy = none 
set user name = SUPPORT_388945a0 dialin = policy cbpolicy = none 
popd
# End of Remote Access configuration.

# Remote Access AppleTalk Configuration    

# -----------------------------------------
 # Remote Access AppleTalk Configuration
 # -----------------------------------------
 pushd ras appletalk
set negotiation mode = allow
popd
# End of Remote Access AppleTalk Configuration.

# Remote Access Diagnostics Configuration

# -----------------------------------------
 # Remote Access Diagnostics Configuration
 # -----------------------------------------
 pushd ras diagnostics
set rastracing component = * state = disabled
set modemtracing state = disabled
set cmtracing state = disabled
set securityeventlogs state = enabled
popd
# End of Remote Access Diagnostics Configuration.

# Remote Access IP 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

# -----------------------------------------
 # 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

# —————————————–
# 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

# Routing Configuration
 pushd routing
 reset
 popd

# IP Configuration

 # 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 3" state=enable
 set filter name="Local Area Connection 3" fragcheck=disable
 add interface name="GST" state=enable
 set filter name="GST" fragcheck=disable
 add interface name="BKP" state=enable
 set filter name="BKP" fragcheck=disable
 add interface name="FE" state=enable
 set filter name="FE" fragcheck=disable
 add interface name="Local Area Connection 6" state=enable
 set filter name="Local Area Connection 6" fragcheck=disable
 add interface name="Local Area Connection" state=enable
 set filter name="Local Area Connection" 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

# ----------------------------------
 # DNS Proxy configuration
 # ----------------------------------
 pushd routing ip dnsproxy
 uninstall
popd
 # End of DNS proxy configuration

# IGMP Configuration

# ----------------------------------
 # IGMP Configuration
 # ----------------------------------
 pushd routing ip igmp
 uninstall
popd
 # End of IGMP configuration

# NAT configuration

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

# OSPF configuration

# ----------------------------------
 # OSPF configuration
 # ----------------------------------
pushd routing ip ospf
 uninstall
popd
 # End of OSPF configuration

# DHCP Relay Agent configuration

# ----------------------------------
 # DHCP Relay Agent configuration
 # ----------------------------------
 pushd routing ip relay
 uninstall
popd
 # End of DHCP Relay configuration

# RIP configuration

# ----------------------------------
 # RIP configuration
 # ----------------------------------
 pushd routing ip rip
 uninstall
popd
 # End of RIP configuration

# Router Discovery Configuration

# ----------------------------------
 # Router Discovery Configuration
 # ----------------------------------
 pushd routing ip routerdiscovery
 uninstall
 add interface name="Local Area Connection 3" disc=disable minint=7 maxint=10 life=30 level=0
 add interface name="GST" disc=disable minint=7 maxint=10 life=30 level=0
 add interface name="BKP" disc=disable minint=7 maxint=10 life=30 level=0
 add interface name="FE" disc=disable minint=7 maxint=10 life=30 level=0
 add interface name="Local Area Connection 6" disc=disable minint=7 maxint=10 life=30 level=0
 add interface name="Local Area Connection" 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

# ----------------------------------
 # DHCP Allocator Configuration
 # ----------------------------------
 pushd routing ip autodhcp
 uninstall
popd
 # End of DHCP Allocator Configuration

Hope that this information can be useful and save you some time.

Please Rate and comment this post.

About rodvars
Been working in IT Services/Consulting for the past 15 years. My main areas of work are planning, development, managing and administration System infrastructures focusing on optimizing user processes, enforcing business security, performance enhancements, high availabilty and infrastucture scalability.

3 Responses to Backup and Restore Network Configuration with netsh utility

  1. Jack says:

    any way of saving it to a certain location like C:\ and reading the .dat file?
    It seems to have an error and close fast, netsh command for saving it is not working.

    • rodvars says:

      using this :netsh interface dump > netcfg.dat, will save in the current location, if you notest I’ve run c:\netsh interface dump > netcfg.dat.
      try to check if you can write in c:\
      Any further question email me rodvars@gmail.com.

    • haxxy says:

      use netsh dump>c:\netcfg.dat

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: