執行個體層級公用 IP (Classic) 概觀Instance level public IP (Classic) overview

執行個體層級公用 IP (ILPIP) 是您可以直接指派至 VM 或雲端服務角色執行個體的公用 IP 位址,而不是指派至 VM 或角色執行個體所在的雲端服務。An instance level public IP (ILPIP) is a public IP address that you can assign directly to a VM or Cloud Services role instance, rather than to the cloud service that your VM or role instance reside in. ILPIP 不會取代指派給雲端服務的虛擬 IP (VIP)。An ILPIP doesn’t take the place of the virtual IP (VIP) that is assigned to your cloud service. 應該說是您可以用來直接連接到 VM 或角色執行個體的其他 IP 位址。Rather, it’s an additional IP address that you can use to connect directly to your VM or role instance.

重要

Azure 針對建立和使用資源方面,有二種不同的的部署模型:Resource Manager 和傳統Azure has two different deployment models for creating and working with resources: Resource Manager and classic. 本文涵蓋之內容包括使用傳統部署模型。This article covers using the classic deployment model. Microsoft 建議您透過 Resource Manager 建立 VM。Microsoft recommends creating VMs through Resource Manager. 請確定您了解 IP 位址 在 Azure 中的運作方式。Make sure you understand how IP addresses work in Azure.

ILPIP 和 VIP 之間的差異

如圖 1 所示,儘管通常是使用 VIP:<連接埠號碼> 來存取個別 VM,但還是會使用 VIP 來存取雲端服務。As shown in Figure 1, the cloud service is accessed using a VIP, while the individual VMs are normally accessed using VIP:<port number>. 將 ILPIP 指派給特定的 VM,就能直接使用該 IP 位址來存取 VM。By assigning an ILPIP to a specific VM, that VM can be accessed directly using that IP address.

當您在 Azure 中建立雲端服務時,對應的 DNS A 記錄即會自動建立,以允許透過完整格式的網域名稱 (FQDN) 存取服務,而不需使用實際的 VIP。When you create a cloud service in Azure, corresponding DNS A records are created automatically to allow access to the service through a fully qualified domain name (FQDN), instead of using the actual VIP. 相同程序也適用於 ILPIP,但可改為透過 FQDN 而不是 ILPIP 來允許存取 VM 或角色執行個體。The same process happens for an ILPIP, allowing access to the VM or role instance by FQDN instead of the ILPIP. 例如,若您建立名為 contosoadservice 的雲端服務,並設定名為 contosoweb 且具有兩個執行個體的 Web 角色,且 .cscfg 中的 domainNameLabel 設定為 WebPublicIP,Azure 將會為那些執行個體註冊下列 A 記錄:For instance, if you create a cloud service named contosoadservice, and you configure a web role named contosoweb with two instances, and in .cscfg domainNameLabel is set to WebPublicIP, Azure registers the following A records for the instances:

  • WebPublicIP.0.contosoadservice.cloudapp.netWebPublicIP.0.contosoadservice.cloudapp.net
  • WebPublicIP.1.contosoadservice.cloudapp.netWebPublicIP.1.contosoadservice.cloudapp.net
  • ......

注意

您只能針對每個 VM 或角色執行個體指派一個 ILPIP。You can assign only one ILPIP for each VM or role instance. 您可以針對每個訂用帳戶最多使用 5 個 ILPIP。You can use up to 5 ILPIPs per subscription. ILPIP 不支援多個 NIC VM。ILPIPs are not supported for multi-NIC VMs.

為什麼我要要求 ILPIP?Why would I request an ILPIP?

如果想要透過直接指派 IP 位址的方式連接到 VM 或角色執行個體,而不是使用雲端服務 VIP:<連接埠號碼>,請為 VM 或角色執行個體要求 ILPIP。If you want to be able to connect to your VM or role instance by an IP address assigned directly to it, rather than using the cloud service VIP:<port number>, request an ILPIP for your VM or your role instance.

  • 主動式 FTP:透過將 ILPIP 指派給 VM,VM 就可以在所有的連接埠上接收流量。Active FTP - By assigning an ILPIP to a VM, it can receive traffic on any port. VM 不需要端點就可以接收流量。Endpoints are not required for the VM to receive traffic. 如需有關 FTP 通訊協定的詳細資料,請參閱 FTP 通訊協定概觀See FTP Protocol Overview for details on the FTP protocol.
  • 輸出 IP:源自 VM 的輸出流量會對應至 ILPIP,因為來源與 ILPIP 可向外部實體唯一識別 VM。Outbound IP - Outbound traffic originating from the VM is mapped to the ILPIP as the source and the ILPIP uniquely identifies the VM to external entities.

注意

ILPIP 過去被稱為公用 IP (PIP) 位址。In the past, an ILPIP address was referred to as a public IP (PIP) address.

管理 VM 的 ILPIPManage an ILPIP for a VM

下列工作可讓您建立、指派和移除 VM 的 ILPIP:The following tasks enable you to create, assign, and remove ILPIPs from VMs:

如何在建立 VM 期間使用 PowerShell 要求 ILPIPHow to request an ILPIP during VM creation using PowerShell

下列 PowerShell 指令碼會建立名為 FTPService 的雲端服務、從 Azure 擷取映像、使用擷取的映像建立名為 FTPInstance 的 VM、設定要使用 ILPIP 的 VM,以及將 VM 加入新服務:The following PowerShell script creates a cloud service named FTPService, retrieves an image from Azure, creates a VM named FTPInstance using the retrieved image, sets the VM to use an ILPIP, and adds the VM to the new service:

New-AzureService -ServiceName FTPService -Location "Central US"

$image = Get-AzureVMImage|?{$_.ImageName -like "*RightImage-Windows-2012R2-x64*"}

#Set "current" storage account for the subscription. It will be used as the location of new VM disk

Set-AzureSubscription -SubscriptionName <SubName> -CurrentStorageAccountName <StorageAccountName>

#Create a new VM configuration object

New-AzureVMConfig -Name FTPInstance -InstanceSize Small -ImageName $image.ImageName `
| Add-AzureProvisioningConfig -Windows -AdminUsername adminuser -Password MyP@ssw0rd!! `
| Set-AzurePublicIP -PublicIPName ftpip | New-AzureVM -ServiceName FTPService -Location "Central US"

如果您想要指定其他儲存體帳戶作為新的 VM 磁碟位置,您可以使用 MediaLocation 參數:If you want to specify another storage account as the location of new VM disk, you can use MediaLocation parameter:

    New-AzureVMConfig -Name FTPInstance -InstanceSize Small -ImageName $image.ImageName `
     -MediaLocation https://management.core.windows.net/<SubscriptionID>/services/storageservices/<StorageAccountName> `
    | Add-AzureProvisioningConfig -Windows -AdminUsername adminuser -Password MyP@ssw0rd!! `
    | Set-AzurePublicIP -PublicIPName ftpip | New-AzureVM -ServiceName FTPService -Location "Central US"

如何擷取 VM 的 ILPIP 資訊How to retrieve ILPIP information for a VM

若要檢視使用上述指令碼所建立 VM 的 ILPIP 資訊,請執行下列 PowerShell 命令,並觀察 PublicIPAddressPublicIPName 的值:To view the ILPIP information for the VM created with the previous script, run the following PowerShell command and observe the values for PublicIPAddress and PublicIPName:

Get-AzureVM -Name FTPInstance -ServiceName FTPService

預期的輸出:Expected output:

DeploymentName              : FTPService
Name                        : FTPInstance
Label                       : 
VM                          : Microsoft.WindowsAzure.Commands.ServiceManagement.Model.PersistentVM
InstanceStatus              : ReadyRole
IpAddress                   : 100.74.118.91
InstanceStateDetails        : 
PowerState                  : Started
InstanceErrorCode           : 
InstanceFaultDomain         : 0
InstanceName                : FTPInstance
InstanceUpgradeDomain       : 0
InstanceSize                : Small
HostName                    : FTPInstance
AvailabilitySetName         : 
DNSName                     : http://ftpservice888.cloudapp.net/
Status                      : ReadyRole
GuestAgentStatus            :   Microsoft.WindowsAzure.Commands.ServiceManagement.Model.GuestAgentStatus
ResourceExtensionStatusList : {Microsoft.Compute.BGInfo}
PublicIPAddress             : 104.43.142.188
PublicIPName                : ftpip
NetworkInterfaces           : {}
ServiceName                 : FTPService
OperationDescription        : Get-AzureVM
OperationId                 : 568d88d2be7c98f4bbb875e4d823718e
OperationStatus             : OK

如何從 VM 移除 ILPIPHow to remove an ILPIP from a VM

若要移除在上述指令碼中加入 VM 的 ILPIP,請執行下列 PowerShell 命令:To remove the ILPIP added to the VM in the previous script, run the following PowerShell command:

Get-AzureVM -ServiceName FTPService -Name FTPInstance | Remove-AzurePublicIP | Update-AzureVM

如何將 ILPIP 加入現有的 VMHow to add an ILPIP to an existing VM

若要將 ILPIP 加入至使用上述指令碼建立的 VM,請執行下列命令:To add an ILPIP to the VM created using the script previous, run the following command:

Get-AzureVM -ServiceName FTPService -Name FTPInstance | Set-AzurePublicIP -PublicIPName ftpip2 | Update-AzureVM

管理雲端服務角色執行個體的 ILPIPManage an ILPIP for a Cloud Services role instance

若要將 ILPIP 加入至雲端服務角色執行個體,請完成下列步驟:To add an ILPIP to a Cloud Services role instance, complete the following steps:

  1. 完成如何設定雲端服務文章中的步驟,以下載雲端服務的 .cscfg 檔案。Download the .cscfg file for the cloud service by completing the steps in the How to Configure Cloud Services article.

  2. 加入 InstanceAddress 元素來更新 .cscfg 檔案。Update the .cscfg file by adding the InstanceAddress element. 下列範例會加入一個名稱為 MyPublicIP 的 ILPIP 到名稱為 WebRole1 的角色執行個體:The following sample adds an ILPIP named MyPublicIP to a role instance named WebRole1:

    <?xml version="1.0" encoding="utf-8"?>
    <ServiceConfiguration serviceName="ILPIPSample" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="4" osVersion="*" schemaVersion="2014-01.2.3">
      <Role name="WebRole1">
        <Instances count="1" />
          <ConfigurationSettings>
        <Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=true" />
          </ConfigurationSettings>
      </Role>
      <NetworkConfiguration>
        <AddressAssignments>
          <InstanceAddress roleName="WebRole1">
        <PublicIPs>
          <PublicIP name="MyPublicIP" domainNameLabel="WebPublicIP" />
            </PublicIPs>
          </InstanceAddress>
        </AddressAssignments>
      </NetworkConfiguration>
    </ServiceConfiguration>
    
  3. 完成如何設定雲端服務文章中的步驟,以上傳雲端服務的 .cscfg 檔案。Upload the .cscfg file for the cloud service by completing the steps in the How to Configure Cloud Services article.

如何擷取雲端服務的 ILPIP 資訊How to retrieve ILPIP information for a Cloud Service

若要檢視每個角色執行個體的 ILPIP 資訊,請執行下列 PowerShell 命令,並觀察 PublicIPAddressPublicIPNamePublicIPDomainNameLabelPublicIPFqdns 的值:To view the ILPIP information per role instance, run the following PowerShell command and observe the values for PublicIPAddress, PublicIPName, PublicIPDomainNameLabel and PublicIPFqdns:

Add-AzureAccount

$roles = Get-AzureRole -ServiceName <Cloud Service Name> -Slot Production -RoleName WebRole1 -InstanceDetails

$roles[0].PublicIPAddress
$roles[1].PublicIPAddress

您也可以使用 nslookup 來查詢子網域的 A 記錄:You may also use nslookup to query the sub-domain's A record:

nslookup WebPublicIP.0.<Cloud Service Name>.cloudapp.net

後續步驟Next steps