In this study, a positively charged nanofiltration (NF) membrane was prepared by interfacial polymerization for separation of divalent cations, whereby a nanomaterial (modified graphitic carbon nitride (g-C3N4) with poly(dopamine), PDA-C3N4) was incorporated into the active layer of the NF membrane. PDA-C3N4 sheets were synthesized from g-C3N4 sheets prepared by thermal oxidation of melamine, and the preparation conditions of NF membrane were also optimized. The results show that the roughness of PDA-C3N4 embedded NF membrane decreases, and the hydrophilicity and the permeation increase. The membrane also shows high rejection for divalent cations (Mg2+, Ca2+, Ba2+, Cu2+ and Zn2+) but low rejection (36.8%) for monovalent cation (Li+), as well as good fouling resistance performance. The fabricated membrane has the potential for treatment of industrial wastewater.