Why git clone fails over IPv6
An IPv6-only VPS can only reach servers that publish an IPv6 address (a DNS AAAA record). But github.com, GitHub's API and its container registry ghcr.io do not publish one. The error message looks like this:
fatal: unable to access 'https://github.com/…': Could not resolve host: github.com
or, depending on the configuration, Network is unreachable. You can check for yourself:
getent ahostsv6 github.com # no answer: no IPv6
getent ahostsv6 debian.org # addresses in 2001:… : IPv6 OK
Not all of GitHub is affected: raw.githubusercontent.com, which serves raw files, is reachable over IPv6. But cloning, git pull and most downloads go through github.com.
Solution 1: a NAT64/DNS64 service (the simplest)
A NAT64/DNS64 service bridges your VPS and the sites that are still IPv4-only. Its DNS server (the DNS64) answers names that have no IPv6 with a special IPv6 address; its gateway (the NAT64) receives the traffic on that address and relays it over IPv4. As far as your VPS is concerned, it is as if GitHub had IPv6: there is nothing else to configure.
The free public service nat64.net provides three DNS64 servers:
2a00:1098:2b::1
2a00:1098:2c::1
2a01:4f9:c010:3f02::1
Check these addresses on nat64.net before using them: they may change. You then need to set them as your VPS's DNS servers. First, look at how your system handles DNS:
ls -l /etc/resolv.conf
If the file points to systemd-resolved
That is the case if the command shows /run/systemd/resolve/stub-resolv.conf. Create a settings file:
mkdir -p /etc/systemd/resolved.conf.d
cat > /etc/systemd/resolved.conf.d/nat64.conf <<'EOF'
[Resolve]
DNS=2a00:1098:2b::1 2a00:1098:2c::1 2a01:4f9:c010:3f02::1
Domains=~.
EOF
systemctl restart systemd-resolved
The Domains=~. line sends all queries through these servers, even if your network interface advertises others.
If it is an ordinary file
Replace its contents with:
nameserver 2a00:1098:2b::1
nameserver 2a00:1098:2c::1
nameserver 2a01:4f9:c010:3f02::1
Check that it works
getent ahostsv6 github.com
git clone https://github.com/git/git.git --depth 1
An address starting 2a00:1098:… or 2a01:4f9:… is shown for github.com, and cloning works. SSH connections to GitHub (git@github.com) normally take the same path.
Solution 2: push the code from your computer
If you are deploying your own project, the VPS does not necessarily need to talk to GitHub. Your computer can reach GitHub normally; it can then push the code to the VPS over IPv6. Create an empty repository on the server:
git init --bare /srv/myproject.git
then, on your computer, add the VPS as a second remote:
git remote add vps root@[2001:db8::10]:/srv/myproject.git
git push vps main
Replace 2001:db8::10 with your VPS's address. With a shortcut in ~/.ssh/config (see the IPv6 VPS guide), vps:/srv/monprojet.git is enough. To copy files as a one-off, rsync or scp will also do the job.
Solution 3: use a mirror reachable over IPv6
For individual files (an install script, a configuration file), raw.githubusercontent.com is reachable over IPv6. For whole repositories, you can host a mirror on a forge that has IPv6, for example a Forgejo or Gitea instance: this software can automatically sync a GitHub repository.
What about Docker, npm, pip?
The good news: most package repositories have IPv6. The Debian and Ubuntu repositories, npm (registry.npmjs.org), PyPI (pypi.org) and nodejs.org work directly. For Docker Hub, use its IPv6 endpoint registry.ipv6.docker.com. Images hosted on ghcr.io, however, need the NAT64 solution.