Lymph nodes are small, bean-shaped structures that are part of the body's immune system. They are located throughout the body and help to protect it from infection by filtering out foreign substances such as bacteria and viruses. When lymph nodes detect an infection or other foreign substance, they swell up as a way to trap the invader and prevent its spread throughout the body.