RF signal generation, switching, and reconfiguring are essential and important features for the rapidly developing microwave system, which are usually implemented using independent components or subsystems. In this paper, we propose and demonstrate an optical method to generate and switch the RF frequency at the stage of generation based on control input state using external cavity based single mode Fabry-Perot laser diode. The RF frequency generation, switching, and controlling are based on the principle of injection locking with negative and positive wavelength detuning. In the proposed scheme, a single external beam is simultaneously used to control RF switching as well as to generate RF signal through optical heterodyning of injection locked beams. This eliminates the necessity of two separate external beams to switch and generate RF signal. Based on the logic state of the input control beam, the frequency of the generated RF signal can be changed to another RF frequency within a group of predefined RF bands. In a proof-of-concept experiment, a 2-Gbps, 16-bit nonreturn-to-zero control signal is applied to switch the frequency of the generated RF signal. We obtain the minimum signal to noise power ratio of more than 23 dB, the maximum linewidth of 165 kHz, and rising and falling times of less than 40 ps associated with the RF switching. The tunable range, RF frequency, and RF power variation of the generated RF signals are also observed. Moreover, using random control signals, random sequences of RF frequencies can be generated using the same experimental and hardware setup. Such reconfigurability and flexibility of our system to generate several random RF signals from the same framework enables application of the proposed method in several fields such as secure communication, encryption, and military applications.