With the application of network technology, the risk of network security is gradually increasing. In order to predict the likelihood of network risks in real-time, a Time-Varying Markov Model (TVMM) for real-time risk probability prediction was proposed. The real-time risk probability prediction method is able to predict the probability of network risk in future exactly with a real-time-updating-state probability transition matrix of TVMM. The model is used to calculate the risk probability of the network at different risk levels in network attack environment. The result shows that TVMM has higher real-time objectivity and accuracy than the traditional Markov model.