  A large fraction of the baryons at low redshift are undetected, and likely
reside in the tenuous, hot intergalactic medium (IGM). One way to probe the
missing baryons is through their absorption of bright sources. The anomalous
absorption excess in the X-ray afterglows of $\gamma$-ray bursts (GRBs) has
been suggested to result from the missing baryons. In order to test this
hypothesis, the present paper employs IllustrisTNG simulations to compute the
X-ray absorption effect on cosmological distances. The simulation shows that
ionization of H and He in the IGM leaves the metals responsible for $>60\%$ of
the X-ray opacity of high-$z$ sources (the ionization of He isn't available in
the simulation, we used here external knowledge). The high-$z$ asymptotic
optical depth at 0.5\,keV in the simulation reaches $0.15\pm0.07$, while the
GRB afterglow values tend to $\approx 0.4$, implying the missing baryons can
account for a significant fraction of the observed opacity. The remaining
discrepancy is ascribed mainly to the low average metallicity in the
simulation, which drops from 0.06 solar at $z=0$ to 0.01 at $z=3$, and which is
below previously measured values.
