Background Lung cancer, a common risky disease, has been the leading cause of death since 2010. In this study, the prognosis of immune genes and its targeted miRNA of non-small lung cancer (NSCLC) was explored. Methods Based on microarray GSE13213 (lung adenocarcinoma (LAD) patient mRNA expression profiles), microarray GSE4573 (lung squamous cell carcinoma (LSC) patient mRNA expression profiles), and microarray GSE102286 (NSCLC patient miRNA profiles), the gene co-expression network was constructed with weight gene co-expression network analysis (WGCNA). KEGG and Gene Ontology were enriched. The binding site was predicted on miRanda. The genes corresponding to immune as well as smoking and its targeted miRNA which was also related to smoking was discovered. And then the prognostic value of them was estimated and confirmed in another data cohort. Results Smoking-related module from LSC had a remarkable association with immune gene set (P = 0.0001), which was not observed in LAD. KEGG and GO enrichment analysis in LSC also exhibited immunity-related pathways and functions, such as the B cell receptor signaling pathway, which was still not found in LAD. High expression of nine immune genes (CD27, CD38, CD79A, MZB1, IGHM, IGKC, IGLL3P, GUSBP11, and IGHD) from the purple module in LSC had better overall survival. In an independent LSC microarray, six of them (CD27, CD38, GUSBP11, IGKC, IGLL3P, and IGHD) were validated. IGHD related to plasma cell regulatory showed better overall survival (OS) in two datasets both. Low expression of IGHD targeted miR-29a and low infiltration of its regulated plasma cells was both associated with better OS. Conclusion Our study revealed that, in LSC, smoking might trigger a more severe immune response, compared to LAD. There were six immune genes related to prognosis being discovered. And miR-29a might bind to IGHD affect OS by regulating plasma cells in LSC.