LoginSignup
6
1

More than 3 years have passed since last update.

GCP - Cloud Shellのアクセス元グローバルIPを特定する方法

Last updated at Posted at 2019-07-16

概要

sshのための22番ポートでアクセス元制限をする際、ホワイトリスト方式で制限するとGCPコンソールやCloud Shellからのssh接続ができない問題に直面すると思います。

その際にGoogleからのアクセス元IP Rangeを特定する方法を説明していきます。

目次

  • Cloud Shellとは
  • Googleのアクセス元IPアドレスのRangeを特定する方法
    • Googleのアクセス元IPアドレスの一覧

Cloud Shellとは

Cloud Shellの説明は弊社記事を参照ください。

Googleのアクセス元IPアドレスのRangeを特定する方法

Googleのアクセス元IPアドレスのRangeはGoogleの公開SPFレコードに記載されているIPアドレスとなります。

https://cloud.google.com/compute/docs/ssh-in-browser#ssherror
https://support.google.com/a/answer/60764?hl=ja

なお、アクセス元IPのRangeは予告なく変更される可能性があります。

それでは実際に特定してみましょう。

まずはSPFのアクセス元のドメイン一覧を特定します。

$ nslookup -q=TXT _spf.google.com 8.8.8.8

#出力結果
Server:     8.8.8.8
Address:    8.8.8.8#53

Non-authoritative answer:
_spf.google.com text = "v=spf1 include:_netblocks.google.com include:_netblocks2.google.com include:_netblocks3.google.com ~all"

Authoritative answers can be found from:

対象のドメインは以下となります。
_netblocks.google.com
_netblocks2.google.com
_netblocks3.google.com

次にこのドメインのtxtレコードを参照し、アクセス元のIPを特定していきます。

nslookup -q=TXT _netblocks.google.com 8.8.8.8

#出力結果
Server:     8.8.8.8
Address:    8.8.8.8#53

Non-authoritative answer:
_netblocks.google.com   text = "v=spf1 ip4:35.190.247.0/24 ip4:64.233.160.0/19 ip4:66.102.0.0/20 ip4:66.249.80.0/20 ip4:72.14.192.0/18 ip4:74.125.0.0/16 ip4:108.177.8.0/21 ip4:173.194.0.0/16 ip4:209.85.128.0/17 ip4:216.58.192.0/19 ip4:216.239.32.0/19 ~all"

Authoritative answers can be found from:
nslookup -q=TXT _netblocks2.google.com 8.8.8.8

#出力結果
Server:     8.8.8.8
Address:    8.8.8.8#53

Non-authoritative answer:
_netblocks2.google.com  text = "v=spf1 ip6:2001:4860:4000::/36 ip6:2404:6800:4000::/36 ip6:2607:f8b0:4000::/36 ip6:2800:3f0:4000::/36 ip6:2a00:1450:4000::/36 ip6:2c0f:fb50:4000::/36 ~all"

Authoritative answers can be found from:
nslookup -q=TXT _netblocks3.google.com 8.8.8.8

#出力結果
Server:     8.8.8.8
Address:    8.8.8.8#53

Non-authoritative answer:
_netblocks3.google.com  text = "v=spf1 ip4:172.217.0.0/19 ip4:172.217.32.0/20 ip4:172.217.128.0/19 ip4:172.217.160.0/20 ip4:172.217.192.0/19 ip4:108.177.96.0/19 ip4:35.191.0.0/16 ip4:130.211.0.0/22 ~all"

Authoritative answers can be found from:

Googleのアクセス元IPアドレスの一覧

現在の(2019/07/12)のGoogleのアクセス元IPアドレスは以下の通り。

IPv4
35.190.247.0/24
64.233.160.0/19
66.102.0.0/20
66.249.80.0/20
72.14.192.0/18
74.125.0.0/16
108.177.8.0/21
173.194.0.0/16
209.85.128.0/17
216.58.192.0/19
216.239.32.0/19
172.217.0.0/19
172.217.32.0/20
172.217.128.0/19
172.217.160.0/20
172.217.192.0/19
108.177.96.0/19
35.191.0.0/16
130.211.0.0/22

IPv6
2001:4860:4000::/36
2404:6800:4000::/36
2607:f8b0:4000::/36
2800:3f0:4000::/36
2a00:1450:4000::/36
2c0f:fb50:4000::/36

6
1
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
6
1