We provide a strange star model under the framework of general relativity by using a general linear equation of state (EOS). The solution set thus obtained is employed on altogether 20 compact star candidates to constraint values of MIT bag model. No specific value of the bag constant ($B$) a-priori is assumed rather possible range of values for bag constant is determined from observational data of the said set of compact stars. To do so the Tolman-Oppenheimer-Volkoff (TOV) equation is solved by homotopy perturbation method (HPM) and hence we get a mass function for the stellar system. The solution to the Einstein field equations represents a non-singular, causal and stable stellar structure which can be related to strange stars. Eventually we get an interesting result on the range of the bag constant as 41.58~MeV~fm$^{-3}< B <$319.31~MeV~fm$^{-3}$. We have found the maximum surface redshift $Z^{max}_{s}=0.63$ and shown that the central redshift ($Z_c$) can not have value larger than $2k$, where $k=2.010789 pm 0.073203$. Also we provide a possible value of bag constant for neutron star (NS) with quark core using hadronic as well as quark EOS.