ubuntu – Git Push/Pull Taking Too Long Due to IPv6 Issue

gitipv6Ubuntu

My configuration:

  • laptop: XPS 15 7590
  • system: Ubuntu 18.04
  • internet connection: wifi (5 GHz)

Every time I run git pull, git push I have to wait like 15 minutes until it is done. Same problem with running add-apt-repository ppa. As I was trying to solve it, I found this question where the solution was running:

sudo sysctl net.ipv6.conf.all.disable_ipv6=1

which is disabling IPv6 until next reboot. It really works. I would like to understand why exactly is this helping and also what can/should be done (set up) to make this permanent. And is it actually okay to set this permanently?

Best Answer

In order to make this permanent, open your /etc/sysctl.conf file using sudo

sudo nano /etc/sysctl.conf

Add the line at the bottom of the file:

net.ipv6.conf.all.disable_ipv6=1

After that you may reboot your machine or run

sudo sysctl -p

Alternatively, you may instruct your ssh client to use ipv4 only. To do so, open ~/.ssh/config using vi or nano and add the following:

Host *
  AddressFamily inet

AddressFamily in the ssh config instructs which type of address to use when connecting via ssh. Valid choices are any, inet, inet6. Selecting to use inet makes sure ssh does not use ipv6 at all.

Git (commands) use either ssh or http protocol when communicating over a network. Since you are most likely using ssh protocol for your git commands, and making ssh protocol only use ipv4, it resolves the slow connectivity issue related to ipv6.

Unfortunately, this alternative approach won't fix your add-apt-repository ppa

Related Question