Skip to content

Instantly share code, notes, and snippets.

@x2c3z4
Forked from n0531m/list_gcp_iprange.sh
Created December 28, 2016 09:03
Show Gist options
  • Select an option

  • Save x2c3z4/c5d6fd8a8b02ea7556a22cb5891e335b to your computer and use it in GitHub Desktop.

Select an option

Save x2c3z4/c5d6fd8a8b02ea7556a22cb5891e335b to your computer and use it in GitHub Desktop.

Revisions

  1. @n0531m n0531m renamed this gist Jun 13, 2016. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. @n0531m n0531m revised this gist May 5, 2015. 1 changed file with 5 additions and 3 deletions.
    8 changes: 5 additions & 3 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -1,14 +1,16 @@
    #!/bin/bash

    # https://cloud.google.com/compute/docs/faq#ipranges

    #nslookup -q=TXT _cloud-netblocks.googleusercontent.com 8.8.8.8
    #`dig txt _cloud-netblocks.googleusercontent.com +short | tr " " "\n" | grep include | tr : "\t" | cut -f 2`

    for LINE in `dig txt _cloud-netblocks.googleusercontent.com +short | tr " " "\n" | grep include | cut -f 2 -d :`
    do
    dig txt $LINE +short
    done | tr " " "\n" | grep ip4 | cut -f 2 -d : | sort -n

    # changing host name as below, and you can get a simliar range now for Google Apps mail servers.
    # changing target to _spf.google.com, you can get a simliar range now for Google Apps mail servers.
    # https://support.google.com/a/answer/60764

    # for LINE in `dig txt _spf.google.com +short | tr " " "\n" | grep include | cut -f 2 -d :`; do dig txt $LINE +short; done | tr " " "\n" | grep ip4 | cut -f 2 -d : | sort -n
    # changing it to _netblocks.google.com will help get all the ip ranges google uses for its services.

  3. @n0531m n0531m revised this gist May 5, 2015. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -7,3 +7,8 @@ for LINE in `dig txt _cloud-netblocks.googleusercontent.com +short | tr " " "\n"
    do
    dig txt $LINE +short
    done | tr " " "\n" | grep ip4 | cut -f 2 -d : | sort -n

    # changing host name as below, and you can get a simliar range now for Google Apps mail servers.
    # https://support.google.com/a/answer/60764

    # for LINE in `dig txt _spf.google.com +short | tr " " "\n" | grep include | cut -f 2 -d :`; do dig txt $LINE +short; done | tr " " "\n" | grep ip4 | cut -f 2 -d : | sort -n
  4. @n0531m n0531m revised this gist May 5, 2015. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    # https://cloud.google.com/compute/docs/faq#ipranges

    #nslookup -q=TXT _cloud-netblocks.googleusercontent.com 8.8.8.8
    #`dig txt _cloud-netblocks.googleusercontent.com +short | tr " " "\n" | grep include | tr : "\t" | cut -f 2`

  5. @n0531m n0531m revised this gist May 5, 2015. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    #nslookup -q=TXT _cloud-netblocks.googleusercontent.com 8.8.8.8
    #`dig txt _cloud-netblocks.googleusercontent.com +short | tr " " "\n" | grep include | tr : "\t" | cut -f 2`

    for LINE in `dig txt _cloud-netblocks.googleusercontent.com +short | tr " " "\n" | grep include | tr : "\t" | cut -f 2`
    for LINE in `dig txt _cloud-netblocks.googleusercontent.com +short | tr " " "\n" | grep include | cut -f 2 -d :`
    do
    dig txt $LINE +short
    done | tr " " "\n" | grep ip4 | tr : "\t" | cut -f 2 | sort -n
    done | tr " " "\n" | grep ip4 | cut -f 2 -d : | sort -n
  6. @n0531m n0531m created this gist May 5, 2015.
    7 changes: 7 additions & 0 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    #nslookup -q=TXT _cloud-netblocks.googleusercontent.com 8.8.8.8
    #`dig txt _cloud-netblocks.googleusercontent.com +short | tr " " "\n" | grep include | tr : "\t" | cut -f 2`

    for LINE in `dig txt _cloud-netblocks.googleusercontent.com +short | tr " " "\n" | grep include | tr : "\t" | cut -f 2`
    do
    dig txt $LINE +short
    done | tr " " "\n" | grep ip4 | tr : "\t" | cut -f 2 | sort -n