brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: AddressFamily inet stops ssh from hanging on a broken IPv6 route

Network and access
~/tips/tip-ssh-addressfamily-inet

ssh -4 [email protected]

Force IPv4 for SSH when a host's IPv6 address resolves but does not work.

If ssh sits there for a long time before it finally connects, or times out on a host that works from other machines, IPv6 is a good suspect. The name has an AAAA record, ssh tries that first, and the route to it is broken.

Try it once with IPv4 forced:

ssh -4 [email protected]

If that connects right away, you found it. ssh -v confirms it: the Connecting to line shows the IPv6 address it was stuck on.

To make it permanent for that host, put it in ~/.ssh/config:

Host example.com
    AddressFamily inet

The values are any (the default), inet for IPv4 only and inet6 for IPv6 only. ssh -6 is the opposite flag, useful to test that the IPv6 path does work.

I would set this per host rather than under Host *. A broken IPv6 path is a problem on one network or one server, and the real fix is there: a missing firewall rule, a stale AAAA record, or a router that hands out IPv6 without routing it. Turning it off everywhere hides that, and one day you will need a host that is only reachable over IPv6.

Further reading: ssh_config man page, ssh man page

More Network and access tips scp -3 alice@server-a:/var/backups/db.sql.gz bob@server-b:/srv/restore/ tailscale exit-node suggest tailscale lock sign nodekey:1abddef1 tlpub:abcdef12 wg genpsk > peer1.psk Table = off All Network and access tips (163) All topics

Link