An electronic fence generator includes a cylindrical body, a ground stake downwardly extended from the bottom of the cylindrical body, and an ultrasonic transmitter, an infrared transmitter and an infrared receiver mounted in the cylindrical body. The ultrasonic transmitter is adapted for transmitting an ultrasonic signal to create a collision avoidance range around the cylindrical body. The infrared transmitter is adapted for transmitting an infrared signal in a signal transmitting direction. The infrared receiver is adapted for receiving an infrared signal from another electronic fence generator in a signal receiving direction different from the signal transmitting direction. Thus, the electronic fence generator can be used for creating a virtual electronic fence for restricting an automatic lawn mower to the range defined by the electronic fence.