The netsh lan command allows you to manage and configure local area network (LAN) settings on your computer.
Syntax
netsh lan add | delete | dump | export | help | reconnect | set | show | ?
netsh lan add profile [filename=]<string> [interface=]<string>
netsh lan delete profile [interface=]<string>
netsh lan export profile [folder=]<string> [interface=]<string>
netsh lan reconnect [interface=]<string>
netsh lan set autoconfig [enabled=] <yes|no> [interface=] <string>
netsh lan set blockperiod [value=]<0-60>
netsh lan set eapuserdata [filename=]<string> [allusers]<yes|no> [interface=]<string>
netsh lan set profileparameter [[interface=]<string>]
[authMode=]<machineOrUser|machineOnly|userOnly|guest>
[ssoMode=]<preLogon|postLogon|none> [maxDelay=]<1-120>
[allowDialog=]<yes|no> [userVLAN=]<yes|no>
[oneXEnabled=]<yes|no> [oneXEnforced=]<yes|no>
netsh lan set trace [mode=]<yes|no|persistent>
netsh lan show interfaces
netsh lan show profiles [interface=]<string>
netsh lan show [settings | tracing]
Parameters
| Command | Description |
|---|---|
add profile filename=<string> interface=<string> |
Adds a new profile configuration entry to a table for LAN settings. filename - The name of the profile XML file. interface - The name of the network interface the profile is added to. |
delete profile interface=<string> |
Removes a profile configuration entry from a table for LAN settings. interface - The name of the network interface. |
| dump | Displays a script of the current LAN configuration. Can also be exported to a text file. |
export profile folder=<string> interface=<string> |
Exports the LAN profiles as XML files for backup or restore. folder - The name of the folder where the profile XML files is saved to. interface - The name of the network interface. |
reconnect interface=<string> |
Re-establishes a connection on a network interface. If the string value contains spaces, it must be wrapped in double quotes (" "). interface - The name of the network interface to reconnect to. |
| set allowexplicitcreds `allow=<yes | no>` |
| set autoconfig `enabled=<yes | no> interface=<string>` |
set blockperiod value=<0-60> |
value - Sets the duration, in minutes, where automatic connection attempts to a network are paused. The blocked state is cleared when you manually attempt to connect to a LAN, when a session changes, or when the network media reconnects. |
set eapuserdata filename=<string> `allusers=<yes |
no> interface=<string>` |
set profileparameter interface=<string> authMode=<machineOrUser | machineOnly | userOnly | guest> ssoMode=<preLogon | postLogon | none> maxDelay=<1-120> `allowDialog=<yes |
no> userVLAN=<yes |
| set tracing `mode=<yes | no |
show interfaces | profiles | settings | tracing |
Displays the current LAN settings and information. interfaces - Displays the local LAN interfaces. profiles - Displays all local configured LAN profiles. settings - Displays the local global LAN settings. tracing - Displays if LAN tracing is enabled or disabled. |
| help or ? | Displays a list of commands and their descriptions in the current context. |
Remarks
-
add profile: The
interfaceparameter is optional. The filename parameter is required and specifies the XML file that contains the profile data. -
delete profile: The
interfaceparameter is optional. If you specify an interface, the profile is deleted only from that interface. If no interface is specified, the profile is deleted from the machine profile. -
export profile: The
interfaceparameter is optional. If an interface name is specified, the profile for that interface is exported as "InterfaceName.xml". If no interface is specified, all profiles are exported, and the machine profile is saved as "MachineProfile.xml".The folder name is required and must point to an existing folder accessible from the local computer. You can use an absolute path or a relative path based on the current working directory. The value "." refers to the current directory, while ".." refers to its parent directory. Universal Naming Convention (UNC) paths aren't supported.
-
reconnect: The
interfaceparameter is optional. If an interface name is specified, only that interface reconnects. If no interface is specified, all interfaces reconnect. -
set profileparameter: Modifies the profile on specified interface. If the interface is specified, then only profile on that interface is modified. At least one parameter besides
interfacemust be specified.
Examples
To add a new LAN profile from an XML file to a specific interface, run the following command:
netsh lan add profile filename="C:\Profiles\MyLANProfile.xml" interface="Ethernet"
To re-establish a connection on a network interface, run the following command:
netsh lan reconnect interface="Ethernet"
To enable autoconfiguration on a network interface, run the following command:
netsh lan set autoconfig enabled=yes interface="Ethernet"
To configure a LAN profile to use machine-only authentication mode, run the following command:
netsh lan set profileparameter interface="Ethernet" authMode=machineOnly
To set the block period for automatic connection attempts to 30 minutes, run the following command:
netsh lan set blockperiod value=30
To save Extensible Authentication Protocol (EAP) user data to an XML file for all users on a specific interface, run the following command:
netsh lan set eapuserdata filename="C:\UserData\EAPConfig.xml" allusers=yes interface="Ethernet"
To display all the local configured LAN profiles, run the following command:
netsh lan show profiles
Source: Microsoft Learn / Windows Server documentation by Microsoft and contributors (upstream author metadata: robinharwood). Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.
