IPv6 support #404

Closed
opened 2026-02-20 21:11:54 -05:00 by deekerman · 11 comments
Owner

Originally created by @whatUwant on GitHub (Nov 9, 2012).

Originally assigned to: @phihag on GitHub.

Is it possible to force youtube-dl to work only via IPv6?
It's impossible to access Youtube via IPv4 in China without a proxy or VPN service while accessing via IPv6 has not yet been banned.
I don't know if youtube-dl chose to access youtube via IPv6 by chance. A few days ago, youtube-dl seemed to be working fine with IPv6. But recently all downloads have failed. The error message is "urlopen error [Errno 104] Connection reset by peer". I'm pretty sure there is nothing wrong with my IPv6 connectivity. The only explanation I can come up with is that youtube-dl is trying to access youtube via IPv4 right now.

Originally created by @whatUwant on GitHub (Nov 9, 2012). Originally assigned to: @phihag on GitHub. Is it possible to force youtube-dl to work only via IPv6? It's impossible to access Youtube via IPv4 in China without a proxy or VPN service while accessing via IPv6 has not yet been banned. I don't know if youtube-dl chose to access youtube via IPv6 by chance. A few days ago, youtube-dl seemed to be working fine with IPv6. But recently all downloads have failed. The error message is "urlopen error [Errno 104] Connection reset by peer". I'm pretty sure there is nothing wrong with my IPv6 connectivity. The only explanation I can come up with is that youtube-dl is trying to access youtube via IPv4 right now.
Author
Owner

@phihag commented on GitHub (Nov 10, 2012):

Currently, youtube-dl simply picks whatever your DNS/IP stack thinks is available, and for youtube, that's IPv6. I'll look into it, but may need to contact you personally to reproduce the issue, since I don't have any servers in China at the moment. Can you send me an email with ways to contact you (by icq/Jabber/email/phone, whatever)?

I suspect a DNS-level issue could be the problem. What do you get if you run

dig youtube.com AAAA

on your system?

@phihag commented on GitHub (Nov 10, 2012): Currently, youtube-dl simply picks whatever your DNS/IP stack thinks is available, and for youtube, that's IPv6. I'll look into it, but may need to contact you personally to reproduce the issue, since I don't have any servers in China at the moment. Can you send me an email with ways to contact you (by icq/Jabber/email/phone, whatever)? I suspect a DNS-level issue could be the problem. What do you get if you run ``` dig youtube.com AAAA ``` on your system?
Author
Owner

@whatUwant commented on GitHub (Nov 10, 2012):

Hello Philipp.
When I ran "dig youtube.com AAAA" I got this

; <<>> DiG 9.3.6-P1-RedHat-9.3.6-20.P1.el5 <<>> www.youtube.com AAAA
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 27062
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:
;www.youtube.com.               IN      AAAA

;; ANSWER SECTION:
www.youtube.com.        23190   IN      CNAME   youtube-ui.l.google.com.
youtube-ui.l.google.com. 868    IN      CNAME   youtube-ui-china.l.google.com.

;; AUTHORITY SECTION:
l.google.com.           600     IN      SOA     ns2.google.com. dns-admin.google.com. 1502868 900 900 1800 60

;; Query time: 118 msec
;; SERVER: 202.120.127.220#53(202.120.127.220)
;; WHEN: Sun Nov 11 05:00:31 2012
;; MSG SIZE  rcvd: 148

I also queried Google's dns server 2001:4860:4860::8888

; <<>> DiG 9.3.6-P1-RedHat-9.3.6-20.P1.el5 <<>> www.youtube.com AAAA
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 23866
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;www.youtube.com.               IN      AAAA

;; ANSWER SECTION:
www.youtube.com.        300     IN      AAAA    ::908a:1a45:0:0

;; Query time: 39 msec
;; SERVER: 2001:4860:4860::8888#53(2001:4860:4860::8888)
;; WHEN: Sun Nov 11 05:17:26 2012
;; MSG SIZE  rcvd: 61

I'm afraid I was wrong about my IPv6 connectivity.
It seems that dns poisoning has already been effective on IPv6.

@whatUwant commented on GitHub (Nov 10, 2012): Hello Philipp. When I ran "dig youtube.com AAAA" I got this ``` ; <<>> DiG 9.3.6-P1-RedHat-9.3.6-20.P1.el5 <<>> www.youtube.com AAAA ;; global options: printcmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 27062 ;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 1, ADDITIONAL: 0 ;; QUESTION SECTION: ;www.youtube.com. IN AAAA ;; ANSWER SECTION: www.youtube.com. 23190 IN CNAME youtube-ui.l.google.com. youtube-ui.l.google.com. 868 IN CNAME youtube-ui-china.l.google.com. ;; AUTHORITY SECTION: l.google.com. 600 IN SOA ns2.google.com. dns-admin.google.com. 1502868 900 900 1800 60 ;; Query time: 118 msec ;; SERVER: 202.120.127.220#53(202.120.127.220) ;; WHEN: Sun Nov 11 05:00:31 2012 ;; MSG SIZE rcvd: 148 ``` I also queried Google's dns server 2001:4860:4860::8888 ``` ; <<>> DiG 9.3.6-P1-RedHat-9.3.6-20.P1.el5 <<>> www.youtube.com AAAA ;; global options: printcmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 23866 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;www.youtube.com. IN AAAA ;; ANSWER SECTION: www.youtube.com. 300 IN AAAA ::908a:1a45:0:0 ;; Query time: 39 msec ;; SERVER: 2001:4860:4860::8888#53(2001:4860:4860::8888) ;; WHEN: Sun Nov 11 05:17:26 2012 ;; MSG SIZE rcvd: 61 ``` I'm afraid I was wrong about my IPv6 connectivity. It seems that dns poisoning has already been effective on IPv6.
Author
Owner

@whatUwant commented on GitHub (Nov 10, 2012):

I can access Youtube via HTTPS in Firefox if I manually associate correct IPv6 addresses with youtube domain names in /etc/hosts. But still, youtube-dl is not working.

@whatUwant commented on GitHub (Nov 10, 2012): I can access Youtube via HTTPS in Firefox if I manually associate correct IPv6 addresses with youtube domain names in /etc/hosts. But still, youtube-dl is not working.
Author
Owner

@meteormatt commented on GitHub (Nov 29, 2012):

If you use IPv6, you should use IPv6's DNS.
For example, Google's dns server 2001:4860:4860::8888
IPv4's DNS will response IPv4 address first.

@meteormatt commented on GitHub (Nov 29, 2012): If you use IPv6, you should use IPv6's DNS. For example, Google's dns server 2001:4860:4860::8888 IPv4's DNS will response IPv4 address first.
Author
Owner

@phihag commented on GitHub (Nov 30, 2012):

@meteormatt Your browser (and youtube-dl) will send A and AAAA queries in parallel, so it doesn't matter which DNS server you choose.

@phihag commented on GitHub (Nov 30, 2012): @meteormatt Your browser (and youtube-dl) will send `A` and `AAAA` queries in parallel, so it doesn't matter which DNS server you choose.
Author
Owner

@dfc commented on GitHub (Jul 29, 2013):

I have a ipv6 tunell through huricane electric. Youtube downloads are much quicker via the tunnel than when I use straight ipv4 via my ISP. I would be interested in yt-dl having a ipv6 switch. I am currently trying to get /etc/gai.conf to prefer ipv6 for google and youtube. However that is not the most portable solution.

@dfc commented on GitHub (Jul 29, 2013): I have a ipv6 tunell through huricane electric. Youtube downloads are much quicker via the tunnel than when I use straight ipv4 via my ISP. I would be interested in yt-dl having a ipv6 switch. I am currently trying to get /etc/gai.conf to prefer ipv6 for google and youtube. However that is not the most portable solution.
Author
Owner

@SylvainBoilard commented on GitHub (Nov 26, 2013):

I second that, an option to force youtube-dl to use a particular version of the IP protocol would come in handy. I’m on a network where IPv6 connectivity is obtained through an IPv6 tunnel with a much lower data rate than what is available using IPv4, so using IPv6 to download large contents is impractical and might get annoying for other users.

@SylvainBoilard commented on GitHub (Nov 26, 2013): I second that, an option to force youtube-dl to use a particular version of the IP protocol would come in handy. I’m on a network where IPv6 connectivity is obtained through an IPv6 tunnel with a much lower data rate than what is available using IPv4, so using IPv6 to download large contents is impractical and might get annoying for other users.
Author
Owner

@haasn commented on GitHub (Feb 1, 2014):

I second that the protocol should be configurable, for similar reasons. My go-to workaround as of now is to use wget -4 -O filename $(youtube-dl -g link) but it's of course a bit bothersome to type that every time I want to download something, especially since I have to assign a filename manually.

It would be great if you could add flags like wget's -4 and -6 options manually. Alternatively, it would be great to be able to use wget in combination more easily (which is also good for stuff like --timeout, --limit-rate among other useful flags).

@haasn commented on GitHub (Feb 1, 2014): I second that the protocol should be configurable, for similar reasons. My go-to workaround as of now is to use `wget -4 -O filename $(youtube-dl -g link)` but it's of course a bit bothersome to type that every time I want to download something, especially since I have to assign a filename manually. It would be great if you could add flags like wget's -4 and -6 options manually. Alternatively, it would be great to be able to use wget in combination more easily (which is also good for stuff like --timeout, --limit-rate among other useful flags).
Author
Owner

@kaimi commented on GitHub (Oct 31, 2014):

-4 / -6 switches would be really great 👍

@kaimi commented on GitHub (Oct 31, 2014): -4 / -6 switches would be really great :+1:
Author
Owner

@phihag commented on GitHub (Jan 10, 2015):

-4 and -6 switches are present in youtube-dl 2015.01.10.1 and newer. See our FAQ if you need help updating.

@phihag commented on GitHub (Jan 10, 2015): `-4` and `-6` switches are present in youtube-dl 2015.01.10.1 and newer. See [our FAQ](https://yt-dl.org/update) if you need help updating.
Author
Owner

@kaimi commented on GitHub (Jan 17, 2015):

Nice job, thanks!

@kaimi commented on GitHub (Jan 17, 2015): Nice job, thanks!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/youtube-dl#404
No description provided.