The application of flagellin derivative CZLC31 from Salmonella in preparation of medicines for preventing and treating inflammatory bowel disease (IBD) is introduced in this invention. The CZLC331 protein has a good preventive and therapeutic effect for IBD, such as ulcerative colitis (UC) and Crohn's disease (CD) in this invention. Therefore, this protein can be prepared into the drug for prevention and treatment of IBD. It has been found that the bad efficacy, slow onset, long course of treatment, side effects can be significantly avoided for existing clinical IBD drugs, it can reduce the patient's pain during the treatment in this invention. The rehabilitation and quality of life of the patients have been largely improved. The drug will play an important role in the prevention and treatment of IBD in this invention, and has broad application prospects.