본문 바로가기

Server Story..../Windows Server

방화벽 컨트롤 스크립트 ( firewall control script )

자.. 방화벽 을 스크립트 화해서 같고 있다가 위기때 확~!!!!  모두 블럭~!~!  하고  튀자~~ ^^
(  ps  2008 r2 기준 )
참고 사이트는 다음과 같다.



http://community.365managed.com/?document_srl=418

위의 사이트의 내용을 예로 아래 작성한 내용이다.


@echo off
echo # mssql 방화벽

echo ###############################    in   ######################################
netsh advfirewall firewall set rule name=all new enable=no

netsh advfirewall firewall set rule name="FTP Server Passive (FTP Passive Traffic-In)" dir=in new enable=yes
netsh advfirewall firewall set rule name="FTP Server Secure (FTP SSL Traffic-In)" dir=in new enable=yes
netsh advfirewall firewall set rule name="FTP 서버(FTP 트래픽 인)" dir=in new enable=yes
netsh advfirewall firewall set rule name="SNMP 서비스(UDP In)" dir=in new enable=yes
netsh advfirewall firewall set rule name="World Wide Web 서비스(HTTP 트래픽 인)" dir=in new enable=yes
netsh advfirewall firewall set rule name="World Wide Web 서비스(HTTPS 트래픽 인)" dir=in new enable=yes
netsh advfirewall firewall set rule name="파일 및 프린터 공유(에코 요청 - ICMPv4-In)" dir=in new enable=yes

netsh advfirewall firewall delete rule name="python(8282)" dir=in protocol=tcp localport=8282
netsh advfirewall firewall add rule name="python(8282)" dir=in protocol=tcp localport=8282 remoteip=121.0.0.0,222.0.0.0 action=allow

netsh advfirewall firewall delete rule name="Mssql Connection Port" dir=in protocol=tcp localport=1433
netsh advfirewall firewall add rule name="Mssql Connection Port" dir=in protocol=tcp localport=1433 action=allow

netsh advfirewall firewall delete rule name="Core Access - unlimited" dir=in
netsh advfirewall firewall add rule name="Core Access - unlimited" dir=in remoteip=121.0.0.0,222.0.0.0  action=allow

netsh advfirewall firewall delete rule name="IPBlockList" dir=in
netsh advfirewall firewall add rule name="IPBlockList" dir=in remoteip=180.68.207.247 action=block

netsh advfirewall firewall delete rule name="Remote Desk Top Change Port ( 3389 )" dir=in
netsh advfirewall firewall add rule name="Remote Desk Top Change Port ( 3389 )" dir=in action=allow protocol=tcp localport=3389

echo ###############################      out    ######################################
netsh advfirewall firewall set rule name=all dir=out new enable=no

netsh advfirewall firewall set rule name="FTP Server (FTP Traffic-Out)" dir=out new enable=yes
netsh advfirewall firewall set rule name="FTP Server Secure (FTP SSL Traffic-Out)" dir=out new enable=yes
netsh advfirewall firewall set rule name="SNMP 서비스(UDP Out)" dir=out new enable=yes
netsh advfirewall firewall set rule name="핵심 네트워킹 - DNS(UDP-Out)" dir=out new enable=yes


netsh advfirewall firewall delete rule name="Mssql Connection Port" dir=out protocol=tcp localport=1433
netsh advfirewall firewall add rule name="Mssql Connection Port" dir=out protocol=tcp localport=1433 action=allow