LoginSignup
1
0

More than 1 year has passed since last update.

Microsoft-hosted agents の IP アドレス範囲は Mac だけリージョンと異なる範囲にある

Last updated at Posted at 2021-12-20

本記事は Azure DevOps | Advent Calendar 2021 の 21 日目の記事です。

Microsoft-hosted agents の IP アドレス範囲を気にする人向けの雑記です。

タイトルの通りで Windows と Linux (Ubuntu) は AzureCloud.<Region> の IP アドレス範囲を持っていますが、 Mac だけは GitHub 独自の macOS クラウドでホストされているようで、 IP アドレスの範囲が異なります。
もし、グローバル IP を使って IP の許可リストなどを作る場合、 Mac だけは設定を変える必要があるので気を付けましょう。

IP アドレス範囲の取得方法

Mac

GitHub metadata API の Meta - GitHub Docs を使って取得できます。

curl \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/meta

actions 配列の中に Mac の IP アドレス範囲が含まれています。

Windows / Linux

Azure IP Ranges の weekly json ファイル Download Azure IP Ranges and Service Tags – Public Cloud from Official Microsoft Download Center をダウンロードして取得します。

恐らく日本の皆さんが使っているであろう東南アジアリージョンの場合は values -> AzureCloud.southeastasia -> addressPrefixes に Windows と Linux の IP アドレス範囲が含まれています。

IP アドレスを検証してみる

Azure Pipelines を実行して Microsoft-hosted agents のグローバル IP アドレスを表示して、先ほど取得した IP アドレス範囲にあるか確認してみます。

検証のための azure-pipelines.yml

Mac / Linux / Windows それぞれでグローバル IP を表示するスクリプトを実行しています。

trigger:
- main

jobs:
- job: Linux
  pool:
    vmImage: 'ubuntu-latest'
  steps:
  - script: dig +short myip.opendns.com @resolver1.opendns.com
- job: macOS
  pool:
    vmImage: 'macOS-latest'
  steps:
  - script: dig +short myip.opendns.com @resolver1.opendns.com
- job: Windows
  pool:
    vmImage: 'windows-latest'
  steps:
  - script: nslookup myip.opendns.com. resolver1.opendns.com

macOS の結果

Agent の IP アドレスは 199.19.85.226 でした。

Image from Gyazo

GitHub metadata API で取得した IP アドレス範囲に含まれています。※Json ファイルは大きいので省略しています。

{
  "actions": [
    "199.19.85.224/29",
  ],
}

Linux の結果

Agent の IP アドレスは 13.76.135.249 でした。

Image from Gyazo

AzureCloud.southeastasia の addressPrefixes に IP アドレス範囲が含まれています。※Json ファイルは大きいので省略しています。

{
  "changeNumber": 180,
  "cloud": "Public",
  "values": [
    {
      "name": "AzureCloud.southeastasia",
      "id": "AzureCloud.southeastasia",
      "properties": {
        "addressPrefixes": [
          "13.76.0.0/16",
        ]
      }
    }
  ]
}

Windows の結果

Agent の IP アドレスは 20.212.57.174 でした。

Image from Gyazo

こちらも Linux と同じように AzureCloud.southeastasia の addressPrefixes に IP アドレス範囲が含まれています。※Json ファイルは大きいので省略しています。

{
  "changeNumber": 180,
  "cloud": "Public",
  "values": [
    {
      "name": "AzureCloud.southeastasia",
      "id": "AzureCloud.southeastasia",
      "properties": {
        "addressPrefixes": [
          "20.212.0.0/16",
        ]
      }
    }
  ]
}

参考文献

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0