Der Rhein, der Main, die Donau, die Mosel ...
In German, there isn't any fixed rule the genus of river nams, since they come from various languages.
The Rhine river (der Rhein) for instance was already masculine with his old Germanic name reinos
("the great river") (-os is a masculine word ending).
was in Latin albia
("white river") - the word ending -a shows the feminine genus.
was masculine due to the 'masculine' running of the water.
But generally most German rivers are feminine - only eight of rivers above 100 km are masculine: der Rhein, der Main, der Inn, der Neckar, der Lech, der Kocher, der Regen and der Rhin (a tributary to the river Havel in the state of Brandenburg).