13

I want to programme my own anti-distraction tool. I can not / do not want to use the hosts file or third-party apps. When using IPsec or Windows Firewall, it only accepts IP addresses. There is

youtube.[264 TLD]
www.youtube.[264 TLD]
subdomains.youtube.[264 TLD]

Apparently, there is no way any more to get a complete list of YouTube sub domains.

Is there a way to somehow obtain all YouTube IP addresses and block them on the IP address level other than using brute force subdomain pinging?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
user670186
  • 2,588
  • 6
  • 37
  • 55

4 Answers4

15

The way to find all the IP addresses associated with a URL is first to find the AS Number. You can get it in Networktools: asinfo Reverse IP Lookup, Whois, Ping, RBL Check, DNS Records, Traceroute, Host information.

For YouTube, get it on Networktools: asinfo youtube.com

There you get the AS number (ASN):

Primary ASN : 15169

Now, type this in the terminal:

whois -h whois.radb.net -- '-i origin AS15169' | grep ^route

And there you will get all the IP addresses. The list is long, but you can find similar addresses that can be grouped in a subnet.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
  • 8
    This answer is wrong. With asn info you get all IPs owned by the ASN, so you get all IPs owned by google not just youtube.com – Moataz Elmasry Jun 19 '16 at 21:57
  • 2
    Moataz Elmasry is right. You can check yourself by following the above procedure but instead of searching for youtube.com search for google.com. You'll end up with the same ASN (15169) and hence the same list of IPs. – ndemou Jun 01 '17 at 13:28
11

The YouTube current address list is:

  • 64.18.0.0/20
  • 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
  • 173.194.0.0/16
  • 207.126.144.0/20
  • 209.85.128.0/17
  • 216.58.208.0/20
  • 216.239.32.0/19
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
8

If you have your own DNS server you can block domains from resolving. Here is a guide to block domains in a BIND DNS server.

To get all the IP addresses there isn't any way. You can install dig. It's available on Linux, but not on Windows.

Then it is to time enter dig youtube.com. It'll show you all the resolved IP addresses from the DNS cache.

See my result of dig youtube.com A:

; <<>> DiG 9.7.0-P1 <<>> youtube.com A
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 13442
;; flags: qr rd ra; QUERY: 1, ANSWER: 16, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;youtube.com.                   IN      A

;; ANSWER SECTION:
youtube.com.            83      IN      A       74.125.235.47
youtube.com.            83      IN      A       74.125.235.46
youtube.com.            83      IN      A       74.125.235.45
youtube.com.            83      IN      A       74.125.235.44
youtube.com.            83      IN      A       74.125.235.43
youtube.com.            83      IN      A       74.125.235.42
youtube.com.            83      IN      A       74.125.235.41
youtube.com.            83      IN      A       74.125.235.40
youtube.com.            83      IN      A       74.125.235.39
youtube.com.            83      IN      A       74.125.235.38
youtube.com.            83      IN      A       74.125.235.37
youtube.com.            83      IN      A       74.125.235.36
youtube.com.            83      IN      A       74.125.235.35
youtube.com.            83      IN      A       74.125.235.34
youtube.com.            83      IN      A       74.125.235.33
youtube.com.            83      IN      A       74.125.235.32

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Sat Feb 18 22:26:58 2012
;; MSG SIZE  rcvd: 285
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Shiplu Mokaddim
  • 56,364
  • 17
  • 141
  • 187
  • Interesting. Why do I get only 4 totally different Ips compared to you, and only 4, not 16? – user670186 Feb 18 '12 at 16:55
  • I get totally different results depending on from which server or site I dig. Why is that? Is there are way to it all? – user670186 Feb 18 '12 at 17:08
  • 2
    This is because your dns server does not have to resolve to more IP till now. If all the 4 IPs are not reachable DNS server will try to look up again. And hopefully an new ip will be resolved. My internet connection is not that stable. I have connection from 2 ISPs. And I use my own DNS server. so my DNS server looked up many times and all are cached – Shiplu Mokaddim Feb 18 '12 at 17:11
  • 1
    OK, but still when I run dig, I get 4 additional ips that are different from your 16 ips. And even if I block all 20 ips I can still reach youtube. Is there ANY way to block youtube on IP level? – user670186 Feb 20 '12 at 14:20
  • Block Youtube from Resolving in your DNS server. It'll never be resolved – Shiplu Mokaddim Feb 20 '12 at 16:37
  • so in other words, there is no real way using just ips ?!? – user670186 Feb 22 '12 at 00:35
  • This won't work because it will only work on the youtube web site and not on the content servers that handle the videos (so it probably won't block mobile/tablet apps for example, that don't use the website directly) – Kedare Dec 06 '14 at 20:07
2

This may help: Obtain Google IP address ranges

Which points to:

https://www.gstatic.com/ipranges/goog.json

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Walty Yeung
  • 3,396
  • 32
  • 33
  • Best and only fully correct answer IMHO. Additionally allows automation of IP range update for youtube and other google services. – Daniel Bişar Nov 07 '22 at 11:49