From Kunming, China, you can apply for a visa to Vietnam at Vietnam consulate in Kunming below:
Vietnamese Embassy, Kunming Consulate:
Add: 2nd floor, Kai Wah International Hotel, 157 Beijing Lu, Kunming
Tel: 86-871-3522669/3515889 ; Fax: 86-871-3516667
How to get there to Hanoi from Kunming, China
By train & bus
Train is no longer operated due to landslides. However, a daily bus takes over 10 hours and costs less than US$24, but the condition of the bus is not good.
Vietnam airlines operates flights from Kunming to Hanoi. A one-way Kunming - Hanoi plane ticket on Vietnam Airlines, cost about 2800 RMB inclusive of taxes.