Windows批处理:配置防火墙规则、开启远程桌面
一、简介
公司主机加入域后,防火墙未进行设置,规则不统一,不少主机ping不通。另打算开启远程桌面,方便远程管理网内每台主机。曾在DC上测试过域组策略内的Windows防火墙设置,无论是新增规则还是直接开启允许ICMP之类的选项,Win7客户端都无效,最后不得不考虑批处理。批处理执行方式和前文的相同,域组策略在用户开机时自动执行。
二、配置
1、防火墙
net start MpsSvc
::开启服务
sc config MpsSvc start= auto
::开机启动 netsh advfirewall set allprofiles state on
::启用防火墙 netsh advfirewall firewall add rule name="Allow Ping" dir=in protocol=icmpv4 action=allow
netsh advfirewall firewall add rule name="FTP" protocol=TCP dir=in localport= action=allow
netsh advfirewall firewall add rule name="FTP" protocol=TCP dir=in localport= action=allow
netsh advfirewall firewall add rule name="SSH" protocol=TCP dir=in localport= action=allow
netsh advfirewall firewall add rule name="Telnet" protocol=TCP dir=in localport= action=allow
netsh advfirewall firewall add rule name="SMTP" protocol=TCP dir=in localport= action=allow
netsh advfirewall firewall add rule name="TFTP" protocol=UDP dir=in localport= action=allow
netsh advfirewall firewall add rule name="POP3" protocol=TCP dir=in localport= action=allow
netsh advfirewall firewall add rule name="HTTPS" protocol=TCP dir=in localport= action=allow
netsh advfirewall firewall add rule name="Netbios-ns" protocol=UDP dir=in localport= action=allow
netsh advfirewall firewall add rule name="Netbios-dgm" protocol=UDP dir=in localport= action=allow
netsh advfirewall firewall add rule name="Netbios-ssn" protocol=TCP dir=in localport= action=allow
netsh advfirewall firewall add rule name="Netbios-ds" protocol=TCP dir=in localport= action=allow
netsh advfirewall firewall add rule name="HTTP" protocol=TCP dir=in localport= action=allow
netsh advfirewall firewall add rule name="HTTP" protocol=TCP dir=in localport= action=allow
::常用端口
旧版语法(Win7&Win8.1测试无效)
@echo off
netsh firewall set opmode mode = enable
::启用防火墙 netsh firewall set icmpsetting type=ALL mode=enable
::允许ICMP
netsh firewall set service remotedesktop enable
netsh firewall set portopening tcp enable
2、远程桌面
@echo off
net start SessionEnv
net start TermService
::开启服务 sc config SessionEnv start= demand
sc config TermService start= demand
::开机手动启动 REG ADD "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d /f
::开启选项 netsh advfirewall firewall add rule name="Remote Desktop" protocol=TCP dir=in localport=3389 action=allow
::开启3389端口
本文出自 “运维菜鸟.log” 博客,谢绝转载!
Windows批处理:配置防火墙规则、开启远程桌面的更多相关文章
- Windows 2008开启远程桌面连接
具体请看下面的截图. 最重要的就是要打开远程允许远程桌面的默认端口 3389 的入站规则,我第一次弄,这一端口没打开,折腾了很久!!! 第一.首先打开“服务器管理器”—“配置”—“高级安全Window ...
- windows 2012 r2如何开启远程桌面
windows 2012 r2如何开启远程桌面 编写人:左丘文 2019-7-6 Windows 2012安装完成后需要开启远程桌面才可以远程连接,网上搜索了一下,有以下几个解决办法,虽说最后还是自己 ...
- win10不能被远程解决方案(开启远程桌面,防火墙仍不能被远程解决方案)
开启远程桌面,防火墙仍不能被远程解决方案 1.“Win+R”→“gpedit.msc” 2.依次展开“计算机配置”→“管理模版”→“系统”→“凭据分配”→找到“允许分配保存的凭据用于仅NTLM服务器身 ...
- 如何开启远程桌面连接功能?windows的远程桌面连接功能使用步骤
由于远程桌面的诞生,为电脑工作者提供了极大的便利.首先,推荐1款比较适合服务器管理的远程桌面: 可以管理1000+服务器/vps的远程桌面:IIS7远程桌面管理 开启远程桌面功能步骤: 1.右键点击电 ...
- win7开启远程桌面
1.启用windows防火墙 计算机管理----->服务----->Windows Firewall(双击进入,启动类型改为自动,点击应用,点击启动)2.启动gpedit.msc打开“本地 ...
- Windows 7 设置允许多用户同时远程桌面连接
有时候我们服务器安装的是Win7系统,远程登录桌面时,即使登录的是不同的管理账号,还是会提示把远程登录的人给踢下来.即系统只允许存在一个远程会话窗,不管是不是相同的用户. 下面讲解如何设置Win7让多 ...
- Windows与Linux如何实现相互远程桌面连接?
今天跟大家一起讨论下,利用Windows自带的远程桌面连接工具,实现远程Linux桌面及在Linux系统中远程Windows桌面 一.Windows远程Linux桌面 1)本次实验以CentOS 7. ...
- Powershell 开启远程桌面
function Set-RemoteDesktop { while($InNumber -ne 6) { Write-Host " ###################### ...
- Win7系统怎么开启远程桌面?Win7远程桌面怎么用(转)
远程桌面服务开启之后,可以方便的远程管理服务器或计算机.为生活和工作带来不少便利呢,很多小伙伴还不知道怎么开启win7远程桌面吧(下面咗嚛以内网远程桌面为例) 工具/原料 Win7 Win7远程桌 ...
随机推荐
- CSS魔法堂:Box-Shadow没那么简单啦:)
前言 说起box-shadow那第一个想法当然就是用来实现阴影,其实它还能用于实现其他好玩的效果的,本篇就打算说说box-shadow的那些事. 二话不说看效果 3D小球 <style typ ...
- “WPF老矣,尚能饭否”—且说说WPF今生未来(上):担心
近日微软公布了最新的WPF路线图,一片热议:对于老牌控件提供商葡萄城来说,这是WPF系列控件一个重要的机遇,因此,Spread Studio for WPF产品做了一次重要更新,并随着Spread S ...
- WCF学习系列四--【WCF Interview Questions – Part 4 翻译系列】
WCF Interview Questions – Part 4 This WCF service tutorial is part-4 in series of WCF Interview Qu ...
- 在Windows Server 2012 R2的Hyper-V中设置虚拟机启用增强会话模式
在Windows Server 2012 R2的Hyper-V中,可以为虚拟机提供一种全新的连接方式,就是“增强会话模式”,它将让您更加方便的对虚拟机进行操作,比如分辨率的调整.设备的加载,最为方便的 ...
- MessageBox的常用方法
一 函数原型及参数 function MessageBox(hWnd: HWND; Text, Caption: PChar; Type: Word): Integer; hWnd:对话框父窗口句柄, ...
- socket编程-java
一,网络编程中两个主要的问题 一个是如何准确的定位网络上一台或多台主机,另一个就是找到主机后如何可靠高效的进行数据传输. 在TCP/IP协议中IP层主要负责网络主机的定位,数据传输的路由,由IP地址可 ...
- spring入门(三)【事务控制】
在开发中需要操作数据库,进行增.删.改操作的过程中属于一次操作,如果在一个业务中需要更新多张表,那么任意一张表的更新失败,整个业务的更新就是失败,这时那些更新成功的表必须回滚,否则业务会出错,这时就要 ...
- PHP7 redis扩展安装
1.安装redis (1)下载:https://github.com/phpredis/phpredis/tree/php7 或下载http://pan.baidu.com/s/1i5DFrjn用sa ...
- 一起谈谈MD5加密算法
MD5是一个安全的散列算法,输入两个不同的明文不会得到相同的输出值,根据输出值,不能得到原始的明文,即其过程不可逆:所以要解密MD5没有现成的算法,只能用穷举法,把可能出现的明文,用MD5算法散列之后 ...
- 【Spring】浅析Spring框架的搭建
c目录结构: // contents structure [-] Spring是什么 搭建Spring框架 简单Demo 1,建立User类 2,建立Test类 3,建立ApplicationCont ...