《Windows Azure Platform 系列文章目录

  刚刚在帮助一个合作伙伴研究需求,他们的虚拟机全面的网络安全组(Network Security Group, NSG)会经常变动,如果手动修改非常麻烦。

  看看是否有批量设置的方法。我仔细研究了一下,记一下笔记。

  注意:这里介绍的是Azure ARM模式下的,虚拟机的Azure NSG网络安全组。

  前提需求:

  1.安装Azure PowerShell

  2.Azure ARM模式下的资源

  具体运行的Azure PowerShell

Add-AzureRmAccount -EnvironmentName AzureChinaCloud
#在弹出的界面中,输入用户名和密码,则登陆通过
#不过关闭PowerShell以后,下次要重新进行身份验证 #选择相应的订阅名称:
Select-AzureRmSubscription -SubscriptionName 'Training'| Select-AzureRmSubscription #请注意下面的NSG必须之前是已经存在的
$resourceGroupName='LeiLinuxRG'
$nsgName= 'LeiCentOS68-nsg' #创建允许外部对3306端口访问,源IP必须是192.168.1.0/24
$ruleName1= 'Inbound3306-rule'
$sourceIP= '192.168.1.0/24'
$destinationPort = 3306 $nsg = Get-AzureRmNetworkSecurityGroup -Name $nsgName -ResourceGroupName $resourceGroupName $nsg | Add-AzureRmNetworkSecurityRuleConfig -Name $ruleName1 -Description "Allow 3306" -Access `
Allow -Protocol Tcp -Direction Inbound -Priority 100 -SourceAddressPrefix $sourceIP `
-SourcePortRange * -DestinationAddressPrefix * -DestinationPortRange $destinationPort #创建允许外部对3389端口访问,源IP必须是192.168.1.0/24
$ruleName2= 'Inbound3389-rule'
$destinationPort = 3389 $nsg | Add-AzureRmNetworkSecurityRuleConfig -Name $ruleName2 -Description "Allow RDP" -Access `
Allow -Protocol Tcp -Direction Inbound -Priority 110 -SourceAddressPrefix $sourceIP `
-SourcePortRange * -DestinationAddressPrefix * -DestinationPortRange $destinationPort $nsg | Set-AzureRmNetworkSecurityGroup

Azure PowerShell (13) 批量设置Azure ARM Network Security Group (NSG)的更多相关文章

  1. Azure PowerShell (14) 批量导出Azure ASM ACL和ARM NSG配置信息

    <Windows Azure Platform 系列文章目录> 最近有一个客户需求,需要批量导出Azure Classic VM的ACL (Access Control List), 还有 ...

  2. Azure PowerShell (15) 批量导出Azure ASM/ARM VM信息

    <Windows Azure Platform 系列文章目录> 客户又提出新的需求,需要知道所有订阅下的虚拟机数量.运行情况等信息. 我花了点时间,写了一个PowerShell脚本,发布到 ...

  3. Azure PowerShell (5) 使用Azure PowerShell创建简单的Azure虚拟机和Linux虚拟机

    <Windows Azure Platform 系列文章目录> 本文介绍的是国外的Azure Global.如果是国内由世纪互联运维的Azure China,请参考这篇文档: Azure ...

  4. 使用Windows Azure PowerShell远程管理Windows Azure虚拟机

    对于Windows Azure,如果你还在使用windowsazure.com门户来管理虚拟机,那就显得不怎么高上大了.Windows Azure PowerShell 是一个功能强大的脚本环境,可用 ...

  5. Azure ARM (22) 使用Azure PowerShell创建Azure RM VM

    <Windows Azure Platform 系列文章目录> 在Azure China获得VM Image,可以执行下面的脚本. Get-AzureRmVMImagePublisher ...

  6. Windows Azure HandBook (3) 浅谈Azure安全性

    <Windows Azure Platform 系列文章目录> 2015年3月5日-6日,参加了上海的Azure University活动.作为桌长与微软合作伙伴交流了Azure相关的技术 ...

  7. Windows Azure Virtual Network (6) 设置Azure Virtual Machine固定公网IP (Virtual IP Address, VIP) (1)

    <Windows Azure Platform 系列文章目录> 注意:本文介绍的是Global Azure (http://www.windowsazure.com),如果你使用的是由世纪 ...

  8. 【Azure Developer】使用Java SDK代码创建Azure VM (包含设置NSG,及添加数据磁盘SSD)

    在参考Azure官方文档进行VM创建时,发现其中没有包含如何设置NSG的内容,以及如何在创建时就添加数据磁盘的代码(设置磁盘为SSD类型).本文的内容以"使用 Java 创建和管理 Azur ...

  9. 使用 Azure PowerShell 模块创建和管理 Windows VM

    Azure 虚拟机提供完全可配置的灵活计算环境. 本教程介绍 Azure 虚拟机的基本部署项目,例如选择 VM 大小.选择 VM 映像和部署 VM. 你将学习如何执行以下操作: 创建并连接到 VM 选 ...

随机推荐

  1. MySQL添加可重复执行列

    一.information_schema数据库表说明: SCHEMATA表:提供了当前mysql实例中所有数据库的信息.是show databases的结果取之此表. TABLES表:提供了关于数据库 ...

  2. 清除chrome浏览器HSTS缓存

    如果你的网站启用了HSTS 在chrome中会用缓存效果,即使你的站点取消了HSTS,下次访问时,仍旧会自动给你重定向到HSTS. 那么如何清除 HSTS呢? chrome://net-interna ...

  3. pytorch如何能够保证模型的可重复性

    问题背景是这样的: 我用了自己定义了pytorch中的模型,并且,在main函数中设置了随机种子用来保证模型初始化的参数是一致的,同时pytorch中的随机种子也能够影响dropout的作用,见链接 ...

  4. Codeforces483B. Friends and Presents(二分+容斥原理)

    题目链接:传送门 题目: B. Friends and Presents time limit per test second memory limit per test megabytes inpu ...

  5. linux php.ini文件没有指向 不生效

    phpinfo下查看: 命令行下查看 :php -i | grep "Loaded Configuration File" 解决: 使用命令去追踪错误: strace  /usr/ ...

  6. Ideal部署web工程

  7. yum小结

    1.查看系统默认安装的yum# rpm -qa|grep yum2.卸载yum# rpm -e yum-fastestmirror-... yum-metadata-parser-... yum-3. ...

  8. CentOS7.0防火墙以及开关机命令

    CentOS 7.0默认使用的是firewall作为防火墙 查看防火墙状态firewall-cmd --state 停止firewallsystemctl stop firewalld.service ...

  9. php基础-6

    类的继承和方法重写 <?php class people{ public function __construct($name, $age, $sex) { $this->age = $a ...

  10. struts2文件上传1

    <form action="hello/UploadAction_upload.action" enctype="multipart/form-data" ...