Given $a<c<d<b$, it suffices to show that $f(x)=\alpha x+\beta$ on $[c,d]$ for some $\alpha,\beta$. Firstly, we can choose $\alpha,\beta$, such that for $g(x)=f(x)-\alpha x-\beta$, $g(c)=g(d)=0$. Since $g$ satisfies the same property with $f$, it suffices to show that $g=0$ on $[c,d]$.
Given $\lambda>0$, let $g_\lambda(x)=g(x)+\lambda(x-c)(x-d)$. Then $g_\lambda(c)=g_\lambda(d)=0$, and
Then for $\epsilon=\lambda$, there exists $\delta>0$, such that when $|h|<\delta$, for any $x\in[c,d]$,
It implies that the maximum of $g_\lambda$ on $[c,d]$ cannot be attained in the interior $(c,d)$, i.e. $g_\lambda(x)\le 0$ on $[c,d]$. Since $\lambda$ is arbitrary, it follows that $g\le 0$ on $[c,d]$. Since the same argument works when $g$ is replaced by $-g$, $g=0$ on $[c,d]$.