  We study the dynamical evolution of an $f(R)$ model of gravity in a viscous
and anisotropic background which is given by a Bianchi type-I model of the
Universe. We find viable forms of $f(R)$ gravity in which one is exactly the
Einsteinian model of gravity with a cosmological constant and other two are
power law $f(R)$ models. We show that these two power law models are stable
with a suitable choice of parameters. We also examine three potentials which
exhibit the potential effect of $f(R)$ models in the context of scalar tensor
theory. By solving different aspects of the model and finding the physical
quantities in the Jordan frame, we show that the equation of state parameter
satisfy the dominant energy condition. At last we show that the two power law
$f(R)$ models behave like quintessence model at late times and also the shear
coefficient viscosity tends to zero at late times.
