In fast ignition of inertial confinement fusion, hot electron beam is considered to be an appropriate energy source for ignition. However, hot electrons are divergent as they are transporting in over-dense plasma. So collimating the hot electrons becomes one of the most important issues in fast ignition. A method to collimate hot electron beam by external magnetic field is proposed in this paper. The external field can be generated by compressing a seed magnetic field at the stage of laser-driven implosion. This method is confirmed by particle-in-cell simulations. The results show that hot electrons are well collimated by external magnetic field from magnetic-flux compression.