CO2/CH4 separation using ionic liquids (ILs) encapsulated metal-organic frameworks (MOFs), especially ZIF-8, has shown promise as a new technique for separating CO2 from CH4. However, the mechanisms behind the high CO2/CH4 selectivity of the method remains indistinct. Here we report the progress of understanding the mechanisms from examining the ZIF-8 aperture configuration variation using DFT and MD simulations. The results indicate that the pristine aperture configuration exhibits the best separation performance, and the addition of ILs prevents the apertures from large swing (i.e. configuration variation). Subsequently, the effect of IL viscosity on the layout variation was investigated. MD simulations also show that the pristine aperture configuration is more stabilized by ILs with large viscosity (0-87Cp). Further increase of IL viscosity above 87Cp did not result in noticeable changes in the aperture stability.