Press and hold the RESET button on the back panel of your Synology NAS for about 4 seconds until you hear a beep. This resets the admin password to blank so you can set a new one.
According to the source, this action also resets the IP and DNS to their default values, but it does not erase your data. If you only need to reinstall the NAS without losing data, the guide says to use the RESET button procedure for reinstallation, and it notes that the saved data will not be erased during reinstallation.
Sources used: [2], [1]