A system for automatically segmenting and merging routing domains within a network, comprising: one or more gateway devices 101; and a plurality of nodes 201 segmented into one or more routing domains 301 in which: each of said plurality of nodes 201 selects a single gateway device 101 from among said plurality of gateway devices as the node's primary gateway at any time; each of said gateway devices 101 possesses a gateway color attribute 104, in which the value of the said gateway color attribute 104 is unique for each gateway 101; each of said plurality of nodes 201 maintains a node color attribute value whose value is derived from the value of said gateway color attribute 104 of the node's primary gateway 101; and each node's routing domain 301 is determined by the node's color attribute value, wherein a first node 201 changes its selection from a first domain 101 to a second domain 101 based on the number of hops to the first primary to gateway 101 exceeding a threshold; the first node 201 derives a new color attribute value from a color attribute value 104 of the second gateway 101; the first node 201, after changing its selection to the second domain 101, updates a local routing table 400 to remove entries not associated with the second domain 101; and the first node 201, after updating the local routing table 400, conveying information from the updated local routing table 400 to at least one other node 201. one or more gateway devices 101; and a plurality of nodes 201 segmented into one or more routing domains 301 in which: each of said plurality of nodes 201 selects a single gateway device 101 from among said plurality of gateway devices as the node's primary gateway at any time; each of said gateway devices 101 possesses a gateway color attribute 104, in which the value of the said gateway color attribute 104 is unique for each gateway 101; each of said plurality of nodes 201 maintains a node color attribute value whose value is derived from the value of said gateway color attribute 104 of the node's primary gateway 101; and each node's routing domain 301 is determined by the node's color attribute value, wherein a first node 201 changes its selection from a first domain 101 to a second domain 101 based on the number of hops to the first primary to gateway 101 exceeding a threshold; the first node 201 derives a new color attribute value from a color attribute value 104 of the second gateway 101; the first node 201, after changing its selection to the second domain 101, updates a local routing table 400 to remove entries not associated with the second domain 101; and the first node 201, after updating the local routing table 400, conveying information from the updated local routing table 400 to at least one other node 201. each of said plurality of nodes 201 selects a single gateway device 101 from among said plurality of gateway devices as the node's primary gateway at any time; each of said gateway devices 101 possesses a gateway color attribute 104, in which the value of the said gateway color attribute 104 is unique for each gateway 101; each of said plurality of nodes 201 maintains a node color attribute value whose value is derived from the value of said gateway color attribute 104 of the node's primary gateway 101; and each node's routing domain 301 is determined by the node's color attribute value, wherein a first node 201 changes its selection from a first domain 101 to a second domain 101 based on the number of hops to the first primary to gateway 101 exceeding a threshold; the first node 201 derives a new color attribute value from a color attribute value 104 of the second gateway 101; the first node 201, after changing its selection to the second domain 101, updates a local routing table 400 to remove entries not associated with the second domain 101; and the first node 201, after updating the local routing table 400, conveying information from the updated local routing table 400 to at least one other node 201.