But in that case how will NAS even know which DAC is connected to it? It always shows no player when connected using SPDIF. But it shows the DAC when I connect using USB.
This is the culprit: you cannot know WHAT DAC is connected to either an optical, or a coaxial SPDIF, as there is no "data" exchanged between the source and the destination (for data here I mean other than audio-data, of course). That's exactly the opposite of USB, through which device type/brand/model/specs data is travelling from destination (the DAC) to the source (the NAS).
The optical SPDIF should not even bother whether there is, or not, something connected on the other end of it: it will just throw optical pulses at it, and if something can get and decode them, well... good. This is basically what an RCA analog connection is between, say, a cassette deck and your pre-amp: neither of them knows the other is there..., b ut one plays audio, and the other eventually captures and routes it to the AMP.