Azure PowerShell (13) 批量设置Azure ARM Network Security Group (NSG)
《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)的更多相关文章
- Azure PowerShell (14) 批量导出Azure ASM ACL和ARM NSG配置信息
<Windows Azure Platform 系列文章目录> 最近有一个客户需求,需要批量导出Azure Classic VM的ACL (Access Control List), 还有 ...
- Azure PowerShell (15) 批量导出Azure ASM/ARM VM信息
<Windows Azure Platform 系列文章目录> 客户又提出新的需求,需要知道所有订阅下的虚拟机数量.运行情况等信息. 我花了点时间,写了一个PowerShell脚本,发布到 ...
- Azure PowerShell (5) 使用Azure PowerShell创建简单的Azure虚拟机和Linux虚拟机
<Windows Azure Platform 系列文章目录> 本文介绍的是国外的Azure Global.如果是国内由世纪互联运维的Azure China,请参考这篇文档: Azure ...
- 使用Windows Azure PowerShell远程管理Windows Azure虚拟机
对于Windows Azure,如果你还在使用windowsazure.com门户来管理虚拟机,那就显得不怎么高上大了.Windows Azure PowerShell 是一个功能强大的脚本环境,可用 ...
- Azure ARM (22) 使用Azure PowerShell创建Azure RM VM
<Windows Azure Platform 系列文章目录> 在Azure China获得VM Image,可以执行下面的脚本. Get-AzureRmVMImagePublisher ...
- Windows Azure HandBook (3) 浅谈Azure安全性
<Windows Azure Platform 系列文章目录> 2015年3月5日-6日,参加了上海的Azure University活动.作为桌长与微软合作伙伴交流了Azure相关的技术 ...
- Windows Azure Virtual Network (6) 设置Azure Virtual Machine固定公网IP (Virtual IP Address, VIP) (1)
<Windows Azure Platform 系列文章目录> 注意:本文介绍的是Global Azure (http://www.windowsazure.com),如果你使用的是由世纪 ...
- 【Azure Developer】使用Java SDK代码创建Azure VM (包含设置NSG,及添加数据磁盘SSD)
在参考Azure官方文档进行VM创建时,发现其中没有包含如何设置NSG的内容,以及如何在创建时就添加数据磁盘的代码(设置磁盘为SSD类型).本文的内容以"使用 Java 创建和管理 Azur ...
- 使用 Azure PowerShell 模块创建和管理 Windows VM
Azure 虚拟机提供完全可配置的灵活计算环境. 本教程介绍 Azure 虚拟机的基本部署项目,例如选择 VM 大小.选择 VM 映像和部署 VM. 你将学习如何执行以下操作: 创建并连接到 VM 选 ...
随机推荐
- 关于Q-LEARNING的优化
Q-LEARNING 最后得到的一个图寻路最佳路径:---直接转化为图关于多顶点深度遍历热度传递 V(level+1) = 0.8 * Max(Vi(level)) 这个方法可以在O时间收敛 原方 ...
- Java 容器的使用及数组、List、Set 的相互转换
0. Utils 字符串数组的排序: Set<String> set = new TreeSet<String>(); Collections.addAll(set, args ...
- Buildroot lmbench使用方法
/********************************************************************** * Buildroot lmbench使用方法 * 说明 ...
- IIS 7上导入SSL证书
1.将SSL证书文件上传至服务器 2.导入证书 1)在IIS设置项中,打开‘服务器证书’ 2)选择导入 3)将网站绑定SSL证书
- HDU 1160:FatMouse's Speed(LIS+记录路径)
FatMouse's Speed Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- try catch之ajax调错
- PTA——数列求和
PTA 7-34 求分数序列前N项和 #include<stdio.h> int main() { int i,n; ,fm = ,sum = ; scanf("%d" ...
- 2017.4.5 Strom
Strom是分布式实时计算系统,它对于实时计算的意义类似于hadoop对于批处理的意义.与Storm关系密切的语言:核心代码用clojure书写,实用程序用python开发,使用java开发拓扑. S ...
- LeetCode - Number of Distinct Islands
Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) conn ...
- git pull refusing to merge unrelated histories
1. 简介 最近的项目开发环境我换到实验室的机器上了,毕竟是台式机,速度杠杠的.于是出现了一个问题,台式机上面的代码我笔记上的代码同步的问题.于是想到了Git这个强大的工具.关于git的简介我就不说了 ...