Teacher-student interaction allows students to combine prior knowledge with new information to develop new knowledge. It is widely understood that both communication mode and students' knowledge state contribute to the teaching effectiveness (i.e., higher students' scores), but the nature of the interplay of these factors and the underlying neural mechanism remain unknown. In the current study, we manipulated the communication modes (face-to-face [FTF] communication mode/computer-mediated communication [CMC] mode) and prior knowledge states (with vs. without) when teacher-student dyads participated in a teaching task. Using functional near-infrared spectroscopy, the brain activities of both the teacher and student in the dyads were recorded simultaneously. After teaching, perceived teacher-student interaction and teaching effectiveness were assessed. The behavioral results demonstrated that, during teaching with prior knowledge, FTF communication improved students' academic performance, as compared with CMC. Conversely, no such effect was found for teaching without prior knowledge. Accordingly, higher task-related interpersonal neural synchronization (INS) in the left prefrontal cortex (PFC) was found in the FTF teaching condition with prior knowledge. Such INS mediated the relationship between perceived interaction and students' test scores. Furthermore, the cumulative INS in the left PFC could predict the teaching effectiveness early in the teaching process (around 25-35 s into the teaching task) only in FTF teaching with prior knowledge. These findings provide insight into how the interplay between the communication mode and students' knowledge state affects teaching effectiveness. Moreover, our findings suggest that INS could be a possible neuromarker for dynamic evaluation of teacher-student interaction and teaching effectiveness.