I suggest installing Debian or Ubuntu on the NAS so that you will be familiar. Then install all the services on that NAS box. Next step is to learn iptables and make your own router. Could make the NAS into a router if it has two or more network ports. A router is just some iptables commands.
Of course, iptables is an older syntax, since replaced by nftables. Learning both isn't too hard. The easiest fw is the Uncomplicated Firewall (UFW) which is also probaby worth learning for completeness.