The socket preservation requires special structures for tissue engineering scaffolds. In this study, we developed a kind of Janus nanocomposite hydrogels with antibacterial property, soft tissue barrier function and bone repairing ability using a penetration cross-linking method. The hydrogels were constructed by permeating oxidized sodium alginate solution into a highly viscous nano-hydroxyapatite-contained carboxymethyl chitosan suspension. Through this process, the Janus structure was fabricated. The dense, smooth top-surface showed a significant barrier function against fibroblast cells, while its loose, porous bottom-surface could support bone regeneration with nano hydroxyapatite. And in order to inhibit periodontitis-related bacteria, an antibacterial agent, metronidazole, was combined into the hydrogels. The CAH4M hydrogel showed antibacterial efficiencies of 82% against S. mutans and 93% against P. gingivalis. The hemolysis ratio was less than 5%, and there was no evident cytotoxicity, demonstrating the good biocompatibility. The in vivo anti-infection and bone repairing properties of the hydrogels were verified by a rat model of infected extraction socket. Based on the above results, this study provided a promising strategy to prepare tissue engineering scaffolds that meet clinical requirements for socket preservation and prevention of infection.