Controlling the distribution of water and wastewater between industrial processes is vital to rationalize water usage and preserve the environment. In this paper, a mathematical technique is proposed to optimize water–wastewater networks, and a nonlinear program is introduced to minimize the consumption of freshwater and, consequently, the flowrate of wastewater discharge. A general mathematical model, able to handle industrial plants containing up to eight sources and eight sinks, is developed using LINGO optimization software to facilitate dealing with complex case studies. The introduced model can handle single-contaminant networks as well as multiple-contaminant ones. The optimal water network is synthesized through two steps; the first step involves the introduction of the case study data into the developed mathematical model. The second step considers using the optimal solution produced after running the developed LINGO model as feed data for a pre-designed Excel sheet able to deal with these results and simultaneously draw the optimal water–wastewater network. The proposed mathematical model is applied to two case studies. The first case study includes actual data from four fertilizer plants located in Egypt; the water resources and requirements are simultaneously integrated to obtain a sensible cutting in both freshwater consumption (lowered by 52.2%) and wastewater discharge (zero wastewater discharge). The second case study regards a Brazilian petrochemical plant; the obtained results show noticeable reductions in freshwater consumption by 12.3%, while the reduction percentage of wastewater discharge is 4.5%.