In this paper we solve the tracking and disturbance rejection problem for an unstable wave equation with reference and disturbance signals that are generated by a linear exosystem whose eigenvalues are located on the imaginary axis. We consider both unmatched disturbance at the boundary and also in the domain, and also matched disturbance at the control boundary. To make the control design more easy, the in-domain disturbance is first shifted to the control boundary by introducing a new variable transformation, and the anti-stable boundary term is then transformed into a dissipative boundary term by constructing a transport equation. We find an ordinary differential equation (ODE) with delay that describes the relationship between the output tracking error and the coupled signals consisting of the disturbance and reference signal, by using Riemann variables. Based on this ODE with delay, we apply the internal model principle to find the dynamic controller that achieves the output regulation while rejecting the disturbances, and uses only the tracking error as input.