How to disable IPv6 in Ubuntu / CentOS

For Ubuntu 14.04 12.04 CentOS 5.x 6.x 7.x

echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf
echo "net.ipv6.conf.default.disable_ipv6 = 1" >>/etc/sysctl.conf
sudo sysctl -p
cat /proc/sys/net/ipv6/conf/all/disable_ipv6
#