Netsh 명령 구문, 컨텍스트 및 서식

적용 대상: Windows Server 2022, Windows Server 2019, Windows Server 2016, Azure Stack HCI, 버전 21H2 및 20H2

이 문서를 사용하여 netsh 컨텍스트 및 하위 텍스트를 입력하고, netsh 구문 및 명령 서식을 이해하고, 로컬 및 원격 컴퓨터에서 netsh 명령을 실행하는 방법을 알아볼 수 있습니다.

Netsh는 현재 실행 중인 컴퓨터의 네트워크 구성을 표시하거나 수정할 수 있는 명령줄 스크립팅 유틸리티입니다. Netsh 명령은 netsh 셸에서 명령을 입력하여 실행할 수 있으며 배치 파일 또는 스크립트에서 사용할 수 있습니다. netsh 명령을 사용하여 원격 컴퓨터와 로컬 컴퓨터를 구성할 수 있습니다.

또한 Netsh는 지정된 컴퓨터에 대해 배치 모드로 명령 그룹을 실행할 수 있게 해주는 스크립팅 기능을 제공합니다. Netsh를 사용하면 보관 목적으로 또는 다른 컴퓨터를 구성하는 데 유용하도록 구성 스크립트를 텍스트 파일로 저장할 수 있습니다.

구문

netsh
netsh [-a AliasFile] [-c Context] [-r RemoteMachine] [-u [DomainName\]UserName] [-p Password | *] [Command | -f ScriptFile]

다음 매개 변수는 선택 사항으로 간주됩니다.

매개 변수 설명
-a AliasFile을 실행후 netsh 셸로 돌아가도록 지정합니다.
AliasFile 하나 이상의 netsh 명령이 포함된 텍스트 파일 이름을 지정합니다.
-c netsh가 지정된 netsh 컨텍스트로 전환되도록 지정합니다.
Context 입력하려는 netsh 컨텍스트를 지정합니다.
-r 원격 컴퓨터에서 명령을 실행하도록 지정합니다. 원격 레지스트리 서비스는 원격 컴퓨터에서 실행 중이어야 합니다. 실행되고 있지 않으면 Windows에 "네트워크 경로를 찾을 수 없음" 오류 메시지가 표시됩니다.
RemoteComputer 구성하려는 원격 컴퓨터를 지정합니다.
-u 사용자 계정으로 netsh 명령을 실행하도록 지정합니다.
DomainName\ 사용자 계정이 있는 도메인을 지정합니다. Do기본Name\이 지정되지 않은 경우 기본값은 로컬 do기본입니다.
UserName 사용자 계정 이름을 지정합니다.
-p 사용자 계정의 암호를 입력하도록 지정합니다.
Password -uUserName으로 지정한 사용자 계정의 암호를 지정합니다.
Command 실행하려는 netsh 명령을 지정합니다.
f- ScriptFile을 사용하여 지정한 스크립트를 실행한 후 netsh를 종료합니다.
ScriptFile 실행하려는 스크립트를 지정합니다.

참고 항목

다음 명령을 지정 -r 하면 netsh는 원격 컴퓨터에서 명령을 실행한 다음 명령 프롬프트로 돌아갑니다. 다른 명령 없이 -r을 지정하면 netsh가 원격 모드에서 열립니다. 이 프로세스는 netsh 명령 셸에서 설정 컴퓨터를 사용하는 것과 유사합니다. -r을 사용할 때 netsh의 현재 인스턴스에 대한 대상 컴퓨터만 설정합니다. netsh를 종료하고 다시 입력하면 대상 컴퓨터가 로컬 컴퓨터로 다시 설정됩니다. WINS에 저장된 컴퓨터 이름, UNC 이름, DNS 서버에서 확인할 인터넷 이름 또는 IP 주소를 지정하여 원격 컴퓨터에서 netsh 명령을 실행할 수 있습니다.

netsh 명령 실행

netsh 명령을 실행하려면 netsh를 입력한 다음 Enter 키를 눌러 명령 프롬프트 또는 PowerShell에서 netsh시작해야 합니다. 다음으로, 사용하려는 명령이 포함된 컨텍스트로 변경할 수 있습니다. 사용 가능한 컨텍스트는 설치한 네트워킹 구성 요소에 따라 다릅니다.

예를 들어 netsh 셸에 dhcp를 입력하고 Enter 키를 누르면 netsh가 DHCP 서버 컨텍스트로 변경됩니다. DHCP 서버 역할이 설치되어 있지 않으면 다음 메시지가 나타납니다.

The following command was not found: dhcp.

Netsh 컨텍스트

Netsh는 DLL(동적 연결 라이브러리) 파일을 사용하여 다른 운영 체제 구성 요소와 상호 작용합니다.

각 netsh 도우미 DLL은 네트워킹 서버 역할 또는 기능과 관련된 명령 그룹인 컨텍스트라는 광범위한 기능 세트를 제공합니다. 이러한 컨텍스트는 하나 이상의 서비스, 유틸리티 또는 프로토콜에 대한 구성 및 모니터링 지원을 제공하여 netsh의 기능을 확장합니다.

예를 들어 Dhcpmon.dll은 DHCP 서버를 구성하고 관리하는 데 필요한 컨텍스트 및 명령 세트를 netsh에 제공합니다.

명령 프롬프트 또는 Windows PowerShell을 열고 netsh /? 또는 netsh 도움말을 입력하고 Enter 키를 눌러 netsh 컨텍스트 목록을 가져올 수 있습니다.

다음은 출력 예제입니다.

The following commands are available:

Commands in this context:
..            - Goes up one context level.
?             - Displays a list of commands.
abort         - Discards changes made while in offline mode.
add           - Adds a configuration entry to a list of entries.
advfirewall   - Changes to the `netsh advfirewall' context.
alias         - Adds an alias.
branchcache   - Changes to the `netsh branchcache' context.
bridge        - Changes to the `netsh bridge' context.
bye           - Exits the program.
commit        - Commits changes made while in offline mode.
delete        - Deletes a configuration entry from a list of entries.
dhcpclient    - Changes to the `netsh dhcpclient' context.
dnsclient     - Changes to the `netsh dnsclient' context.
dump          - Displays a configuration script.
exec          - Runs a script file.
exit          - Exits the program.
firewall      - Changes to the `netsh firewall' context.
help          - Displays a list of commands.
http          - Changes to the `netsh http' context.
interface     - Changes to the `netsh interface' context.
ipsec         - Changes to the `netsh ipsec' context.
ipsecdosprotection - Changes to the `netsh ipsecdosprotection' context.
lan           - Changes to the `netsh lan' context.
namespace     - Changes to the `netsh namespace' context.
netio         - Changes to the `netsh netio' context.
offline       - Sets the current mode to offline.
online        - Sets the current mode to online.
popd          - Pops a context from the stack.
pushd         - Pushes current context on stack.
quit          - Exits the program.
ras           - Changes to the `netsh ras' context.
rpc           - Changes to the `netsh rpc' context.
set           - Updates configuration settings.
show          - Displays information.
trace         - Changes to the `netsh trace' context.
unalias       - Deletes an alias.
wfp           - Changes to the `netsh wfp' context.
winhttp       - Changes to the `netsh winhttp' context.
winsock       - Changes to the `netsh winsock' context.

The following sub-contexts are available:
advfirewall branchcache bridge dhcpclient dnsclient firewall http interface ipsec ipsecdosprotection lan namespace netio ras rpc trace wfp winhttp winsock

To view help for a command, type the command, followed by a space, and then type ?.

Netsh 하위 텍스트

Netsh 컨텍스트는 하위 컨텍스트라고 하는 명령과 추가 컨텍스트를 모두 포함할 수 있습니다. 예를 들어 인터페이스 컨텍스트 내에서 IPv4 및 IPv6 하위 텍스트로 변경할 수 있습니다.

컨텍스트 내에서 사용할 수 있는 명령 및 하위 텍스트 목록을 표시하려면 netsh 셸에서 하위 텍스트 이름을 입력한 다음 ? 또는 도움말을 입력합니다. 예시:

netsh> interface help

The following commands are available:

Commands in this context:
6to4           - Changes to the `netsh interface 6to4' context.
?              - Displays a list of commands.
dump           - Displays a configuration script.
help           - Displays a list of commands.
httpstunnel    - Changes to the `netsh interface httpstunnel' context.
ipv4           - Changes to the `netsh interface ipv4' context.
ipv6           - Changes to the `netsh interface ipv6' context.
isatap         - Changes to the `netsh interface isatap' context.
portproxy      - Changes to the `netsh interface portproxy' context.
set            - Sets configuration information.
show           - Displays information.
tcp            - Changes to the `netsh interface tcp' context.
teredo         - Changes to the `netsh interface teredo' context.
udp            - Changes to the `netsh interface udp' context.

The following sub-contexts are available:
6to4 httpstunnel ipv4 ipv6 isatap portproxy tcp teredo udp

To view help for a command, type the command, followed by a space, and then type ?.

현재 컨텍스트에서 변경하지 않고 다른 컨텍스트에서 작업을 수행하려면 netsh 셸에서 사용할 명령의 컨텍스트 경로를 입력합니다. 예를 들어 "NetLAN1"에 대한 정적 IPv4 주소를 추가하고 서브넷 마스크와 게이트웨이를 모두 지정하려면 다음을 입력합니다.

netsh interface ipv4 set address "NetLAN1" static <IP_Address> <Subnet_Mask> <Gateway>

범례 서식 지정

다음 서식 범례를 사용하여 netsh 셸에서 명령을 일괄 처리 파일 또는 스크립트로 실행할 때 올바른 netsh 명령 구문을 해석하고 사용할 수 있습니다.

  • 기울임꼴 텍스트는 명령을 입력하는 동안 제공해야 하는 정보입니다. 예를 들어 명령에 -UserName이라는 매개 변수가 있으면 실제 사용자 이름을 입력해야 합니다.
  • 굵게 텍스트는 명령을 입력할 때 보이는 그대로 입력해야 하는 정보입니다.
  • 줄임표(...)가 뒤에 잇는 텍스트는 명령줄에서 여러 번 반복할 수 있는 매개 변수입니다.
  • 대괄호 [] 사이에 있는 텍스트는 선택적 항목입니다.
  • 선택 항목이 파이프로 구분된 중괄호 { } 사이에 있는 텍스트는 선택 항목 집합을 제공하며, 선택 항목은 다음과 같이 {enable|disable}하나만 선택해야 합니다.
  • Courier 글꼴로 서식이 지정된 텍스트는 코드 또는 프로그램 출력입니다.

netsh 명령에 대한 문자열 값

문자열 값이 필요한 매개 변수를 포함하는 명령이 있습니다. 문자열 값에 문자 사이의 공백이 포함된 경우 문자열 값을 큰따옴표로 묶어야 합니다.

무선 네트워크 커넥트ion문자열 값으로 IPv4 네트워크에 대한 인터페이스 매개 변수를 DHCP로 설정하는 경우 문자열 값 주위에 큰따옴표를 사용합니다. 예시:

netsh interface ipv4>set address name="Wireless Network Connection" dhcp

또는 네트워크 인터페이스의 경우 인덱스 번호를 연결된 이름 대신 사용할 수 있습니다. 예시:

netsh interface ipv4>set address name=15 dhcp

연결된 인터페이스의 이름 또는 인덱스를 찾으려면 IPv4 또는 IPv6 인터페이스 하위 텍스트에 있어야 하며 인터페이스를 표시합니다. 다음은 그 예입니다.

netsh interface ipv4>show interfaces
netsh interface ipv6>show interfaces

참고 항목