Well, random <> unique, so first you need to decide what your true requirements are in this regard.
Based on what you've stated, you could build a table of all possible 6-digit numbers, then select a random unused value when you need it (and mark it as used).