Generation and protection of a maximally entangled state between many modes in an optical network with dissipation