Let $f:\mathbb{C}\to\mathbb{C}$ be an entire function be such that $\mathbb{R}=f^{-1}(\mathbb{R})$. Show that $f$ is linear. i.e.
$$\exists\ a,b\in\mathbb{R}:f(z)=az+b$$
Hint
I think that $f$ must map the upper half plane and lower half plane to certain two disconnected open sets.
Maybe, if we can show that $f$ is a mobius transformation, then we can then we can look at
$$g(z)=\frac{f(z)-f(0)}{z}$$
and finish.
Let $\mathbb H$ be the upper half-plane. Then $-\mathbb H$ is the lower half-plane. The set $f(\mathbb{H})$ is connected and it contains no real number. Therefore $f(\mathbb{H})\subset\mathbb{H}$ or $f(\mathbb{H})\subset-\mathbb{H}$. By the same argument, $f(-\mathbb{H})\subset\mathbb{H}$ or $f(-\mathbb{H})\subset-\mathbb{H}$. But we can't have $f(\mathbb{H})\subset\mathbb{H}$ and $f(-\mathbb{H})\subset\mathbb{H}$ simultaneously, because then $f(\mathbb{C})\subset\mathbb{H}\cup\mathbb{R}$ and then, since $f$ is an open mapping, $f(\mathbb{C})\subset\mathbb{H}$, wich is impossible, since $f(\mathbb{R})\subset\mathbb R$. By the same argumen, we can't have $f(\mathbb{H})\subset-\mathbb{H}$ and $f(-\mathbb{H})\subset-\mathbb{H}$ simultaneously. So, either$$f(\mathbb{H})\subset\mathbb{H}\text{ and }f(-\mathbb{H})\subset-\mathbb{H}\tag1$$or$$f(\mathbb{H})\subset-\mathbb{H}\text{ and }f(-\mathbb{H})\subset\mathbb{H}.$$We can assume without loss of generality that $(1)$ holds. Now, you will find an answer here.