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

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. [設定]で、[Inbound security rules(受信セキュリティルール)]をクリックします。
  2. [Add(追加)]をクリックします。
  3. 以下の値を入力します。
    • 宛先ポートの範囲80/443
    • プロトコルTCP
    • 名前ポート 80/ポート 443 ルール
    • 優先度100/101

    ポート80は任意です。

  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": [], . . . }