add the following lines to /etc/sysctl.conf
# IPv6 net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 net.ipv6.conf.lo.disable_ipv6 = 1
… and reboot.
Or simply reload the settings:
sysctl -p
2019 update:
sysctl.conf still works, but it won’t be processed during boot.
Therefor recent Ubuntu’s need an extra grub parameter ipv6.disable=1. Like so:
GRUB_CMDLINE_LINUX_DEFAULT="splash quiet ipv6.disable=1" GRUB_CMDLINE_LINUX="ipv6.disable=1"