3-dimensionally interconnected macroporous carbons are versatile materials that can be used in catalysis, electrochemical devices, and separation technology. Herein, the synthesis of a nitrogen doped carbonaceous material with a well-defined nanoarchitecture via nano-casting is demonstrated. A novel carbon source, a task-specific protic salt, has been proposed to create nitrogen doped carbon by direct carbonization within the pores of controlled macroporous glass. After the removal of macroporous glass from the composite using an aqueous sodium hydroxide solution and upon further heat treatment, an oxidation resistant doped carbon with high nitrogen content (6 mass %) is obtained. The materials formed during the different stages of the nano-casting process exhibit interesting properties such as hierarchical porosity, very high nitrogen content (15 mass %), and increased oxidational stability. A combination of different properties to create tailor-made materials for different applications using this technique is possible.