ネットワーキングを構成する

Microsoft Azure仮想マシン、セキュリティグループ、インバウンドセキュリティルールを作成し、セキュリティルールを仮想マシンに関連付けます。

セキュリティグループを作成する

  1. Microsoft Azure Portalにサインインします。
  2. メニューからすべてのサービス(All Services)を選択してリソースグループ(Resource Groups)を検索します。または、お気に入りのリストからリソースグループ(Resource Groups)を選択します。
  3. ネットワークセキュリティルール一式を追加するリソースグループの名前をクリックします。
  4. 追加(Add)をクリックします。
  5. ネットワークセキュリティグループ(Network security group)を検索して選択します。
  6. 作成(Create)を選択します。
  7. セキュリティグループの名前を付けます。
  8. 作成・レビュー(Create and Review)をクリックします。
  9. 作成(Create)をクリックします。

受信セキュリティルールを作成する

  1. 設定(Settings)で、受信セキュリティルール(Inbound security rules)をクリックします。
  2. 追加(Add)をクリックします。
  3. 以下の値を入力します。
    • 宛先ポートの範囲(Destination port range)80/443
    • プロトコル(Protocol)TCP
    • 名前(Name)Port80/Port443 Rule
    • 優先度(Priority)100/101
  4. 追加(Add)をクリックします。
  5. これらの手順を繰り返し、ポート80および443のルールを作成します。

セキュリティルールを関連付ける

  1. ホーム(HOME) > VMに移動します。
  2. Access Gateway仮想マシンの名前をクリックします。
  3. 設定(Settings)で、サブネット(Subnets)を選択します。
  4. 関連付け(Associate)をクリックします。
  5. 以前作成したセキュリティグループを検索し、仮想マシンに関連付けます。
  1. az network nsg createコマンドを使用して、ネットワークセキュリティを作成します。

    az network nsg create --resource-group AccessGateway --location <location> --name <name>

    • <location>はセキュリティグループを格納する地域です。
    • <resource-group>は以前作成したリソースグループの名前です。
    • <name>は新しいセキュリティグループの名前です。

    以下は、パラメーターに値を入力したaz network nsg createコマンドの例です。

    az network nsg create --resource-group AccessGateway --location eastus --name AGSecurityGroup

    az network nsg createコマンドを実行すると、次の結果が表示されます。

    { "NewNSG": {
       "defaultSecurityRules": [
       {
      "destinationAddressPrefixes": [],
      "destinationApplicationSecurityGroups": null,
       . . . ]}
    }	
  2. az network nsg rule create コマンドを使用してポート80のネットワークセキュリティルールを追加します。ポート80は任意です。

    az network nsg rule create \ --resource-group <resource-group>\ --nsg-name <network-security-group>\ --name <rule-name>\ --protocol tcp \ --priority 1000 \ --destination-port-range 80

    • <resource-group>は以前に作成したリソースグループの名前です。
    • <nework-security-group>は新しいセキュリティグループの名前です。
    • <rule-name>はルールの名前です。

    以下は、パラメーターに値を入力したaz network nsg rule create コマンドの例です。

    az network nsg rule create --resource-group AccessGateway \
    --nsg-name AGSecurityGroup --name Port80GroupRule \
    --protocol tcp --priority 1000 --destination-port-range 80

    az network nsg rule create コマンドを実行すると、次の結果が表示されます。

    {- Finished
        "access": "Allow",
        "description": null,
        "destinationAddressPrefix": "*",
        . . .
    }
  3. az network nsg rule create コマンドを使用してポート443のネットワークセキュリティルールを追加します。

    az network nsg rule create --resource-group AccessGateway --nsg-name AGSecurityGroup \ --name Port443GroupRule --protocol tcp --priority 1001 --destination-port-range 443

    az network nsg rule create コマンドを実行すると、次の結果が表示されます。

    {- Finished
        "access": "Allow",
        "description": null,
        "destinationAddressPrefix": "*",
        . . .
    }	
  4. az network nic updateコマンドを使用して、新しいセキュリティグループをVM nicに関連付けます。

    az network nic update \ --resource-group <resource-group>\ --name <nic-name>\ --network-security-group <security-group-name>

    • <resource-group>は以前作成したリソースグループの名前です。
    • <nic-name>はセキュリティグループと関連付けられるNICの名前です。
    • <nework-security-group>は新しいセキュリティグループの名前です。

    以下は、パラメーターに値を入力したaz network nic updateコマンドの例です。

    # obtain the name of the nic.
    az vm nic list --resource-group AccessGateway --vm-name "OAG5.0vm"
    [{
     "id": "/subscriptions/. . . /networkInterfaces/OAG5.0VMVMNic",
         . . .
    }]
    
    # Assign the security group to the nic
    az network nic update \
        --resource-group AccessGateway\
        --name OAG5.0VMMVNic
        --network-security-group AGSecurityGroup 

    az network nic updateコマンドを実行すると、次の結果が表示されます。

    {{"dnsSettings": {
        "dnsSettings": {
        appliedDnsServers": [],
        . . .
    }