IPSec is a framework that provides security for communications over IP networks by authenticating and encrypting traffic between hosts. It protects against attacks on private networks and the internet through end-to-end encryption and authentication of data. IPSec uses protocols like AH and ESP to authenticate and encrypt data flowing in transport or tunnel mode between endpoints or gateways. It was created to address security issues in IPv4 like eavesdropping, data modification, spoofing and denial of service attacks.