A DHT (Distributed Hash Table) is a Hash Table that is distributed. That being said it is much more complex than that. The routing portion is the hardest part. There are 2 major variants of DHTs out there.
1.) Chord
Chord works in a circle based system so there is a limit to the amount of nodes in the dht. The DHT is for systems that are private and want more of a graceful close to pass data to the other nodes before the leave. When it tries to find a file or data it searches the file or data hash on other nodes the node with the closest XOR ID to the file or data hash.
https://github.com/DrBrad/JChord
https://en.wikipedia.org/wiki/Chord_(peer-to-peer)
Commands:
2.) Kademlia
Kademlia works on an XOR bucket based system. Each node assigns itself an ID based off of IP or something with SHA1 or CRC32c. It then uses this when a part of the network. When it tries to find a file or data it searches the file or data hash on other nodes the node with the closest XOR ID to the file or data hash.
https://github.com/DrBrad/Kad4
https://github.com/DrBrad/Kad4/wiki
Commands:
Basic jist is file or data closest based off of a hash should be stored on node closest to it.