温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

新建Azure VM或者对现有的VM使用PIP

发布时间:2020-05-31 16:36:33 来源:网络 阅读:818 作者:jeffcsc 栏目:编程语言

 在前两篇的博客中主要讲解了对VIP的固定,VIP是针对云服务,而有时我们需要针对虚拟机的固定,比如当我做FTP服务器的时候,如果使用VIP的话,我们需要在外部防火墙内针对主动可被动端口开启许多,给我们的部署带来了许多的麻烦,这时候PIP就比较适合我们了,PIP可以直接穿透外部防火墙到虚拟机,不在单独在外部防火墙中开启这么多的端口,但是PIP的这个特性也决定了他的不安全性,同时PIP 在固定但是虚拟机重启后也会改变,这是我们在使用时也是需要特别注意的。

  废话不多少了,直接开始动手实验吧:


  1. 创建虚拟机并得到一个VIP


新建Azure VM或者对现有的VM使用PIP

新建Azure VM或者对现有的VM使用PIP


2. 从公网申请PIP地址并分配给现有的VM Instance


新建Azure VM或者对现有的VM使用PIP

新建Azure VM或者对现有的VM使用PIP


3. 查看PIP


新建Azure VM或者对现有的VM使用PIP


4. VM重启

新建Azure VM或者对现有的VM使用PIP


5. 再次查看PIP,IP已经发生了改变


新建Azure VM或者对现有的VM使用PIP


备注:及时PIP使用powershell固定后VM重启也会改变



 在新建VM时保留PIP

(1)首先使用命令从公网获得一个PIP

PS C:\> New-AzureReservedIP –ReservedIPName "JEFFPIP" –Label "jeffPIP" –Location "China North"

详细信息: 18:54:18 - Begin Operation: New-AzureReservedIP

详细信息: 18:54:51 - Completed Operation: New-AzureReservedIP


OperationDescription                    OperationId                             OperationStatus

--------------------                    -----------                             ---------------

New-AzureReservedIP                     b882b7f3-8661-4d37-a92a-8360ba520cd1    Succeeded


(2)查看成功获得的PIP

PS C:\> Get-AzureReservedIP

详细信息: 18:55:52 - Begin Operation: Get-AzureReservedIP

详细信息: 18:55:53 - Completed Operation: Get-AzureReservedIP



ReservedIPName       : JEFFPIP

Address              : 139.219.14.132

Id                   : 35b80824-29b8-4491-bd10-2fec1922048a

Label                : jeffPIP

Location             : China North

State                : Created

InUse                : False

ServiceName          :

DeploymentName       :

OperationDescription : Get-AzureReservedIP

OperationId          : a1b79933-22f2-4a15-a2ea-61b94764e066

OperationStatus      : Succeeded


(3)使用映像或者磁盘在创建VM的时候使用此PIP(这里主要演示使用映像创建的)

PS C:\> New-AzureVMConfig -Name 'centos' -InstanceSize Small -ImageName jeffcentos-20150402-800866 | Add-AzureProvisioni

ngConfig -Linux -LinuxUser "azureuser" -Password "P@ssw0rd123" | New-AzureVM -ServiceName "testpip" –ReservedIPName "JEF

FPIP"  -VNetName 'chinnort'

警告: Subnet should be specified when deploying VMs in a VNET: centos

详细信息: 19:03:16 - Begin Operation: New-AzureVM - Create Deployment with VM centos

详细信息: 19:04:23 - Completed Operation: New-AzureVM - Create Deployment with VM centos


OperationDescription                    OperationId                             OperationStatus

--------------------                    -----------                             ---------------

New-AzureVM                             03626a98-22ed-45b0-bd3f-5c8f66a57067    Succeeded


(4)查看已经使用PIP的VM

PS C:\> Get-AzureReservedIP

详细信息: 19:09:16 - Begin Operation: Get-AzureReservedIP

详细信息: 19:09:19 - Completed Operation: Get-AzureReservedIP



ReservedIPName       : JEFFPIP

Address              : 139.219.14.132

Id                   : 35b80824-29b8-4491-bd10-2fec1922048a

Label                : jeffPIP

Location             : China North

State                : Created

InUse                : True

ServiceName          : testpip

DeploymentName       : testpip

OperationDescription : Get-AzureReservedIP

OperationId          : c2494b48-d504-4535-b885-ee45043dd785

OperationStatus      : Succeeded



备注:在我们创建的时候有时候会遇到下面这个错误:

PS C:\> New-AzureVMConfig -Name 'centos' -InstanceSize Small -ImageName jeffcentos-jeffcentos-0-201504020640350599 | Add-AzureProvisioningConfig -Linux -LinuxUser "azureuser" -Password "P@ssw0rd123" | New-AzureVM -ServiceName "testpip" –ReservedIPName "JEFFPIP"  -VNetName 'chinnort'

New-AzureVMConfig : Must specify MediaLocation or set a current storage account using Set-AzureSubscription.

所在位置 行:1 字符: 1

+ New-AzureVMConfig -Name 'centos' -InstanceSize Small -ImageName jeffcentos-jeffc ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [New-AzureVMConfig], ArgumentException

    + FullyQualifiedErrorId : System.ArgumentException,Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.NewAzure

   VMConfigCommand

主要使我们在此订阅下有多个存储账号,这里是要求你制定一个存储账号来存储VM,使用一下办法解决

PS C:\> Set-Set-AzureSubscription -SubscriptionName "订阅账号" -CurrentStorageAccountName "存储账号"。

查看存储账号:Get-AzureStorageAccount

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI