1

私は Windows Azure を初めて使用し、ネットワークに関する知識が限られています。仮想ネットワークを持つように構成された Windows azure で VM を実行しています。したがって、[ダッシュボード] の下に、マシンには次の情報が表示されます。

Public virtual IP address (VIP): 168.62.210.xx
Internal IP Address: 10.1.1.4

そのマシンで、ポート 2641 でリッスンするカスタマイズされたサーバーを実行しています。

Name   Protocol Public Port Private Port Load Balanced
Handle TCP      2641        2641         NO

基本的に着信トラフィックを 168.62.210.xx:2641 から 10.1.1.4:2641 に、またはその逆 (10.1.1.4 から 168.62.210.xx) にルーティングする NAT があると思いますか?

そのポートが機能しているかどうかを確認する方法はありますか?

Linux では、の出力nc -z 168.62.210.xx 2641; echo $?は 1 です (ポートが開いていないことを意味します)。

サーバーをセットアップする場合、サーバーを 168.62.210.xx ではなく 10.1.1.4 にバインドする必要があると思いますか?

どんな助けでも大歓迎です。

ありがとう、

4

2 に答える 2

0

VM ネットワーク インターフェイスに関連付けられたネットワーク セキュリティ グループで、受信および送信セキュリティ ルールが構成されていることを確認してください。

以下の Azure ポータルの画像に似ています。 ここに画像の説明を入力

Azure でネットワーク ルールを構成するもう 1 つの方法は、Azure PowerShell SDK を呼び出すことです。以下のコード スニペットを利用できます。

# 0. set the target resource group name and target vm name
$ResourceGroupName = "ocoslab-eric" # set your own resource group
$VMName = "vm-eric-demo" # set your own vm name

# 1. get the vm information
$VM = Get-AzureRmVM -ResourceGroupName $ResourceGroupName -Name $VMName

# 2. get the network interface information
$NICID = $VM.NetworkInterfaceIDs[0]
$NICName = ([regex]"/.*/(.*?)$").Match($NICID).Groups[1].Value
$NICResourceGroupName = ([regex]"/resourceGroups/(.*?)/").Match($NICID).Groups[1].Value
$NIC = Get-AzureRmNetworkInterface -Name $NICName -ResourceGroupName $NICResourceGroupName

# 3. get or create the associated security network group
If ($NIC.NetworkSecurityGroup -eq $null) {
    $NSG = New-AzureRmNetworkSecurityGroup -Name 'custom-nsg' -Location $VM.Location -ResourceGroupName $ResourceGroupName
    $NIC.NetworkSecurityGroup = $NSG
} Else {
    $NSGId = $NIC.NetworkSecurityGroup.Id
    $NSGName = ([regex]"/.*/(.*?)$").Match($NSGId).Groups[1].Value
    $NSGResourcGroup = ([regex]"/resourceGroups/(.*?)/").Match($NSGId).Groups[1].Value
    $NSG = Get-AzureRmNetworkSecurityGroup -Name $NSGName -ResourceGroupName $NSGResourcGroup
    $NIC.NetworkSecurityGroup = $NSG
}

# 4. create security rule to allow the port and associate with the security network group
# Parameter explanation:
#   a.  -Name                       Specifies the name of a network security rule configuration
#   b.  -Access                     Specifies whether network traffic is allowed or denied. psdx_paramvalues Allow and Deny.
#   c.  -Protocol                   Specifies the network protocol that a rule configuration applies to. 
#                                   - Tcp
#                                   - Udp
#                                   - Wildcard character (*) to match both 
#   d.  -Direction                  Specifies whether a rule is evaluated on incoming or outgoing traffic. psdx_paramvalues Inbound and Outbound.
#   e.  -SourceAddressPrefix        Specifies a source address prefix. psdx_paramvalues
#                                   - A CIDR
#                                   - A source IP range
#                                   - A wildcard character (*) to match any IP address.
#   f.  -SourcePortRange            Specifies a source port or range. This value is expressed as an integer, as a range between 0 and 65535, or as a wildcard character (*) to match any source port.
#   g.  -DestinationAddressPrefix   Specifies a destination address prefix. psdx_paramvalues
#                                   - A Classless Interdomain Routing (CIDR) address
#                                   - A destination IP address range
#                                   - A wildcard character (*) to match any IP address  
#   h.  -DestinationPortRange       Specifies a destination port or range. psdx_paramvalues
#                                   - An integer
#                                   - A range of integers between 0 and 65535
#                                   - A wildcard character (*) to match any port
#   i.  -Priority                   Specifies the priority of a rule configuration. psdx_paramvalues An integer between 100 and 4096. The priority number must be unique for each rule in the collection. The lower the priority number, the higher the priority of the rule.

Add-AzureRmNetworkSecurityRuleConfig  -NetworkSecurityGroup $NSG `
                -Name 'custom_rule_name' `
                -Access Allow `
                -Protocol Tcp `
                -Direction Inbound `
                -SourceAddressPrefix Internet `
                -SourcePortRange * `
                -DestinationAddressPrefix * `
                -DestinationPortRange 3389 `
                -Priority 100 | Out-Null

# 5 finally, set the NetworkSecurityGroup and NetworkInterface state
Set-AzureRmNetworkSecurityGroup -NetworkSecurityGroup $NSG | Out-Null
Set-AzureRmNetworkInterface -NetworkInterface $NIC | Out-Null

Write-Host "Done"

また、ダウンロード可能な完全なコード サンプルについては、PowerShell で Azure 仮想マシンのポートを管理する方法に関するページを参照してください。

于 2016-11-21T03:17:01.563 に答える