An intrusion detection system (IDS) monitors network traffic and analyzes system activities for potential threats. There are two main types of IDS - network-based IDS (NIDS) which analyzes network packets, and host-based IDS (HIDS) which analyzes the host system. An intrusion prevention system (IPS) also monitors for threats but can actively block or prevent intrusions by taking automatic actions in response to rules and detections. IDS and IPS use various analysis techniques like signature-based detection, anomaly detection, and machine learning to identify threats and protect networks and systems.