Source: https://www.leowkahman.com/2016/03/19/disable-ipv6-raspberry-raspbian/
Firstly, check for presence of IPv6 using ifconfig. You should be seeing a few lines containing inet6 addr: ....
To disable, edit a file: sudo nano /etc/sysctl.conf
Add the following line:
net.ipv6.conf.all.disable_ipv6 = 1
For the change to take effect without rebooting: sudo sysctl -p
Verify that IPv6 address does not show up in ifconfig.
If you wish to re-enable, change the value in the setting above from 1 to 0 then execute the following two lines:
sudo sysctl -p
sudo ifconfig eth0 down && sudo ifconfig eth0 up
If you are doing this over SSH, the current session will of course be cut off. You should be able to reconnect in just a few seconds.
Thank you very much for this nugget of pure goodness. I've been down a bit of a rabbit-hole trying to eradicate IPv6 on some of my Raspberry Pi installs, and I'd already done the sysctl.conf stuff and also edited cmdline.txt and I was still seeing IPv6 entries when running an 'ip addr' query.
After applying your fix, I was overjoyed to see just IPv4 stuff. Many thanks @barci335
John G