Cape Town - Bafana Bafana will have to overcome Cameroon, Gambia and Mauritania in order to qualify for the 2017 Africa Cup of Nations (AFCON).
The official draw took place in Cairo on Wednesday after it was announced that Gabon will host the 31st edition of the tournament.
Group winners, best two runners-up and hosts Gabon will qualify for tournament.
Gabon co-hosted the event with Equatorial Guinea in 2012 and are now entrusted by CAF to do it all on their own.
War-torn Libya was initially selected to host AFCON that year, but concerns over players and spectators' safety pushed CAF to choose an alternative host.
The first round of matches are set to take place on the weekend of June 12-14.
Complete AFCON qualifying draw:
Group A: Djibouti, Liberia, Togo, Tunisia
Group B: Angola, Central African Republic, Democratic Republic of Congo, Madagascar,
Group C: Benin, Equatorial Guinea, Mali, South Sudan
Group D: Botswana, Burkina Faso, Comoros, Uganda
Group E: Congo, Guinea Bissau, Kenya, Zambia
Group F: Cape Verde, Libya, Morocco, Sao Tome
Group G: Chad, Egypt, Nigeria, Tanzania
Group H: Ghana, Mauritius, Mozambique, Rwanda
Group I: Gabon, Ivory Coast, Sierra Leone, Sudan
Group J: Algeria, Ethiopia, Lesotho, Seychelles
Group K: Burundi, Namibia, Niger, Senegal
Group L: Guinea, Malawi, Swaziland, Zimbabwe
Group M: Cameroon, Gambia, Mauritania, South Africa