Nomadic empire
The Xiongnu were a confederation of nomadic tribes from Central Asia with a ruling class of unknown origin and other subjugated tribes. They lived on the Mongolian Plateau between the 3rd century BC and the 460s AD, their territories including modern day Mongolia, southern Siberia, western Manchuria, and the modern Chinese provinces of Inner Mongolia, Gansu, and Xinjiang. The Xiongnu was the first unified empire of nomadic peoples. Relations between early Chinese dynasties and the Xiongnu were complicated and included military conflict, exchanges of tribute and trade, and marriage treaties. When Emperor Qin Shihuang drove them away from the south of the Yellow River, he built the famous Great Wall to prevent the Xiongnu from coming back.
Shuofang
In the chaos of the rebellions that took place during the end of the Qin Dynasty, the Xiongnu once again moved into the area and took control, and retained this area even after the foundation of the Han Dynasty, using it as an important staging post for raiding into northern and northeastern China. It was only during the Han–Xiongnu War launched by Emperor Wu that the Han Dynasty proactively sought to take over the former borderlands of the Qin Dynasty. In 127 BC, an expedition led by Wei Qing defeated the Xiongnu, leading to the foundation of Shuofang Commandery; by 8 BC the commandery had ten constituent counties.