개발자 모드/C언어

netsh와 system함수로 ip 변경하는 법 #2

인생은직구 2021. 9. 9. 12:07
728x90
// test.cpp : 콘솔 응용 프로그램에 대한 진입점을 정의합니다.

//

​

#include "stdafx.h"

#include "windows.h" // console에서 system함수의 명령어를 가능하게 함

​

​

int _tmain(int argc, _TCHAR* argv[])

{

​

//system("netsh interface ip set address \"이더넷\" static 192.168.23.22 255.255.255.0 192.168.23.1 1");

//// netsh interface ip set address "[Network Interface Name]" static [IP Address] [Subnet Mask] [Default Gateway] [Metric]

//// * Metric - 라우팅 경로가 여러개일 경우 우선순위를 나타냄.

​

//system("netsh interface ip add address \"이더넷\" 192.168.23.21");

//// netsh interface ip add address "[Network Interface Name]" [IP Address]

​

//system("netsh interface ip delete address \"이더넷\" 192.168.23.21");

//// netsh interface ip delete address "[Network Interface Name]" [IP Address]

​

​

system("netsh interface ip set address name=\"이더넷\" static 192.168.23.22 255.255.255.0 192.168.23.1");

// ip set

​

system("netsh interface ip add address name=\"이더넷\" addr=192.168.23.20");

// ip add

​

system("netsh interface ip delete address name=\"이더넷\" addr=192.168.23.20");

// ip delete

​

​

system("netsh int ip reset");

// network reset

​

return 0;

}
728x90